Answer: Claude Code hooks use exit code 0 for success, exit code 2 for a blocking error, and any other code for a non-blocking error. Exit code 2 blocks the action: on events that can block, Claude Code stops the action, and the block message is the hook's stderr. Status: Confirmed Entry: tool/claude-code/agents-and-automation/hook-exit-codes Revision: 2 Digest: sha256:f5f8696df1d4760d (changes whenever the content changes) Timeline: Created: 2026-11-13T03:04:24Z Last changed: 2026-11-16T12:09:30Z (exit code 2 behavior: — → 2) Last verified: 2026-11-20T12:21:23Z Next check: 2026-11-21T12:21:23Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of success exit code | 0 | [1] | 2026-11-20 blocking error exit code | 2 | [1] | 2026-11-20 non-blocking error exit code | any other code | [1] | 2026-11-20 exit code 2 behavior | 2 | [1] | 2026-11-20 block message source | stderr | [1] | 2026-11-20 Sources: [1] Anthropic. "Hooks reference". https://code.claude.com/docs/en/hooks.md Role: primary. Accessed: 2026-11-20T12:21:23Z Quote: "**Success**: your hook exits 0." (Supports: success exit code) Quote: "**Blocking error**: your hook exits 2." (Supports: blocking error exit code) Quote: "**Non-blocking error**: your hook exits with any other code" (Supports: non-blocking error exit code) Quote: "Exit with code 2 to block the action." (Supports: exit code 2 behavior) Quote: "The message that comes with the block is your hook's stderr." (Supports: block message source) Published: 2026-11-20T10:20:03Z Snapshot SHA-256: d55a7aff8ea51f8313b678ce1156d51dc20d90b11795b6c43c3e90f98b939727 (captured 2026-11-20T12:21:23Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. Cross-check: not-available at 2026-11-20T12:21:23Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:21:23Z Last attempt: 2026-11-20T12:21:23Z Notes and limitations: Extracted automatically from a single official source (section "Exit code output"). Related: https://latestn.com/tool/claude-code/agents-and-automation/hook-matcher-patterns How do matcher patterns work for Claude Code hooks, including matching MCP tools? https://latestn.com/tool/claude-code/agents-and-automation/isolate-subagents-worktrees How do I isolate subagents in separate worktrees in Claude Code? https://latestn.com/tool/claude-code/agents-and-automation/load-plugin-in-sdk How do I load a plugin in the Claude Code Agent SDK? https://latestn.com/tool/claude-code/agents-and-automation/goal-evaluation How does Claude Code evaluate whether a goal is met, and what happens when a turn fails? https://latestn.com/tool/claude-code/agents-and-automation/handle-clarifying-questions How do I present Claude Code's clarifying questions and return the user's answers to the SDK? https://latestn.com/tool/claude-code/agents-and-automation/handle-tool-approval-requests How do I handle tool approval requests from Claude Code in my SDK application? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-16T12:09:30Z | changed | exit code 2 behavior: — → 2 | [1] 2026-11-16T12:09:30Z | changed | exit code 2 effect: 2 → — | [1] 2026-11-13T03:04:24Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/claude-code/agents-and-automation/hook-exit-codes/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/claude-code/agents-and-automation/hook-exit-codes POST: https://latestn.com/dispute/tool/claude-code/agents-and-automation/hook-exit-codes with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/claude-code/agents-and-automation/hook-exit-codes?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). What exit codes do Claude Code hooks use and what does exit code 2 do? Revision 2, last verified 2026-11-20T12:21:23Z. https://latestn.com/tool/claude-code/agents-and-automation/hook-exit-codes (accessed 2026-11-21T09:56:42Z). @misc{LatestN_tool_claude_code_agents_and_automation_hook_exit_codes_r2, title = {What exit codes do Claude Code hooks use and what does exit code 2 do?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/claude-code/agents-and-automation/hook-exit-codes}}, note = {Revision 2; digest sha256:f5f8696df1d4760d; last verified 2026-11-20T12:21:23Z; accessed 2026-11-21T09:56:42Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/claude-code/agents-and-automation/hook-exit-codes