This is a cross-post — the original (and any updates) live at broke2builtai.com.

You put "always run prettier after editing" in your CLAUDE.md. Claude does it... most of the time. Then one long session it edits nine files, formats six, and you find the mess in the diff. That gap — between a rule the model usually follows and a rule that always runs — is exactly what hooks close.

What Claude Code hooks actually are

Hooks are shell commands you define that Claude Code runs automatically at lifecycle events — before a tool call, after one succeeds, when you submit a prompt, when a session starts, when Claude finishes responding.

The key word is deterministic. Instructions in a CLAUDE.md file are suggestions the model reads and usually honors — but it can overlook one mid-task. A hook isn't read by the model at all. The harness executes it, every time the event fires, no judgment involved. Rules become guarantees.