RadarAI· X:Lydia Hallie(Anthropic,Claude Code) (@lydiahallie)·· 4 小时前AI 评分45
Claude Code 员工讲解 hook 退出码用法:exit 2 才能让 Claude 重试
AI 导读
Claude Code 的 Lydia Hallie 指出,hook 退出码 exit 1 也可能表示 hook 本身出错(如缺依赖或脚本 bug),想让 Claude 重试应改用 exit 2,并把输出写到 stderr 让它看到出错原因,示例写法为 "[your command] >&2 || { echo failed; exit 2; }"。
正文 · 原文
Lydia Hallie ✨· @lydiahallie · X·2026-11-14 02:43· 1 小时前AI 评分58
AI 导读
Lydia Hallie 说明 Claude Code 中 exit 1 也可能表示 hook 本身出错(如缺依赖或脚本 bug)。想让 Claude 重试应退出码用 2,并把输出写到 stderr,例如 "[your command] >&2 || { echo failed; exit 2; }"。
正文 · 原文
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; }"
来源:Lydia Hallie ✨ · x.com
事件后续 · 1
来源:RadarAI · aihot.news