claude-code - 💡(How to fix) Fix [FEATURE] Hook Retry Limit [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#45309Fetched 2026-04-09 08:08:20
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
labeled ×2

Fix Action

Fix / Workaround

My current workaround is a shell script wrapping my hook with a per-session_id retry limit from stdin.

RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing requests and this feature hasn't been requested yet
  • This is a single feature request (not multiple features)

Problem Statement

Many tools that may be added to claude Done hooks might return a non-zero exit code on failure. If claude fails to fix these, they might return non-zero exit code every time. When this happens, I'd like a fallback mechanism for my hooks to not loop.

Proposed Solution

I would prefer a new argument in hooks in settings.json that lets me input a retry limit. This would prevent claude from looping forever and wasting tokens.

Alternative Solutions

My current workaround is a shell script wrapping my hook with a per-session_id retry limit from stdin.

Priority

High - Significant impact on productivity

Feature Category

CLI commands and flags

Use Case Example

Adding a typechecker to my Done hook.

Additional Context

No response

extent analysis

TL;DR

Implement a retry limit for hooks in settings.json to prevent infinite looping when a hook returns a non-zero exit code.

Guidance

  • Consider adding a retry_limit argument to the hooks section in settings.json to specify the maximum number of retries for a hook.
  • Evaluate the current workaround using a shell script with a per-session_id retry limit to determine if it can be adapted as a temporary solution.
  • Investigate how to handle hooks that return non-zero exit codes to prevent wasting tokens and improve overall productivity.
  • Review the Done hook implementation to ensure it can be extended to support a retry limit or fallback mechanism.

Example

No code example is provided as the issue does not contain sufficient technical details to generate a accurate snippet.

Notes

The proposed solution requires modifications to the settings.json file and potentially the hooks implementation. The alternative solution using a shell script may have limitations or drawbacks that need to be considered.

Recommendation

Apply workaround: Implement the proposed retry_limit argument in settings.json to prevent infinite looping and improve productivity.

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