Menu

1 / 5

Claude Code Hooks Decoded: Rules That Actually Run

DEV Community·Eugeniu Ghelbur·9 days ago
#KdX5AkD7
#dev#claude#code#hooks#hook
Long article (2179 words) — no AI summary yet.
Reading 0:00
15s threshold

TL;DR

Claude Code hooks are shell commands the runtime runs on set events. Those events include a tool call, session start, stop and a file change. Hooks run outside the model, and a failing exit code can block the action. Use them only for rules that must never break, like a secret scan or the tests.

A rule written in CLAUDE.md is a request. A hook is a rule.

One survey of 2,500 public Claude Code repos found hooks in 13.3% of them, so most projects run on requests.

The order that worked in mine: write the promise, add a check that fails, then wire the gate.

Someone opened an issue on my repo two weeks ago that I could not argue with.

The bootstrap message printed a line saying Claude reads your _CLAUDE.md automatically on every session. A contributor named motkoning pointed out that this is true only when three separate pieces of wiring are all in place: a SessionStart hook, an environment variable pointing at the vault, and a session actually started inside that vault.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.