什么是 Agent Skill?

2.1 基本结构

一个 Agent Skill 是一个文件夹,必须包含 SKILL.md 文件,可选包含 scripts/references/assets/ 目录:

cafe-preparation/                 # 目录名使用 snake_case
├── SKILL.md                      # 必需:元数据 + 指令
├── scripts/                      # 可选:可执行代码
│   ├── calc_quantities.py
│   └── convert_to_ingredients.py
├── references/                   # 可选:补充上下文
│   ├── menu_and_recipes.md
│   └── minimums.md
└── assets/                       # 可选:模板、配置、schema
    ├── prep_sheet_template.md
    └── shopping_list_template.md

2.2 渐进式披露 (Progressive Disclosure)

这是 Skills 架构的核心创新 —— 三层加载机制:

┌─────────────────────────────────────────────────────────────┐
│  Layer 1: Metadata (name + description)                     │
│  → 始终存在于 Agent 上下文中 (~50 tokens)                   │
│  → 用于决定是否触发 Skill                                    │
├─────────────────────────────────────────────────────────────┤
│  Layer 2: SKILL.md Body                                     │
│  → 仅当 Skill 触发时加载                                    │
│  → 包含详细指令和工作流                                      │
├─────────────────────────────────────────────────────────────┤
│  Layer 3: Bundled Resources                                 │
│  → 仅在 SKILL.md 引用时加载                                │
│  → scripts/ 执行时不污染 token 窗口                         │
└─────────────────────────────────────────────────────────────┘

为什么这很重要?

假设你有 50 个 Skill: - 传统方式: 作为单个系统提示词 → 每次加载 15,000 tokens - Skills 方式: 仅加载描述 (~4,000 tokens) + 当前激活 Skill 的正文 (~2,000 tokens) → 总计约 6,000 tokens

Anthropic 的案例显示:将工作流转换为 Skills 可将活跃上下文从 150,000 tokens 减少到 2,000 tokens,减少超过 98%