How I cut AI agent skill context bloat under 4,000 tokens across my stack
本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。
If you keep adding skills and AGENTS.md rules to your AI coding setup, you eventually hit a quiet tax: your assistant burns thousands of tokens before you even type your first prompt. In my own setup, auto-loading a 97-skill growth pack ate roughly 3,950 startup tokens on one assistant, and an 89-skill trading pack ate roughly 3,680 tokens on another.
如果你不断地在 AI 编程配置中添加技能和 AGENTS.md 规则,最终会面临一种隐形的代价:你的助手在你输入第一个提示词之前就已经消耗了数千个 Token。在我自己的配置中,自动加载一个包含 97 项技能的增长包,在一个助手上就消耗了大约 3,950 个启动 Token,而另一个包含 89 项技能的交易包则消耗了大约 3,680 个 Token。
Fixing that context bloat started with treating startup instructions like a menu instead of a full recipe book. Once that lightweight skill pattern worked across my 14 custom assistants, I rolled the same 20-skill library out to five external coding CLIs on my Windows ARM64 laptop, which triggered cross-tool hook leaks, a backup overwrite, and three Windows-specific snags that hit the exact same stack.
解决这种上下文臃肿问题的第一步,是将启动指令视为一份菜单,而不是一本完整的食谱。一旦这种轻量级技能模式在我 14 个自定义助手上运行成功,我就将同样的 20 项技能库部署到了我 Windows ARM64 笔记本电脑上的五个外部编程 CLI 中,这引发了跨工具钩子泄露、备份覆盖以及三个针对 Windows 的特定故障,这些问题都发生在了同一个技术栈上。
TL;DR On Windows ARM64 (Nov 2026), treating startup skills like a menu (short descriptions + <=8 pinned core skills) kept 14 custom Raven agents at 1,269 to 3,731 active skill tokens (638 to 666 for 6 shared skills). Scaling our 20-skill catalog across 5 external coding CLIs with separate hook files hit zero hook leakage across 23 configs.
简而言之:在 Windows ARM64(2026 年 11 月)上,将启动技能视为菜单(简短描述 + 最多 8 个固定的核心技能)使 14 个自定义 Raven 代理的活跃技能 Token 保持在 1,269 到 3,731 之间(6 个共享技能仅占 638 到 666 个 Token)。将我们的 20 项技能目录扩展到 5 个外部编程 CLI 并使用独立的钩子文件后,在 23 种配置中实现了零钩子泄露。
AGENTS.md vs. on-demand skills: the menu and recipe book pattern Keep always-on instruction files (AGENTS.md, CLAUDE.md, copilot-instructions.md) thin with global rules and one startup pointer, and store deep workflows in on-demand skill folders. That split resolves the trade-off highlighted by Vercel’s agent evals: putting every rule upfront guarantees visibility in short demos but bloats context at scale, while unindexed skill folders save tokens but get skipped unless a startup pointer tells the model when to check them.
AGENTS.md 与按需技能:菜单与食谱模式。保持常驻指令文件(AGENTS.md、CLAUDE.md、copilot-instructions.md)精简,仅包含全局规则和一个启动指针,并将深度工作流存储在按需调用的技能文件夹中。这种拆分解决了 Vercel 代理评估中强调的权衡问题:将所有规则放在前面虽然能保证在简短演示中的可见性,但在大规模使用时会造成上下文臃肿;而未索引的技能文件夹虽然节省了 Token,但除非有启动指针告诉模型何时检查,否则它们会被忽略。
The simplest mental model is the difference between a menu and a recipe book. At startup, you hand the assistant a short menu: a thin startup pointer and a list of skill names with one-line descriptions. The full step-by-step recipes stay closed on the shelf until a task matches one of them. You do not need custom tooling to use this pattern today.
最简单的思维模型就是菜单和食谱之间的区别。在启动时,你交给助手一份简短的菜单:一个精简的启动指针和一份带有单行描述的技能名称列表。完整的逐步食谱则留在书架上,直到任务与其中某项匹配时才会被调用。你现在无需任何自定义工具即可使用这种模式。
In Claude Code (Anthropic’s terminal coding agent), OpenAI Codex (OpenAI’s CLI coding agent), or GitHub Copilot CLI, keep your global instruction file concise, cap always-active skills at roughly 7 or 8 core workflows per domain, and leave deep reference guides inside your skills folder to load on demand.
在 Claude Code(Anthropic 的终端编程代理)、OpenAI Codex(OpenAI 的 CLI 编程代理)或 GitHub Copilot CLI 中,请保持全局指令文件简洁,将每个领域的常驻活跃技能限制在 7 到 8 个核心工作流左右,并将深度参考指南留在技能文件夹中按需加载。