如果你把 Skill 当成“提示词模板”,那基本还停留在 1.0 阶段。
Anthropic 的 skill-creator 实际做的是另一件事:定义一种“可执行、可组合、可加载”的 Agent 能力单元(Capability Unit)。
这篇文章从源码层面,拆掉它的抽象,讲清楚三件事:
先给一个更准确的定义:
Skill = 可触发的上下文片段 + 可选执行资源 + 明确边界条件
换句话说:
Skill ≈ Prompt Template + Tool Bundle + Lazy Loader
User Input
↓
Match(description)
↓
Load(SKILL.md)
↓
Reason()
├── need_knowledge → Load(references/)
└── need_action → Run(scripts/)
从 skill-creator 可以反推出一个隐式运行时模型:
flowchart TD
A[User Input] --> B[Skill Matcher]
B -->|匹配 description| C[Load SKILL.md]
C --> D[Agent Reasoning]
D -->|需要更多信息| E[Load references/]
D -->|需要执行| F[Run scripts/]
核心点:
skill-creator 最重要的一句话:
context window is a public good
翻译成工程语言:
Context Window = Shared Memory (多租户系统)
所以 Skill 的设计,本质是:
如何在有限 token 内实现最大能力密度
三层结构:
| 层级 | 内容 | 是否常驻 | 本质 |
|---|---|---|---|
| L1 | name + description | ✅ | Router |
| L2 | SKILL.md | ⚠️ 触发后加载 | Controller |
| L3 | scripts / refs | ❌ 按需加载 | Executor |
很多人误解 SKILL.md 是文档,其实它更接近:
Declarative Control Program
---
name: skill-creator
description: |
Guide for creating effective skills...
---
这里的关键不是 metadata,而是:
description = 触发条件 DSL(Domain Specific Language)
Agent 在做的其实是:
def should_trigger(skill, user_input):
return semantic_match(skill.description, user_input)
👉 所以 description 必须:
skill-creator 强制使用祈使句,本质原因不是风格,而是:
减少推理分支(branching factor)
对比:
❌ You should run the script
→ 需要判断 should 不 should
✅ Run the script
→ 直接执行
等价于:
# bad
if should_run():
run()
# good
run()
抽象成代码结构:
class Skill:
def __init__(self):
self.trigger = description
self.controller = instructions
self.resources = {
"scripts": [],
"references": []
}
下面不是复述,而是解释它们为什么存在。
不是“简洁”,而是:
Maximize (Useful Information / Token)
换算成工程指标:
Information Density ↑
Redundancy ↓
典型优化:
❌ 解释 + 示例
✅ 只留示例
因为:
Example > Explanation
Skill 实际是在控制 Agent 的搜索空间:
High freedom → 大搜索空间 → 灵活但不稳定
Low freedom → 小搜索空间 → 稳定但僵化
映射:
| 形式 | 本质 |
|---|---|
| 文本指令 | unconstrained reasoning |
| 伪代码 | semi-constrained |
| 脚本 | fully constrained |
本质就是:
def load_skill():
load(metadata)
if triggered:
load(body)
if needed:
load(resources)
这和:
是一个思路。
多余文件的本质问题:
Noise ↑ → Attention Dilution ↑ → Performance ↓
Agent 不会“忽略无关信息”,它只会:
被污染
Skill 是否触发,只看 description:
Body 再好,如果 description 写烂 = 永远不会触发
所以:
description ≈ API Gateway
本质:
减少 token 内的决策节点
Single Source of Truth
否则:
冲突 → agent 不确定 → 输出退化
skill-creator 其实隐含了三种模式:
User Request → Step1 → Step2 → Step3
在 SKILL.md 里表现为:
1. Extract text
2. Analyze structure
3. Generate output
例如:
python scripts/convert_format.py input.docx output.pdf
本质是:
def tool(input):
return subprocess.run(...)
See references/ooxml-reference.md
等价于:
if need_deep_knowledge:
load(reference)
你给的 docx-processor,其实是一个非常标准的 Skill 工程。
我们从代码层面看它的优点。
if len(sys.argv) != 3:
print('usage...')
sys.exit(1)
这是典型:
Fail Fast + Deterministic Interface
cmd = ['pandoc', input_path, '-o', output_path]
本质:
Skill 不实现能力 → 调用系统能力
不是文档,而是:
On-demand Knowledge Base
当 agent 需要:
低级格式操作(XML)
才加载。
for table in doc.tables:
说明:
Skill 必须覆盖“隐含结构”
否则 agent 会漏信息。
不是理论,直接给工程 checklist:
skill-creator 真正教你的不是:
“怎么写 Skill”
而是:
如何为 AI 设计一个最小认知负担的执行环境
或者更直白一点:
Skill = 给模型“减负”的工程体系
如果你接下来想更硬核一点,我们可以继续往下拆两层:
这两块才是现在 Cursor / Claude Code 真正的竞争核心。