跳到正文
Simon Willison·· 4 小时前AI 评分51

Geoffrey Huntley 谈用 pre-commit hook 约束编码智能体

Quoting Geoffrey Huntley

AI 导读

Simon Willison 引用 Geoffrey Huntley 的观点:当智能体不使用其诊断库时,与其内省并更新 AGENTS.md(仍会有偏差并逐渐漂移),不如写一个 pre-commit hook 检查 git diff 中绕过诊断模块、直接调用可观测性模块的代码,让提交失败并向智能体注入提示词要求其使用诊断库,效果立刻变成十分满分。

正文

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.

来源:Simon Willison · simonwillison.net