Where the AI's promises meet your guarantees
Hooks are user-defined commands, HTTP endpoints, or LLM prompts that fire at lifecycle events: SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PermissionRequest, Stop, plus a dozen more. They give you deterministic control where the model's compliance is statistical.
The two events that change every team's life: PreToolUse can block a tool call (exit code 2 + stderr message → tool cancelled, model sees the reason). PostToolUse runs after success — perfect for auto-format, type-check, run-affected-tests.
Hook types: command shells out (JSON on stdin, exit code controls flow), http POSTs to a URL (Slack notifications, audit logs), prompt asks Claude itself for a decision (great for permission gates that need judgment).