Skill 可以理解成给 LLM(大语言模型)准备的一份“可加载操作手册”。它不直接扩展模型能力,也不会凭空生成一个新工具,而是在合适的时机把一组指令、流程、约束、示例和参考资料注入到上下文里,让模型按照这些规则使用已有工具完成任务。
如果一个 Skill 写得好,模型会在正确场景加载它,按预期步骤执行,遇到异常知道如何降级,不确定时知道停下来让人确认。
如果写得不好,常见问题通常不是“模型不会”,而是 Skill 没有说清楚:什么时候用、按什么顺序做、哪些事不能做、做到什么程度才算完成。
Skill 的基本结构
一个 Skill 通常是一个目录,最核心的文件是 SKILL.md。这个文件由两部分组成:
- YAML frontmatter:告诉模型这个 Skill 叫什么、什么时候应该加载。
- Markdown 正文:告诉模型加载后应该怎么执行。
典型目录结构如下:
my-skill/
├── SKILL.md # 必需:Skill 主文件
├── scripts/ # 可选:可执行脚本
├── references/ # 可选:详细参考资料,按需读取
├── resources/ # 可选:模板、清单、配置样例
└── examples/ # 可选:输入输出示例
Skill 的执行链路可以画成这样:
flowchart LR
A[用户提出任务] --> B[LLM 扫描 Skill frontmatter]
B --> C{description 是否匹配}
C -- 否 --> D[不加载 Skill]
C -- 是 --> E[调用 skill 工具]
E --> F[读取 SKILL.md]
F --> G[内容注入上下文]
G --> H[LLM 使用已有工具执行]
H --> I[返回结果或继续追问]
这里有一个关键点:Skill 本质上是“知识注入”,不是“工具注册”。
也就是说,Skill 不能让模型突然拥有一个新的系统工具。它只是告诉模型:在这个场景下,你应该如何使用已有的 bash、read、edit、search 等工具。目录里的脚本、模板和参考资料只是辅助材料,真正执行动作的仍然是模型已经具备的工具能力。
frontmatter 决定 Skill 能不能被正确加载
SKILL.md 的开头必须放 YAML frontmatter。最小结构通常是这样:
---
name: test-driven-development
description: Use when implementing any feature or bugfix, before writing implementation code.
---
其中最重要的是 description。模型会根据它判断当前用户请求是否需要加载这个 Skill。很多 Skill 不生效,不是正文写得差,而是 description 写得太模糊,模型根本不会加载。
必填字段
| 字段 | 作用 | 写法要求 |
|---|---|---|
name | Skill 的唯一标识 | 小写字母、数字、连字符,例如 vercel-deploy |
description | 触发条件说明 | 写清使用场景、用户可能的说法、时序位置 |
一个好的 description 不应该只说“帮助部署”,而要把触发语义写具体。
---
name: vercel-deploy
description: Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "push this live", or "create a preview deployment".
---
对比一个不够好的版本:
---
name: deploy-helper
description: Helps with deployment stuff.
---
第二个描述的问题很明显:
“deployment stuff”范围太大,模型无法判断它适合 Vercel、Cloudflare、Kubernetes 还是其他平台;也不知道用户说“push this live”时是否应该加载它。
description 的 4 个写作要点
| 要点 | 说明 | 示例 |
|---|---|---|
| 写出用户原话 | 把用户可能输入的短语放进去 | "deploy my app"、"push this live" |
| 写出时序位置 | 说明在什么之前或之后使用 | before writing implementation code |
| 写出产品关键词 | 大平台 Skill 要列出产品名 | Vercel、Workers、Pages、R2、D1 |
| 写出边界 | 说明不适合什么场景 | Do not use for production deployment unless explicitly requested |
如果 Skill 是工作流类型,时序位置尤其重要。例如 TDD(测试驱动开发)Skill 的触发点不是“写完代码后”,而是“写实现代码之前”。这类信息必须写进 description,否则模型很可能在错误阶段才想起加载。
可选扩展字段
除了 name 和 description,一些复杂 Skill 会增加扩展字段。它们不一定属于统一规范,但对模型理解 Skill 很有帮助。
| 字段 | 适合场景 | 作用 |
|---|---|---|
references | 主文件引用外部资料 | 告诉模型优先读取哪些参考文档 |
allowed-tools | 工具权限受控的环境 | 声明可能需要的工具,例如 bash、read、edit |
type | Skill 类型较多时 | 标记为 workflow、component、analysis 等 |
best_for | 适用范围复杂时 | 列出最适合的任务 |
scenarios | 触发条件容易混淆时 | 给出更具体的用户场景 |
estimated_time | 长流程 | 告诉用户大致耗时 |
示例:
---
name: product-discovery-process
description: Use to guide a multi-stage product discovery workflow with research, synthesis, decision checkpoints, and handoff artifacts.
type: workflow
best_for:
- new product exploration
- validating ambiguous product ideas
- multi-week discovery projects
estimated_time: 2-6 weeks
---
frontmatter 不需要写成长篇说明。它的目标是“让模型快速判断是否加载”,不是承载全部执行细节。详细流程应该放到正文或 references/ 目录里。
SKILL.md 正文应该承担什么职责
SKILL.md 正文是模型加载 Skill 后真正会阅读的操作说明。好的正文通常包含 5 类信息:
| 内容 | 作用 |
|---|---|
| 核心原则 | 明确不能违反的规则,例如“默认部署到 preview,不直接上 production” |
| 执行流程 | 给出步骤、循环、阶段或决策树 |
| 命令和示例 | 减少模型自由发挥,降低执行偏差 |
| 故障处理 | 失败时提供替代路径 |
| 完成标准 | 告诉模型什么时候可以停止 |
一个 Skill 不一定越长越好。主文件应该承载高频、关键、必须遵守的内容;细节资料、长示例、产品说明可以放到 references/ 或 resources/ 里,让模型需要时再读取。
推荐的知识分层如下:
flowchart TD
A[Frontmatter<br/>约 100 tokens] --> B[SKILL.md 正文<br/>2K-5K tokens]
B --> C[references/<br/>详细文档,按需读取]
B --> D[resources/<br/>模板、清单、配置]
B --> E[examples/<br/>完整示例]
| 层级 | Token 预算 | 放什么内容 |
|---|---|---|
| Frontmatter | 约 100 tokens | name、description、少量扩展字段 |
| 主文件 | 2K-5K tokens | 核心流程、关键约束、常用命令 |
| 单个参考文档 | 1K-3K tokens | 详细解释、长示例、产品资料 |
| 单次加载总量 | 尽量小于 10K tokens | 主文件 + 少量参考文档 |
6 种常见 Skill 设计模式
不同 Skill 解决的问题不一样,结构也不应该一样。部署 Skill 适合写成步骤清单,TDD Skill 适合写成循环,产品发现 Skill 则更像阶段化工作流。
可以把工作流型 Skill 分成 6 种模式:
| 模式 | 适合场景 | 代表结构 |
|---|---|---|
| 线性流程 | 部署、安装、迁移、初始化 | 前置条件 → 步骤 → 降级 → 排错 |
| 决策树 + 按需加载 | 大平台选型、产品导航、问题诊断 | 意图分类 → 分支判断 → 参考文档 |
| 循环迭代 | TDD、代码审查、设计评审 | 做 → 验证 → 修正 → 重复 |
| 接力棒循环 | 跨会话长期任务、多 Agent 协作 | 读取状态文件 → 执行 → 写入下一棒 |
| 多阶段 + 检查点 | 多周项目、复杂研究流程 | 阶段活动 → 产出 → Go/No-Go |
| 思维框架 | 安全审计、架构分析、深度理解 | 分析原则 → 检查清单 → 反幻觉规则 |
模式 1:线性流程
线性流程适合“先做 A,再做 B,最后做 C”的任务,例如部署应用、安装环境、迁移配置、初始化项目。
典型结构:
# Vercel Deployment
## Prerequisites
- Confirm the project has a valid package manager configuration.
- Confirm the user wants a preview deployment unless production is explicitly requested.
## Quick Start
### Step 1: Install CLI
```bash
npm install -g vercel
Step 2: Link project
vercel link
Step 3: Deploy preview
vercel --yes
Fallback
If the CLI fails, use the provided deployment script.
Troubleshooting
| Issue | Fix |
|---|---|
| Missing token | Ask the user to provide a Vercel token |
| Build timeout | Re-run with a longer timeout |
线性流程 Skill 的重点不是“把步骤列出来”这么简单,而是要减少模型猜测空间。
| 技巧 | 写法 | 作用 |
|---|---|---|
| 安全默认值 | 默认 preview,不默认 production | 避免模型执行高风险操作 |
| 具体命令 | 每一步都给出可复制命令 | 模型不需要自己拼命令 |
| 超时设置 | 明确 `600000ms` 之类的时间 | 避免长任务被过早中断 |
| 降级方案 | CLI 失败时改用脚本或手动步骤 | 不让流程卡死 |
| 负面指令 | `Do not curl the deployed URL to verify` | 明确禁止无意义或危险操作 |
线性流程适合短小 Skill。一个优秀的部署 Skill 可以只有几十行,但必须覆盖成功路径、失败路径和安全边界。
### 模式 2:决策树 + 按需加载
当 Skill 面对的是一个大平台或复杂知识域,线性步骤就不够了。比如 Cloudflare 这类平台有 Workers、Pages、R2、D1、KV、Queues、AI Gateway 等多个产品,用户往往不会直接说产品名,而是说“我想跑一段后端代码”“我需要存文件”“我需要做边缘缓存”。
这类 Skill 应该先帮助模型识别用户意图,再导航到正确产品。
```mermaid
flowchart TD
A[用户需求] --> B{用户想做什么}
B --> C[运行代码]
B --> D[存储数据]
B --> E[处理 AI/ML]
B --> F[部署网站]
C --> C1[边缘函数: Workers]
C --> C2[容器或长期任务: Containers / Workflows]
D --> D1[对象文件: R2]
D --> D2[关系型数据: D1]
D --> D3[键值数据: KV]
E --> E1[模型调用网关: AI Gateway]
E --> E2[边缘推理: Workers AI]
F --> F1[静态站点: Pages]
F --> F2[全栈应用: Pages + Functions]
正文可以这样组织:
# Cloud Platform Navigator
## Authentication
Explain how to check login status and required credentials.
## Quick Decision Trees
### "I need to run code"
- Edge request handling → Workers
- Long-running workflows → Workflows
- Containerized services → Containers
### "I need to store data"
- Object storage → R2
- Relational database → D1
- Key-value access → KV
## Product Index
| Product | Use when | Reference |
|---|---|---|
| Workers | Edge compute | references/workers.md |
| R2 | Object storage | references/r2.md |
| D1 | SQL database | references/d1.md |
决策树 Skill 的关键是用“用户语言”而不是“产品分类语言”。
用户更可能说“我需要存图片”,而不是说“我需要对象存储”。Skill 应该把前者映射到后者。
| 技巧 | 说明 |
|---|---|
| 意图优先 | 用 "I need to store files" 这类表达组织分支 |
| 渐进披露 | 主文件只放导航,详细资料放 references/ |
| 产品索引 | 用表格建立产品、用途、参考文档的映射 |
| 拆分 Skill | 一个 Skill 做导航,另一个 Skill 做具体操作 |
对于大型平台,常见做法是拆成两个 Skill:
| 类型 | 职责 | 示例 |
|---|---|---|
| 导航型 Skill | 帮模型选对产品或方向 | “用户要存文件 → R2” |
| 操作型 Skill | 给出认证、命令、部署、排错步骤 | “用 Wrangler 部署 Worker” |
这样可以避免一个 Skill 同时承担“选型”和“执行”的全部负担。
模式 3:循环迭代
循环迭代适合需要反复“做、验证、修改”的任务,例如 TDD、代码审查、重构、设计评审。
TDD Skill 的核心不是告诉模型“写测试很重要”,而是强制它遵守 Red-Green-Refactor 循环:
flowchart LR
A[RED<br/>写一个失败测试] --> B[验证测试确实失败]
B --> C[GREEN<br/>写最少实现代码]
C --> D[验证测试通过]
D --> E[REFACTOR<br/>清理实现]
E --> F[再次运行测试]
F --> A
典型结构:
# Test-Driven Development
## The Iron Law
Never write implementation code before there is a failing test.
## Red-Green-Refactor
### RED — Write a failing test
Create the smallest test that captures the desired behavior.
### Verify RED
Run the test and confirm it fails for the expected reason.
### GREEN — Write minimal code
Implement only enough code to pass the test.
### Verify GREEN
Run the test suite and confirm the new test passes.
### REFACTOR
Clean up duplication and naming without changing behavior.
## Common Rationalizations
| Excuse | Reality |
|---|---|
| "This is too simple to test" | Simple code still needs executable behavior documentation |
| "I'll add tests after implementation" | That is not TDD |
## Completion Checklist
- [ ] Every behavior change started with a failing test
- [ ] The failing test failed for the expected reason
- [ ] All tests pass
- [ ] Refactoring did not change behavior
循环型 Skill 要特别注意模型“走捷径”的倾向。模型可能会直接写实现、跳过验证、把失败测试改成通过测试,或者用一句“这个场景不需要测试”合理化偏离流程。
降低这种偏差的办法有 4 种:
| 方法 | 写法 | 效果 |
|---|---|---|
| 强约束语气 | Delete it. Start over. | 阻止模型把违规步骤继续推进 |
| Good/Bad 对比 | 用好例子和坏例子并排展示 | 让模型更容易模仿正确模式 |
| 借口反驳表 | 列出常见偷懒理由及反驳 | 预先堵住偏离路径 |
| 退出清单 | 没满足 checklist 就不能结束 | 给循环设置明确完成条件 |
循环 Skill 的核心是“控制节奏”。它不只告诉模型要做什么,还要告诉模型每一步之后必须验证什么,以及验证失败时回到哪里。
模式 4:接力棒循环
普通循环依赖当前会话上下文。一旦会话结束,模型就可能忘记做到了哪一步。长期任务需要把状态写到外部文件中,这就是接力棒模式。
接力棒模式适合这些场景:
- 一个项目需要跨多个会话持续推进。
- 多个 Agent 需要协作完成任务。
- 每轮执行都要留下下一轮的输入。
- 任务持续时间从几天到几周。
核心思想是“文件即状态”。例如用 next-prompt.md 保存下一轮要做的事:
project/
├── roadmap.md # 总路线图
├── context.md # 项目上下文
├── decisions.md # 已做决策
├── outputs/ # 每轮产物
└── next-prompt.md # 下一轮接力棒
执行流程如下:
sequenceDiagram
participant Agent as 当前 Agent
participant FS as 文件系统
participant Next as 下一轮 Agent
Agent->>FS: 读取 next-prompt.md
Agent->>FS: 读取 context.md / roadmap.md
Agent->>Agent: 执行本轮任务
Agent->>FS: 写入产物和决策记录
Agent->>FS: 更新 roadmap.md
Agent->>FS: 生成新的 next-prompt.md
Next->>FS: 从新的 next-prompt.md 继续
典型正文结构:
# Stitch Loop
## Overview
This workflow uses files as persistent state between sessions.
## The Baton System
The baton file is `next-prompt.md`. It must contain:
- current objective
- relevant context files
- completed work
- next concrete action
- stopping condition
## Execution Protocol
### Step 1: Read the Baton
Read `next-prompt.md` before doing any work.
### Step 2: Consult Context Files
Read the referenced files only when needed.
### Step 3: Generate
Complete the current unit of work.
### Step 4: Integrate
Write outputs into the expected project files.
### Step 5: Update Documentation
Record decisions and remaining tasks.
### Step 6: Prepare the Next Baton
This step is mandatory. Create or update `next-prompt.md` so another session can continue.
接力棒模式和普通循环的差异很大:
| 维度 | 循环迭代 | 接力棒循环 |
|---|---|---|
| 状态存储位置 | 当前对话上下文 | 外部文件系统 |
| 是否跨会话 | 不适合 | 适合 |
| 结束条件 | checklist 全部满足 | 路线图任务清空或人工停止 |
| 典型时长 | 分钟到小时 | 天到周 |
| 关键风险 | 模型跳过验证 | 模型忘记写下一棒 |
接力棒 Skill 最重要的指令是“必须写下一棒”。如果最后没有更新 next-prompt.md,循环就断了。这个要求应该用明显的语气写在正文里,而不是藏在普通步骤中。
模式 5:多阶段 + 检查点
有些工作流不是循环执行一个小动作,而是跨越多个阶段,每个阶段都有不同活动、不同产物和不同决策点。产品发现、用户研究、复杂架构评审、迁移方案设计都属于这种类型。
这类 Skill 可以使用统一阶段模板:
## Phase 1: Frame the Problem
### Activities
- Run stakeholder interview
- Collect existing assumptions
- Define decision constraints
### Outputs
- Problem statement
- Known assumptions
- Open questions
### Decision Point 1
Question: Is the problem specific enough?
- YES → Move to Phase 2
- NO → Spend 2-3 more days refining the problem
完整流程通常是这样:
flowchart TD
A[Phase 1<br/>界定问题] --> B{问题是否足够清楚}
B -- YES --> C[Phase 2<br/>收集证据]
B -- NO<br/>+2-3 days --> A
C --> D{证据是否达到饱和}
D -- YES --> E[Phase 3<br/>综合洞察]
D -- NO<br/>+1 week --> C
E --> F{是否值得推进}
F -- YES --> G[Phase 4<br/>方案设计]
F -- NO --> H[停止或重新定义方向]
G --> I[Phase 5<br/>验证方案]
I --> J{验证是否通过}
J -- YES --> K[Phase 6<br/>交付与交接]
J -- NO<br/>+1-2 weeks --> G
多阶段 Skill 的关键不是“阶段多”,而是每个阶段都必须有清晰的 Go/No-Go 决策。
| 技巧 | 说明 |
|---|---|
| 统一模板 | 每个阶段都写 Activities、Outputs、Decision Point |
| 决策条件 | 明确什么情况下继续,什么情况下停下 |
| 时间影响 | NO 路径写清会增加几天或几周 |
| Skill 编排 | 大 Skill 负责流程,小 Skill 负责访谈、分析、工作坊等具体活动 |
| 交互协议分离 | 把会议引导、访谈提问等独立成子 Skill |
这种模式适合作为“编排器 Skill”。它本身不一定写完所有细节,而是调度多个子 Skill 完成不同阶段。
例如:
## Phase 2: User Research
### Activities
Use these skills:
- `interview-planning`
- `research-synthesis`
- `persona-mapping`
### Outputs
- Interview guide
- Research notes
- Pattern summary
- Evidence table
这样可以避免一个巨大的 Skill 变成不可维护的长文档。
模式 6:思维框架
前面几种模式主要控制“怎么做”,思维框架模式控制的是“怎么想”。它适合安全审计、代码理解、架构分析、复杂故障定位等场景。
这类 Skill 不一定要求模型立刻修改代码,甚至会明确禁止模型过早下结论。它要求模型先建立上下文、逐层分析证据,再输出结构化理解。
典型结构:
# Audit Context Building
## Purpose
Build deep understanding before identifying vulnerabilities or proposing fixes.
## When to Use
Use for security review, complex codebase orientation, and high-risk reasoning tasks.
## When NOT to Use
Do not use for quick syntax fixes or simple refactors.
## Phase 1: Initial Orientation
Map the repository structure, entry points, data flows, and trust boundaries.
## Phase 2: Ultra-Granular Function Analysis
For each important function, identify:
- invariants
- assumptions
- inputs
- outputs
- side effects
- failure modes
## Phase 3: Global System Understanding
Connect function-level behavior into system-level flows.
## Stability Rules
Never reshape evidence to match an earlier assumption.
## Non-Goals
Do not report vulnerabilities before context building is complete.
Do not propose fixes during the analysis phase.
思维框架 Skill 里常见的技巧包括:
| 技巧 | 写法 | 作用 |
|---|---|---|
| 思维工具 | 第一性原理、5 Why、5 How | 给模型分析路径 |
| 量化阈值 | 每个函数至少列出 3 个不变量、5 个假设 | 避免浅层分析 |
| 非目标约束 | 不要识别漏洞,不要提出修复 | 阻止模型过早跳到结论 |
| 反幻觉规则 | 不允许改写证据来适配猜测 | 降低自洽但错误的推理 |
| 子 Agent 指导 | 指定何时调用函数分析 Agent | 把复杂分析拆小 |
思维框架 Skill 的完成标准不应该是“给出答案”,而应该是“证据是否充分、分析是否覆盖关键路径、结论是否可追溯”。
模式选择决策树
选择 Skill 结构时,可以先判断任务的形态:
flowchart TD
A[Skill 主要解决什么问题] --> B{是否是明确步骤操作}
B -- 是 --> B1[线性流程]
B -- 否 --> C{是否需要在大量选项中导航}
C -- 是 --> C1[决策树 + 按需加载]
C -- 否 --> D{是否在单次会话内反复做验证}
D -- 是 --> D1[循环迭代]
D -- 否 --> E{是否需要跨会话保存状态}
E -- 是 --> E1[接力棒循环]
E -- 否 --> F{是否跨多天或多周并有阶段决策}
F -- 是 --> F1[多阶段 + 检查点]
F -- 否 --> G{是否主要控制分析深度}
G -- 是 --> G1[思维框架]
G -- 否 --> H[从最小线性 Skill 开始]
简单判断规则:
| 任务描述 | 推荐模式 |
|---|---|
| “把应用部署到某个平台” | 线性流程 |
| “用户可能选择很多产品,需要先判断方向” | 决策树 + 按需加载 |
| “必须一轮一轮验证质量” | 循环迭代 |
| “今天做一部分,明天接着做” | 接力棒循环 |
| “项目有阶段、产物、决策门” | 多阶段 + 检查点 |
| “不能急着执行,需要先深入理解” | 思维框架 |
通用写作技巧
1. 用约束减少模型走捷径
模型很容易为了完成任务而省略中间步骤。Skill 里必须把关键约束写成明确规则。
| 方法 | 示例 |
|---|---|
| 强硬语气 | If you wrote implementation before a failing test, delete it and start over. |
| 借口反驳表 | "This is too small to test" → Small behavior still needs a test. |
| 量化阈值 | List at least 3 invariants and 5 assumptions for each critical function. |
| 负面指令 | Do not deploy to production unless the user explicitly requests it. |
“请尽量”这类表达通常太弱。对不能违反的规则,应该直接写成 MUST、NEVER、Do not。
2. 用示例教模型,而不是只写抽象原则
模型更擅长模仿具体结构。与其写“输出要清晰”,不如给出完整格式。
## Output Format
Return the analysis using this structure:
### Summary
One paragraph explaining the key behavior.
### Evidence
| Claim | Evidence | File |
|---|---|---|
### Open Questions
- Question 1
- Question 2
Good/Bad 对比也很有效:
<Bad>
Write all implementation code first, then add a broad test later.
</Bad>
<Good>
Write one failing test for the smallest behavior, confirm it fails, then implement only enough code to pass.
</Good>
3. 默认选择安全路径
如果 Skill 会操作真实系统,安全默认值必须写在靠前位置。
| 场景 | 安全默认值 |
|---|---|
| 部署 | 默认 preview,不默认 production |
| 数据库迁移 | 默认 dry-run,不默认执行写操作 |
| 文件删除 | 默认列出将删除内容,等待确认 |
| 权限升级 | 默认不提权,除非用户明确同意 |
| 不确定判断 | 暂停并向用户确认 |
例如部署 Skill 可以写:
## Safety Defaults
- Always create a preview deployment unless the user explicitly asks for production.
- Never delete remote resources without confirmation.
- Do not expose secrets in logs.
- If credentials are missing, ask the user instead of inventing values.
4. 把长资料放到 references
主文件过长会浪费上下文,也会让模型抓不住重点。复杂 Skill 应该采用“主文件导航 + 参考资料按需读取”的结构。
cloudflare-skill/
├── SKILL.md
└── references/
├── workers.md
├── pages.md
├── r2.md
├── d1.md
└── troubleshooting.md
SKILL.md 里只放索引:
## Product References
| Product | Use when | File |
|---|---|---|
| Workers | Running code at the edge | references/workers.md |
| Pages | Deploying static or full-stack web apps | references/pages.md |
| R2 | Storing objects and files | references/r2.md |
| D1 | Using SQL at the edge | references/d1.md |
这样模型先用少量上下文选方向,只有真正需要时才读取细节。
最小可用模板
线性流程 Skill 模板
---
name: my-linear-skill
description: Use when the user wants to [完成某类任务]. Trigger for phrases like "[用户可能说法 1]", "[用户可能说法 2]". Default to the safest option unless the user explicitly requests otherwise.
---
# My Linear Skill
## Core Rule
State the non-negotiable rule here. For example: always run in preview mode before production.
## Prerequisites
- Confirm [前置条件 1].
- Confirm [前置条件 2].
- If [缺少必要信息], ask the user before continuing.
## Steps
### Step 1: [动作名称]
```bash
[可直接执行的命令]
Expected result: [预期结果].
Step 2: [动作名称]
[可直接执行的命令]
Expected result: [预期结果].
Step 3: [动作名称]
[具体说明。]
Fallback
If [主路径失败], use [替代方案].
Troubleshooting
| Issue | Cause | Fix |
|---|---|---|
| [问题 1] | [原因] | [解决办法] |
| [问题 2] | [原因] | [解决办法] |
Completion Checklist
- [完成条件 1]
- [完成条件 2]
- [安全检查]
### 循环迭代 Skill 模板
```markdown
---
name: my-loop-skill
description: Use when the user needs an iterative workflow for [任务类型]. Use before [关键时机], and continue until the completion checklist is satisfied.
---
# My Loop Skill
## Core Principle
[不可违反的核心原则。]
## The Loop
### Phase A — [动作]
[具体指令。]
### Verify A
```bash
[验证命令]
If verification fails, fix the issue before moving on.
Phase B — [动作]
[具体指令。]
Verify B
[验证命令]
Refine
[清理、改进、重构或复查要求。]
Repeat
Return to Phase A until the completion checklist is satisfied.
Rationalizations
| Excuse | Reality |
|---|---|
| "[常见借口 1]" | [反驳] |
| "[常见借口 2]" | [反驳] |
Completion Checklist
- [条件 1]
- [条件 2]
- [条件 3]
### 接力棒 Skill 模板
```markdown
---
name: my-baton-skill
description: Use for long-running work that must continue across sessions or agents. Use when the user asks to continue a project, resume work, or coordinate multiple iterations over time.
---
# My Baton Skill
## Core Rule
The baton file is the source of truth. Always read it before work and always update it before stopping.
## File Protocol
| File | Purpose |
|---|---|
| `next-prompt.md` | Current baton and next action |
| `context.md` | Stable project context |
| `roadmap.md` | Remaining work |
| `decisions.md` | Decisions already made |
| `outputs/` | Generated artifacts |
## Execution Protocol
### Step 1: Read the Baton
Read `next-prompt.md`.
### Step 2: Read Context
Read only the context files referenced by the baton.
### Step 3: Execute
Complete the current unit of work.
### Step 4: Integrate
Write outputs to the expected files.
### Step 5: Update Documentation
Update `roadmap.md` and `decisions.md`.
### Step 6: Prepare the Next Baton
This step is mandatory. Update `next-prompt.md` with:
- current state
- completed work
- next task
- required context files
- stopping condition
7 个代表性 Skill 速查
| # | Skill | 来源仓库 | 模式 | 特点 |
|---|---|---|---|---|
| 1 | vercel-deploy | openai/skills | 线性流程 | 用较短内容覆盖部署、降级和排错 |
| 2 | cloudflare-deploy | openai/skills | 线性 + 决策树 | 大平台操作 Skill,兼顾认证、部署和产品选择 |
| 3 | cloudflare | opencode 相关 Skill | 决策树 | 更偏导航,帮助模型选产品和查资料 |
| 4 | test-driven-development | obra/superpowers | 循环迭代 | 用强约束、借口反驳和 checklist 固化 TDD 节奏 |
| 5 | stitch-loop | google-labs-code/stitch-skills | 接力棒循环 | 用文件保存状态,支持跨会话继续 |
| 6 | discovery-process | deanpeters/Product-Manager-Skills | 多阶段 + 检查点 | 大 Skill 编排多个子 Skill,适合产品发现流程 |
| 7 | audit-context-building | trailofbits/skills | 思维框架 | 控制模型分析方式,强调证据、深度和反幻觉 |
参考资源
规范与模板
- Agent Skills 开放标准:https://agentskills.io/
- Anthropic Skills 模板:https://github.com/anthropics/skills/tree/main/template
- Anthropic Skills 规范:https://github.com/anthropics/skills/tree/main/spec
Skill 仓库
- OpenAI Skills:https://github.com/openai/skills
- Obra Superpowers:https://github.com/obra/superpowers
- Google Labs Stitch Skills:https://github.com/google-labs-code/stitch-skills
- Dean Peters Product Manager Skills:https://github.com/deanpeters/Product-Manager-Skills
- Trail of Bits Skills:https://github.com/trailofbits/skills
- OpenClaw ClawHub:https://github.com/openclaw/clawhub
精选索引
- Awesome Agent Skills:https://github.com/VoltAgent/awesome-agent-skills
- Awesome Claude Skills:https://github.com/travisvn/awesome-claude-skills
编写 Skill 前的检查清单
真正落地前,可以用这份清单检查:
-
description是否写出了触发短语,而不是泛泛描述功能? - 是否说明了使用时机,例如“写代码前”“部署前”“审计前”?
- 是否有安全默认值?
- 是否明确写出禁止事项?
- 每个关键步骤是否有命令、示例或输出格式?
- 失败时是否有 fallback?
- 是否有完成 checklist?
- 主文件是否过长,长资料是否拆到
references/? - 如果任务跨会话,是否把状态写入文件?
- 如果任务需要深度分析,是否写了反幻觉规则和量化标准?
Skill 的质量取决于结构清不清楚、触发条件准不准、约束够不够硬。把它当成一份给模型执行的工程手册来写,比把它当成普通提示词更容易得到稳定结果。