Primary sourceViking
View sourceEvent ·Multi-source
用 pre-commit hook 限制文件不超过 5000 token,防止 Agent 改不动大文件
Matt Pocock 分享了一个提示词写法:让 Agent 生成一个 pre-commit hook,文件超过 5000 token(按字节除以 4 估算)就拦截提交。该 hook 只检查 staged 文件,跳过 lockfile 和代码生成产物。报错信息里附带如何拆分文件的具体指引。作者认为光写在 Agents.md 里不够,要变成不依赖 AI 自觉的硬性约束,因为大文件会超出 Agent 的上下文窗口,导致漏改和重复改。
Current read
Matt Pocock 提了个实用招:让 Agent 自己写个 git hook,文件超 5000 token 就不让提交,报错还教你怎么拆,代码库干净多了。
4 sources38° AI heatLast updated 2026/10/19 12:50:17
Evidence
4 sourcesRelated source 1arXiv cs.LG
View sourceRelated source 2IT之家
View sourceRelated source 3掘金本周最热
View sourceConflict check
Dedup data only shows that these sources discuss the same event, not that they agree. There is no structured supporting or refuting evidence yet, so no conflict is inferred automatically.