AI编码
dev.to ·
@Vildanden
用 Stop hook 阻止 Claude Code 在构建仍失败时宣称“完成”
文章介绍如何利用 Claude Code 的 Stop hook:当 Agent 准备结束回合时运行类型检查,若 npx tsc --noEmit 返回非零则 hook 以状态码 2 退出,阻止停止并把 stderr 内容回传给 Agent 作为继续修复的理由。文中给出完整 Python hook 代码和 .claude/settings.json 配置,并通过 stop_hook_active 判断避免无限循环。
AI推荐理由 给出 Claude Code Stop hook 的具体可运行代码与 settings.json 配置,用 tsc --noEmit 退出码阻止 Agent 在类型检查失败时宣告完成,并处理了 stop_hook_active 防死循环,对使用编码 Agent 的开发者有直接可复用价值。
68
正文
当前仅保存了标题或简介;并非所有来源都提供正文,可通过下方原文链接查看。