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.

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)→

Original post →

More from coding & agent

coding & agent channel →