跳到正文
X · Lydia Hallie·· 22 天前AI 评分15

Claude hook 退出码用法:用 exit 2 触发重试,错误输出走 stderr

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; }"

AI 导读

Claude hook 中 exit 1 也可能表示 hook 自身出错,例如缺少依赖或脚本有 bug。若希望 Claude 重试,应以 exit 2 退出,并把输出发送到 stderr,让 Claude 看到出错原因,例如 `[your command] >&2 || { echo failed; exit 2; }`。

打开原文x.com
博主
Lydia Hallie ✨@lydiahallie

粉丝 19万

Claude Code @AnthropicAI @ClaudeDevs

互动数据
浏览
1.2万
点赞
54
评论
3
分享
0
收藏
12

数字来自平台,为最近一次抓取时的数据。

来源:X · Lydia Hallie · x.com