跳到正文
热点事件持续更新

Claude Code Stop hook 重试须用 exit 2

3 篇报道2 个报道来源1 小时前更新

先了解这件事

AI 综述

Lydia Hallie 称,在 Claude Code 的 Stop hook 中,若检查失败后要触发 Claude 再次修复,必须以 exit 2 退出:Claude 会读取 hook 的 stderr 并重试;exit 1 是非阻断性退出,检查失败时可能直接结束,也可能仅表示脚本自身出错。 她建议把检查命令的输出重定向到 stderr,并在失败时执行 `echo failed` 和 `exit 2`,推荐写法为 `[your command] >&2 || { echo failed; exit 2; }`,以便 Claude 同时获得失败原因并重新尝试修复。

AI 根据报道生成 · 22 分钟前更新

报道时间线

沿着报道,了解事件的不同侧面。

11月14日
  1. AGI Hunt
    Claude Code hook 补充:exit 1 可能是脚本报错,重试须用 exit 2

    Claude Code 的 Stop hook 中,exit 1 可能表示脚本自身出错,要求 Claude 重试时应使用 exit 2。Lydia Hallie 建议将命令输出重定向至 stderr,并在失败时执行 `echo failed` 与 `exit 2`,让 Claude 看到失败原因并触发重试。

  2. AIHOT
    Claude Code 用 Stop hook 让检查失败自动重试的技巧:关键在 exit code 2

    Lydia Hallie 分享了用 Claude Code 的 Stop hook 让 Claude 在检查失败后自动重试的技巧,关键是让 hook 以 exit code 2 退出。exit 2 会把 hook 的 stderr 返回给 Claude 从而触发重试,而 exit 1 是非阻塞的,检查失败时 Claude 也会直接结束。

  3. AGI Hunt
    Claude Code Stop hook 使用 exit 2 实现检查失败自动重试

    Lydia Hallie 分享了使用 Claude Code Stop hook 在检查失败时自动重试的技巧,关键是为阻断性退出配置 exit 2。exit 2 会让 Claude 读取 hook 的 stderr 输出并再次修复,exit 1 则可能直接结束;推荐写法为 `[your command] >&2 || { echo failed; exit 2; }`。

本事件热度走势

还没有足够的连续观测数据,暂不绘制趋势。