Claude Code Stop hook 技巧:用 exit code 2 让 Claude 在检查失败时自动重试
原文标题:You can use a Stop hook to have Claude try again when a check fails, but make sure it exits with code 2!
AI 摘要
Lydia Hallie 分享一个 Claude Code 使用技巧:用 Stop hook 让 Claude 在检查失败后自动重试,关键是让 hook 以 exit code 2 退出。exit 2 会把 hook 的 stderr 返回给 Claude 触发重试,exit 1 则是非阻塞的,即使检查失败 Claude 也会直接结束。
关键信息
- Lydia Hallie 分享一个 Claude Code 使用技巧:用 Stop hook 让 Claude 在检查失败后自动重试,关键是让 hook 以 exit code 2 退出。
- exit 2 会把 hook 的 stderr 返回给 Claude 触发重试,exit 1 则是非阻塞的,即使检查失败 Claude 也会直接结束
- 原文讲清了 Claude Code Stop hook 中 exit 1 与 exit 2 的行为差异,可用于让检查失败时自动重试
速览
- 发布时间
- 分类
- 教程与技巧
- AI 评分
- 69
推荐理由
原文讲清了 Claude Code Stop hook 中 exit 1 与 exit 2 的行为差异,可用于让检查失败时自动重试。
相关实体
来源与版权
本文基于 AIHOT 公开 API 的精选标题与 AI 摘要整理,已注明来源并回链;原文版权归原媒体与作者所有,本站不镜像全文。
如何引用
引用本文时请保留标题、日期与永久链接,并注明来源为橙子新闻。
橙子新闻:Claude Code Stop hook 技巧:用 exit code 2 让 Claude 在检查失败时自动重试。2026年11月14日。https://new.nat6.net/news/p0jsxs2bnv6tmnmn1soi56759/