claude-code - 💡(How to fix) Fix [DOCS] Stop hook docs omit consecutive block cap and override env var

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…

Fix Action

Fix / Workaround

PageLine(s)Context
https://code.claude.com/docs/en/hooks1894-1915Stop hook input and decision control mention preventing indefinite looping but not the built-in consecutive-block cap
https://code.claude.com/docs/en/hooks-guide913-926Troubleshooting still frames this as an infinite-loop problem with only the stop_hook_active workaround
https://code.claude.com/docs/en/env-vars180-251Environment variable reference does not list CLAUDE_CODE_STOP_HOOK_BLOCK_CAP
RAW_BUFFERClick to expand / collapse

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 receive stop_hook_active and last_assistant_message. 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 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 the stop_hook_active field from the JSON input and exit early if it's true:

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:

PageLine(s)Context
https://code.claude.com/docs/en/hooks1894-1915Stop hook input and decision control mention preventing indefinite looping but not the built-in consecutive-block cap
https://code.claude.com/docs/en/hooks-guide913-926Troubleshooting still frames this as an infinite-loop problem with only the stop_hook_active workaround
https://code.claude.com/docs/en/env-vars180-251Environment 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)"

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 [DOCS] Stop hook docs omit consecutive block cap and override env var