Skip to content
View original post on X: Lydia Hallie ✨
Published

How to make Claude retry after a hook fails

AILydia Hallie says Claude hooks should exit with code 2 to request a retry; exit code 1 can indicate the hook itself errored, such as from a missing dependency or script bug. She recommends sending error output to stderr so Claude can see what went wrong.
Lydia Hallie ✨Verified on X
@lydiahallie
View on X

Part of a thread · earlier post

exit 1 can also mean that the hook itself errored (eg a missing dependency or a bug in the hook script)

so exit with 2 when you want Claude to retry, and send the output to stderr so it can see what went wrong. something like "[your command] >&2 || { echo failed; exit 2; }"

Source details

Lydia Hallie ✨ · x.comPublished · added here

Original title: exit 1 can also mean that the hook itself errored (eg a missing dependency or a bug in the hook script)