三档递进子代理提示词重构 AGENTS.md 省 Token
分享一条可复用提示词,用三个由温和到激进的子代理重构 AGENTS.md,去除无效指令、渐进披露并拆分编码规范。
原始内容
Prompt of the day: /writing-for-agents my AGENTS.md is a hot mess, propose a series of restructurings that: - Remove no-ops - Use progressive disclosure - Move instructions to CODING_STANDARDS.md Apply your work over three subagents, each more radical than the last. Create a single PR. AGENTS.md is the most common source of token inefficiency. This prompt kills it dead.
中文译文
机器翻译,保留原文供核对。
今日提示词: /writing-for-agents 我的 AGENTS.md 一团乱麻,请提出一系列重构方案,要求: - 移除无效指令 - 使用渐进披露 - 将指令迁移到 CODING_STANDARDS.md 让三个子代理依次执行你的工作,一个比一个更激进。创建一个 PR。 AGENTS.md 是 token 效率低下的最常见来源。这个提示词能把它彻底干掉。
深度解析
是什么:Matt Pocock(知名 TypeScript 教育者与 AI 编程工具评论者)分享的“每日提示词”:让编码代理把混乱的 AGENTS.md 交由三个激进度递增的子代理重构,要求去除无效指令(no-ops)、采用渐进式披露(progressive disclosure)、把编码规范迁移到独立的 CODING_STANDARDS.md,最终合并为单个 PR。
核心设计:该提示词把文档重构当作一次可评审的代码变更来治理——三层子代理提供从保守到激进的方案梯度,便于对比取舍;“渐进式披露”让代理只按需加载细节而非全量塞入上下文;规范外置则把“给人看的规则”与“给代理看的导航”解耦。
关键洞察:作者点出 AGENTS.md 是最常见的 Token 低效来源。随着项目增长,这类文件往往堆叠重复、互相冲突的指令,每次会话都重复付费。用结构化提示词批量清理,是低成本高杠杆的上下文工程手段。
边界与风险:三个子代理的开销本身消耗 Token,小项目收益有限;“更激进”的一档可能误删看似冗余但实际必要的约束,仍需人工审查 PR 后合并;该思路依赖所用代理支持子代理与自动建 PR 的工作流。
精选追评与案例
指出 AGENTS.md 应拆分仓库规则与个人偏好,避免跨项目重复粘贴。
A lot of AGENTS.md bloat is two files in one: rules about the repo, and preferences about you (how small you like PRs, how terse you want answers). The repo rules belong in the file. The personal ones should follow you across every repo and tool instead of getting copied into each AGENTS.md
中文译文 · 机器翻译
很多 AGENTS.md 的臃肿,实际上是把两个文件合成了一个:关于仓库的规则,以及关于你个人的偏好(你喜欢多小的 PR、希望回答多简洁)。仓库规则应该留在这个文件里。个人偏好则应该跨所有仓库和工具跟随你,而不是被复制进每一个 AGENTS.md。
点明单纯移动内容不等于精简,关键是按需加载规则。
@mattpocockuk AGENTS.md is a router, not a junk drawer. Moving the bloat to CODING_STANDARDS.md just relocates it. The fix is loading a rule only when you need it.
中文译文 · 机器翻译
AGENTS.md 是路由器,不是杂物抽屉。把臃肿内容移到 CODING_STANDARDS.md 只是把它换了个地方。真正的修法是只在需要时加载某条规则。
补充了渐进披露的关键边界:必须有明确的任务到文件加载路径。
@mattpocockuk Progressive disclosure helps, but the third “more radical” pass often just relocates the same rules into CODING_STANDARDS.md with no load path. The real cut is an include graph: which file is read for which task class. If standards are always pulled in, you renamed the hot mess
中文译文 · 机器翻译
渐进披露有帮助,但第三轮“更激进”的处理往往只是把同样的规则搬进 CODING_STANDARDS.md,却没有给出加载路径。真正的裁剪是一张包含关系图:哪类任务该读哪个文件。如果规范总是被拉进来,那你只是给这团乱麻改了个名字。
给出可操作的规则注释保留法,兼顾删除依据与上下文成本。
i moved the notes behind my claude code rules into block html comments last month, after reading a paper on agent instruction files. it found those files more than triple over their life, because once nobody remembers why a rule is there nobody dares to delete it, and keeping the reason in a comment stopped the growth. claude code drops block comments before the model sees them, so the reason costs nothing to keep. https://t.co/MAHVRfPVym
中文译文 · 机器翻译
上个月,在读到一篇关于代理指令文件的论文后,我把 Claude Code 规则背后的说明移进了 HTML 块注释。论文发现,这些文件在其生命周期内会增长到三倍以上,因为一旦没人记得某条规则为什么存在,就没人敢删它;而把原因保留在注释里,就阻止了这种增长。 Claude Code 会在模型看到之前丢弃块注释,所以保留原因不产生任何成本。 https://t.co/MAHVRfPVym
追问 no-op 判定依据,提醒低频但关键的规则不能被误删。
@mattpocockuk How does it decide a line is a no-op? Some rules only matter on the one task a month that hits them. Does it look at past sessions or just read the file?
中文译文 · 机器翻译
它如何判断一行是无效指令?有些规则只在一个月才碰到一次的那类任务上才有用。它会查看过去的会话,还是只读文件本身?