跳到正文
北京时间
原文
X:Lydia Hallie(Anthropic,Claude Code) (@lydiahallie)·· 15 天前AI 评分58

Claude Code 员工讲解 hook 退出码用法:exit 2 才能让 Claude 重试

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

AI 导读

Lydia Hallie 说明 Claude Code 中 exit 1 也可能表示 hook 本身出错(如缺依赖或脚本 bug)。想让 Claude 重试应退出码用 2,并把输出写到 stderr,例如 "[your command] >&2 || { echo failed; exit 2; }"。

来源:X:Lydia Hallie(Anthropic,Claude Code) (@lydiahallie) · x.com