claude-code - 💡(How to fix) Fix Documentation contradiction: multi-hook firing order is documented as "parallel" in Agent SDK docs but "sequential with short-circuit" in hooks-guide [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#57800Fetched 2026-05-11 03:25:04
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
labeled ×3
RAW_BUFFERClick to expand / collapse

The Claude Code documentation contradicts itself on what happens when multiple hooks are registered on the same matcher (or fire on the same event). Two official docs say different things.

Source 1 — Agent SDK hooks reference (https://code.claude.com/docs/en/agent-sdk/hooks)

"When an event fires, all matching hooks run in parallel. For permission decisions, the most restrictive result wins: a single deny blocks the tool call regardless of what the other hooks return."

Source 2 — Hooks guide (https://code.claude.com/docs/en/hooks-guide)

"Hooks run in order, and the first failure blocks the rest. If one hook exits with a blocking exit code (exit code 2), subsequent hooks won't run."

Why this is a contradiction

These describe different mechanics:

  • "Parallel + restrictive-result-wins" implies all hooks always run; their results are merged after every hook completes.
  • "Sequential + short-circuit on exit code 2" implies hooks run in a deterministic order and a blocking hook prevents subsequent hooks from running at all.

A hook author cannot predict which behavior applies.

Why it matters

Concrete scenario: two hooks register on PreToolUse(ExitPlanMode):

  1. A model-tier guardrail that exits 2 (or returns decision: "block") when the active model is wrong.
  2. A side-effect hook that writes the approved plan to a file and updates a tracker issue.

If "parallel" is correct, the file-write happens regardless of the guardrail's verdict — bad outcome (we wrote a wrong-tier plan).

If "sequential with short-circuit on exit code 2" is correct, registration order matters and the file-write is correctly suppressed when the guardrail blocks — good outcome, but only if the project knows to register the guardrail first.

Without a definitive answer, hook authors either over-engineer (re-implement the guardrail check inside every dependent hook) or under-engineer (assume sequential and get burned when the runtime is parallel).

Asks

  1. Which behavior is the actual implementation in current Claude Code?
  2. If parallel: how should the "blocking exit code 2 stops subsequent hooks" passage in the hooks-guide be reconciled?
  3. If sequential: does the short-circuit apply only to exit-code-based blocking, or also to JSON decision: "block"? And what determines firing order — registration order in settings.json, alphabetical, or something else?
  4. Once resolved, please update both docs to match.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Documentation contradiction: multi-hook firing order is documented as "parallel" in Agent SDK docs but "sequential with short-circuit" in hooks-guide [1 participants]