insight Simon Willison 2026-10-13T13:32 正文 ok 85 words

引用 Geoffrey Huntley:用 Git 钩子约束 Agent 使用诊断库

英文标题:Quoting Geoffrey Huntley

Geoffrey Huntley 提出,与其依赖更新 AGENTS.md 来提醒 AI Agent 使用诊断库,不如通过 pre-commit hook 强制执行这一约束。该钩子会检查 Git diff,识别是否存在绕过诊断库、直接调用可观测性模块的代码。一旦发现违规,提交将被阻止,并向 Agent 注入提示,要求其改用诊断库。这种将开发规范编码为自动化校验的方式,可减少 Agent 指令漂移并提升代码一致性。
打开原文相关 3.6 · 机会 2

中文

2026 年 10 月 13 日

如果 Agent 没有使用我的诊断库,我可以进行自省并更新 AGENTS.md,但两者之间仍然会存在差异,而且会逐渐漂移。相反,我会编写一个 pre-commit hook,检查 git diff 中是否有绕过我的诊断库、直接调用可观测性模块的情况。砰:让提交失败,并注入一条提示,告诉 Agent 使用诊断库。突然之间,效果就变成了满分,十全十美。

— Geoffrey Huntley,已经不该再有人亲手编写代码了。剩下的事情如下。

English / 原文

13th October 2026

If the agent isn't using my diagnostics library, I could introspect and update AGENTS.md, but there's still a delta, and it'll drift. Instead, I write a pre-commit hook that checks the git diff for direct calls to observability modules that bypass my diagnostics module. Boom: fail the commit, inject a prompt telling the agent to use the diagnostics library. All of a sudden it's ten out of ten.

— Geoffrey Huntley, nobody should type code by hand anymore. here's what's left.