Claude Code tip: use Stop hooks with exit 2 to auto-retry on failed checks
lydiahallie · x · 2026-11-14
Lydia Hallie shares a practical Claude Code technique: use a Stop hook to make Claude automatically retry when a check fails — but the exit code matters.
- exit 2 is blocking: Claude reads the hook's stderr and retries the fix
- exit 1 is non-blocking: Claude finishes even when the check failed (and exit 1 can also mean the hook itself errored, e.g. a missing dependency or a bug in the script)
The accompanying diagram contrasts both flows: with exit 2, Claude reads the error from stderr, edits again, and tests pass. Suggested pattern: [your command] >&2 || { echo failed; exit 2; }.
Related event: Claude Code Stop hook tip: use exit 2 to trigger auto-retry(2 posts)→
More from coding & agent
- FastMCP 4.2 Ships Skills Over MCP, Pairing Tools With Usage Guidance — jlowin123 · 2026-11-14
- Dev reverse-engineers Waymo's private API into a Cloudflare Worker MCP for Claude — MicahBerkley · 2026-11-14
- Dev's fix for chaotic agent work: a feed-shaped todo list with action buttons — _rchaves_ · 2026-11-14
- Dev replaces his smartphone with 8 Raspberry Pis controlled by OpenAI's Dot — OpenAIDevs · 2026-11-14
- Garry Tan open-sources idea-miner skill that turns your last 48 hours into a ranked build list — garrytan · 2026-11-14
- LLMLean is back: LLM-powered proof suggestions for Lean, local or cloud — wellecks · 2026-11-14