How agent hooks work
When an agent hook fires:
- Claude Code spawns a subagent with your prompt and the hook's JSON input
- The subagent can use tools like Read, Grep, and Glob to investigate
- After up to 50 turns, the subagent returns a structured
\{ "ok": true/false \}decision - Claude Code allows the action if
okistrue. Ifokisfalse, Claude Code handles the block the same way as a prompt hook withcontinueOnBlock: trueon that event, as listed under Response schema
Agent hooks are useful when verification requires inspecting actual files or test output, not just evaluating the hook input data alone.