别把所有东西塞进 system prompt,按需加载
目录(catalog)放在 system prompt,只占 ~200 tokens。完整技能内容通过 tool_result 按需注入,避免一次性加载全部技能。
catalog → system_prompt
body → tool_result
假设有 5 个 skill,每个 ~2000 tokens。全部塞进 system prompt = 10000 tokens。按需加载只需 ~200 tokens 目录 + 当前 skill 内容。
10000 → 200 (98% saved)
每个 skill 文件用 YAML frontmatter 声明元数据(name, description, allowed_tools),正文是详细指令。解析时分离目录信息和完整内容。
--- metadata ---
# full instructions
"有哪些技能可用?"
"What skills are available?"
"加载 agent-builder skill 并按照它的说明操作"
"Load the agent-builder skill and follow its instructions"
"我需要做代码审查——先加载相关 skill"
"I need to do a code review -- load the relevant skill first"
"使用 mcp-builder skill 构建一个 MCP 服务器"
"Build an MCP server using the mcp-builder skill"