技巧精选

Geoffrey Huntley:用 pre-commit hook 约束编码智能体的写法

Quoting Geoffrey Huntley

精选理由

与其反复改 AGENTS.md 提醒智能体,不如让 commit 直接失败并注入提示,这个技巧挺狠的。

Geoffrey Huntley 分享了一种管理编码智能体的做法:与其依赖 AGENTS.md 让智能体遵守规则,不如写一个 pre-commit hook,在 git diff 中检查绕过 diagnostics 库、直接调用 observability 模块的代码。

正文

检测到违规时让提交失败,并向智能体注入提示要求改用 diagnostics 库。Huntley 称这种方式让智能体的遵循效果达到十分。

Simon Willison 引用了这段话并标注了 coding-agents 与 agentic-engineering 标签。

原文 · Simon Willison’s Weblog

Quoting Geoffrey Huntley

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. Tags: coding-agents , generative-ai , git , agentic-engineering , ai , geoffrey-huntley , llms

产业坐标与信源核验

本条情报归属 AITOP「技巧」核心栏目,重点聚焦北美前沿实验室与硅谷科技巨头。在跨区域产业观察坐标中,该动态直接关联「AI 开发者工具链、Coding Agent 与工程化实践」研究主线,反映出当前技术演进与商业落地的最新风向。涉及核心实体与技术议题包括:coding-agents、AGENTS.md、git、pre-commit hook,读者可通过下方标签进入对应专题页查阅历史脉络与关联对比。

信源核验说明:本文原始线索采编自「Simon Willison’s Weblog」,经 AITOP 多维评分管线结构化提炼。