The hook system — shipped scripts that Claude Code runs on session and tool lifecycle events
Notes & tips
- Fail open on bad input. Exit
0on any non-JSON / non-dict stdin; only a deliberate policy decision should exit2. - Only
2blocks. Every other exit code allows the tool. - Keep hooks fast. They run on the critical path under a timeout.
- One event name space. The event names (
PreToolUse, …) are the Claude Code names.