Exit 1 can mean the hook itself errored — use exit 2 for Claude Code retries

lydiahallie · x · 2026-11-14

Follow-up to Lydia Hallie's Stop hook tip: exit 1 can also mean the hook itself errored (e.g. a missing dependency or a bug in the hook script), so use exit 2 when you want Claude to retry, and send output to stderr so it can see what went wrong.

Concrete pattern provided: [your command] >&2 || { echo failed; exit 2; } — redirect output to stderr and exit 2 on failure to trigger the retry loop.

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 →