[DOCS] Stop hook docs omit consecutive block cap and override env var
Documentation Type
Missing documentation (feature not documented)
Documentation Location
https://code.claude.com/docs/en/hooks
Section/Topic
Stop hook input and decision control, plus the stop-hook troubleshooting guidance
Current Documentation
The docs currently say:
In addition to the common input fields, Stop hooks receivestop_hook_activeandlast_assistant_message. Thestop_hook_activefield istruewhen Claude Code is already continuing as a result of a stop hook. Check this value or process the transcript to prevent Claude Code from running indefinitely.
And the troubleshooting guide says:
Claude keeps working in an infinite loop instead of stopping. Your Stop hook script needs to check whether it already triggered a continuation. Parse thestop_hook_activefield from the JSON input and exit early if it'strue:
What's Wrong or Missing?
Changelog v2.1.143 introduced a built-in safeguard for repeatedly blocked stop hooks, but the hooks documentation does not describe that behavior.
A. The built-in cap is not documented
The current hooks docs explain how to avoid indefinite looping by checking stop_hook_active, but they do not say that Claude Code now ends the turn with a warning after 8 consecutive stop-hook blocks instead of continuing forever.
B. The override is not documented
The release entry names CLAUDE_CODE_STOP_HOOK_BLOCK_CAP as the override for that threshold, but the environment variable reference does not document this variable.
C. User-visible behavior is missing
The docs do not tell users what happens when the cap is reached, so someone debugging a repeatedly blocking Stop hook has no documentation explaining why the turn stopped with a warning.
Suggested Improvement
Add a short note to the Stop / SubagentStop documentation explaining the built-in circuit breaker, for example:
Claude Code limits repeated Stop-hook continuations. After 8 consecutive blocks, the turn ends with a warning instead of continuing indefinitely. To change that threshold, set CLAUDE_CODE_STOP_HOOK_BLOCK_CAP.
Also update the troubleshooting section in https://code.claude.com/docs/en/hooks-guide so the "Stop hook runs forever" section mentions that newer versions end the turn after the consecutive-block cap is reached, and add CLAUDE_CODE_STOP_HOOK_BLOCK_CAP to https://code.claude.com/docs/en/env-vars.
Impact
Medium - Makes feature difficult to understand
Additional Context
Affected Pages:
| Page | Line(s) | Context |
|------|---------|---------|
| https://code.claude.com/docs/en/hooks | 1894-1915 | Stop hook input and decision control mention preventing indefinite looping but not the built-in consecutive-block cap |
| https://code.claude.com/docs/en/hooks-guide | 913-926 | Troubleshooting still frames this as an infinite-loop problem with only the stop_hook_active workaround |
| https://code.claude.com/docs/en/env-vars | 180-251 | Environment variable reference does not list CLAUDE_CODE_STOP_HOOK_BLOCK_CAP |
Total scope: 3 pages affected
Source: Changelog v2.1.143
Exact changelog entry: "Fixed stop hooks that block repeatedly looping forever - the turn now ends with a warning after 8 consecutive blocks (override via CLAUDE_CODE_STOP_HOOK_BLOCK_CAP)"
3 Comments
+1 — ran into the 8-block cap last week while testing a Stop hook that gates session-end on verification (
.claude/state/stop-verify.logmust contain aVERIFIEDentry from the last 5 min, otherwiseexit 2). When the model loops trying to log-then-stop-then-log, the cap kicks in and the user just sees the turn end silently.Two concrete docs requests from the user side:
decision: "approve"+ stderr message is the right shape.For anyone hitting this in the wild before docs land: I open-sourced the Stop hook pattern I'm using at https://github.com/ianymu/claude-verify-before-stop (pure bash, MIT) — the relevant bit is using
exit 2for the block + checkingstop_hook_activeto avoid stacking blocks. The cap behavior caught me by surprise too; would love this documented.Issue #59583 Verification
Title: [DOCS] Stop hook docs omit consecutive block cap and override env var
Issue Date: 2026-05-16
Verification Date: 2026-06-04
Status: RESOLVED
---
Issue Summary
This issue reports that the Stop hook documentation did not explain the built-in cap that ends a turn after repeated Stop-hook blocks, did not document the
CLAUDE_CODE_STOP_HOOK_BLOCK_CAPoverride, and did not describe the warning users see when that cap is reached.---
Verification Results
Claim 1: The main hooks page does not document the built-in Stop-hook block cap
Status: RESOLVED
At https://code.claude.com/docs/en/hooks, line 2053 now states:
The stop_hook_active field is true when Claude Code is already continuing as a result of a stop hook. Check this value or process the transcript to avoid blocking on a condition that will never resolve. Claude Code overrides the hook and ends the turn after 8 consecutive blocks.Verdict: The main hooks page now documents the built-in circuit breaker and its default threshold of 8 consecutive blocks.
---
Claim 2: The documentation does not describe the user-visible warning behavior when the cap is reached
Status: RESOLVED
At https://code.claude.com/docs/en/hooks-guide, lines 918-920, the troubleshooting guide now says:
Claude keeps working instead of stopping, then ends the turn with a warning that the Stop hook blocked too many consecutive times.It then states:Claude Code overrides a Stop hook after it blocks 8 times in a row without progress.At line 931, the same section adds:If your hook legitimately needs more than eight iterations to converge, raise the cap with CLAUDE_CODE_STOP_HOOK_BLOCK_CAP.Verdict: The troubleshooting guide now documents both the warning users see and the capped Stop-hook behavior.
---
Claim 3: The environment variable reference does not document
CLAUDE_CODE_STOP_HOOK_BLOCK_CAPStatus: RESOLVED
At https://code.claude.com/docs/en/env-vars, line 246, the environment variable table now includes:
CLAUDE_CODE_STOP_HOOK_BLOCK_CAP | Maximum number of consecutive times a Stop or SubagentStop hook may block the turn from ending before Claude Code overrides it and ends the turn anyway (default: 8). Set to 0 to disable the cap.Verdict: The override variable is now documented with its purpose, default behavior, and disable option.
---
Current State
| Claim | Status |
|-------|--------|
| Main hooks page omits the built-in Stop-hook block cap | RESOLVED |
| User-visible warning behavior is missing from the docs | RESOLVED |
| Environment variable reference omits
CLAUDE_CODE_STOP_HOOK_BLOCK_CAP| RESOLVED |---
Suggested Fix
N/A - issue has been resolved.
---
References
CLAUDE_CODE_STOP_HOOK_BLOCK_CAP.CLAUDE_CODE_STOP_HOOK_BLOCK_CAP, its default of 8, and that0disables the cap.the turn now ends with a warning after 8 consecutive blocks (override via CLAUDE_CODE_STOP_HOOK_BLOCK_CAP).---
Conclusion & Recommendation
Primary Concern: The docs previously failed to explain the Stop-hook consecutive-block cap, the warning shown when that cap is hit, and the override environment variable.
Resolution Status: RESOLVED
Recommendation: CLOSE
The current hooks, troubleshooting, and environment variable pages now document the cap, the warning behavior, and the override variable. The issue's reported documentation gaps are no longer present.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.