The hook system — shipped scripts that Claude Code runs on session and tool lifecycle events

Failure modes

Symptom Cause Fix Severity
Hook blocks a real tool on odd input script raised / exited non-zero on malformed stdin parse defensively and exit 0 on any non-dict / non-JSON payload high
Tool not blocked when it should be wrong exit code (only 2 blocks a PreToolUse) sys.exit(2) to block high
Banner or side effect missing script exceeded its hooks.json timeout and was killed keep the script fast; move slow work off the critical path medium
Hook never fires event not wired in hooks.json, or wrong event name check the mapping and the Claude Code event name medium

Risk areas

Diagnosis order

  1. Is the event wired to the script in hooks.json?
  2. What exit code does the script return for this payload?
  3. Does it fail open on malformed stdin?
  4. Is it finishing inside its timeout?