write-skill
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWrite Skill
编写 Skill
Overview
概述
Writing skills IS Test-Driven Development applied to process documentation.
Personal skills live in agent-specific directories ( for Claude Code, for Codex)
~/.claude/skills~/.agents/skills/You write test cases (pressure scenarios with subagents), watch them fail (baseline behavior), write the skill (documentation), watch tests pass (agents comply), and refactor (close loopholes).
Core principle: If you didn't watch an agent fail without the skill, you don't know if the skill teaches the right thing.
REQUIRED BACKGROUND: You MUST understand agent-skills:test-driven-development before using this skill. That skill defines the fundamental RED-GREEN-REFACTOR cycle. This skill adapts TDD to documentation.
Skills with executable code: see , a summary of Anthropic's skill authoring best practices with a link to the full page.
executable-code-skills.md编写 Skill 本质上就是将测试驱动开发(TDD)应用于流程文档。
个人 Skill 位于特定 Agent 的目录中(Claude Code 使用 ,Codex 使用 )
~/.claude/skills~/.agents/skills/你先编写测试用例(使用 subagent 的压力场景),观察测试失败(基线行为),然后编写 Skill(文档),观察测试通过(Agent 遵守规则),最后重构(堵住漏洞)。
核心原则: 如果你没有亲眼看到 Agent 在没有 Skill 时失败,就无法确定该 Skill 是否教会了正确的行为。
必需背景: 使用本 Skill 前,你必须理解 。该 Skill 定义了基本的 RED-GREEN-REFACTOR 循环。本 Skill 将 TDD 适配到文档中。
agent-skills:test-driven-development包含可执行代码的 Skill: 参阅 ,其中汇总了 Anthropic 的 Skill 编写最佳实践,并附有完整页面的链接。
executable-code-skills.mdWhat is a Skill?
什么是 Skill?
A skill is a reference guide for proven techniques, patterns, or tools. Skills help future Claude instances find and apply effective approaches.
Skills are: Reusable techniques, patterns, tools, reference guides
Skills are NOT: Narratives about how you solved a problem once
Skill 是经过验证的技巧、模式或工具的参考指南。Skill 帮助未来的 Claude 实例找到并应用有效的方法。
Skill 是: 可复用的技巧、模式、工具和参考指南
Skill 不是: 描述你如何一次性解决某个问题的叙事
TDD Mapping for Skills
Skill 的 TDD 映射
| TDD Concept | Skill Creation |
|---|---|
| Test case | Pressure scenario with subagent |
| Production code | Skill document (SKILL.md) |
| Test fails (RED) | Agent violates rule without skill (baseline) |
| Test passes (GREEN) | Agent complies with skill present |
| Refactor | Close loopholes while maintaining compliance |
| Write test first | Run baseline scenario BEFORE writing skill |
| Watch it fail | Document exact rationalizations agent uses |
| Minimal code | Write skill addressing those specific violations |
| Watch it pass | Verify agent now complies |
| Refactor cycle | Find new rationalizations → plug → re-verify |
The entire skill creation process follows RED-GREEN-REFACTOR.
| TDD 概念 | Skill 创建 |
|---|---|
| 测试用例 | 使用 subagent 的压力场景 |
| 生产代码 | Skill 文档(SKILL.md) |
| 测试失败(RED) | 没有 Skill 时 Agent 违反规则(基线) |
| 测试通过(GREEN) | 存在 Skill 时 Agent 遵守规则 |
| 重构 | 在保持合规的同时堵住漏洞 |
| 先写测试 | 在编写 Skill 之前运行基线场景 |
| 观察测试失败 | 记录 Agent 使用的确切合理化辩解 |
| 最小代码 | 编写 Skill 以解决这些具体违规 |
| 观察测试通过 | 验证 Agent 现在能够遵守规则 |
| 重构循环 | 找出新的合理化辩解 → 封堵 → 重新验证 |
整个 Skill 创建过程都遵循 RED-GREEN-REFACTOR。
When to Create a Skill
何时创建 Skill
Create when:
- Technique wasn't intuitively obvious to you
- You'd reference this again across projects
- Pattern applies broadly (not project-specific)
- Others would benefit
Don't create for:
- One-off solutions
- Standard practices well-documented elsewhere
- Project-specific conventions (put in CLAUDE.md)
- Mechanical constraints (if it's enforceable with regex/validation, automate it—save documentation for judgment calls)
应在以下情况下创建:
- 该技巧并非你凭直觉就知道
- 你会在多个项目中再次引用它
- 该模式适用广泛(并非项目专用)
- 其他人也能从中受益
不要为以下内容创建:
- 一次性解决方案
- 其他地方已有充分文档的标准实践
- 项目专用约定(放入 CLAUDE.md)
- 机械性约束(如果可以使用 regex/validation 强制执行,就将其自动化——文档应只保留需要判断的事项)
Skill Types
Skill 类型
Technique
技巧
Concrete method with steps to follow (find-cause, verify-sources)
一种包含待遵循步骤的具体方法(查找根因、验证来源)
Pattern
模式
Way of thinking about problems (flatten-with-flags, test-invariants)
一种思考问题的方式(flatten-with-flags、测试不变量)
Reference
参考
API docs, syntax guides, tool documentation (office docs)
API 文档、语法指南、工具文档(office 文档)
Directory Structure
目录结构
skills/
skill-name/
SKILL.md # Main reference (required)
supporting-file.* # Only if neededFlat namespace - all skills in one searchable namespace
Separate files for:
- Heavy reference (100+ lines) - API docs, comprehensive syntax
- Reusable tools - Scripts, utilities, templates
Keep inline:
- Principles and concepts
- Code patterns (< 50 lines)
- Everything else
skills/
skill-name/
SKILL.md # Main reference (required)
supporting-file.* # Only if needed扁平命名空间——所有 Skill 都位于同一个可搜索的命名空间中
以下内容应拆分为单独文件:
- 重型参考资料(100+ 行)——API 文档、完整语法
- 可复用工具——脚本、实用工具、模板
以下内容应保留在正文中:
- 原则和概念
- 代码模式(少于 50 行)
- 其他所有内容
SKILL.md Structure
SKILL.md 结构
Frontmatter (YAML):
- Two required fields: and
name(see agentskills.io/specification for all supported fields)description - : required,
version, top-level field (not nested underMajor.Minor.patch). New skill starts atmetadata. Bump Patch for clarifications/typos, Minor for added sections/rules that don't break existing usage, Major for structural/behavioral changes that invalidate prior usage.1.0.0 - Max 1024 characters total
- : Use letters, numbers, and hyphens only (no parentheses, special chars)
name - : Third-person, describes ONLY when to use (NOT what it does)
description- Start with "Use when..." to focus on triggering conditions
- Include specific symptoms, situations, and contexts
- NEVER summarize the skill's process or workflow (see for why)
cso-guide.md - Keep under 500 characters if possible
markdown
---
name: Skill-Name-With-Hyphens
description: Use when [specific triggering conditions and symptoms]
---前置元数据(YAML):
- 必需字段:和
name(所有支持的字段见 agentskills.io/specification)description - :必需,使用
version格式,属于顶层字段(不能嵌套在Major.Minor.patch下)。新 Skill 从metadata开始。澄清说明或修正拼写时增加 Patch,新增不破坏现有用法的章节或规则时增加 Minor,发生结构性或行为变更并使原有用法失效时增加 Major。1.0.0 - 总计最多 1024 个字符
- :仅使用字母、数字和连字符(不能使用括号或特殊字符)
name - :使用第三人称,只描述何时使用(不要描述它做什么)
description- 以“Use when...”开头,以聚焦触发条件
- 包含具体的症状、情境和上下文
- 绝不总结 Skill 的流程或工作流(原因见 )
cso-guide.md - 尽可能控制在 500 个字符以内
markdown
---
name: Skill-Name-With-Hyphens
description: Use when [specific triggering conditions and symptoms]
---Skill Name
Skill Name
Overview
Overview
What is this? Core principle in 1-2 sentences.
What is this? Core principle in 1-2 sentences.
When to Use
When to Use
[Small inline flowchart IF decision non-obvious]
Bullet list with SYMPTOMS and use cases
When NOT to use
[Small inline flowchart IF decision non-obvious]
Bullet list with SYMPTOMS and use cases
When NOT to use
Core Pattern (for techniques/patterns)
Core Pattern (for techniques/patterns)
Before/after code comparison
Before/after code comparison
Quick Reference
Quick Reference
Table or bullets for scanning common operations
Table or bullets for scanning common operations
Implementation
Implementation
Inline code for simple patterns
Link to file for heavy reference or reusable tools
Inline code for simple patterns
Link to file for heavy reference or reusable tools
Common Mistakes
Common Mistakes
What goes wrong + fixes
What goes wrong + fixes
Real-World Impact (optional)
Real-World Impact (optional)
Concrete results
undefinedConcrete results
undefinedClaude Search Optimization (CSO)
Claude 搜索优化(CSO)
Critical for discovery: Future Claude needs to FIND your skill before it can use it.
Description rules (summary):
- Start with "Use when..." — describes the TRIGGER, not what the skill does
- Never summarize the workflow or process in the description
- Use concrete symptoms and situations, not abstract categories
- Technology-agnostic unless the skill itself is tech-specific
Cross-references: Use backticks only — never -syntax (force-loads, burns context).
@Naming: Verb-noun, e.g. , , . Not a vague category
(, ).
write-skillguide-decisionfind-causeskill-utilshelpersKeyword coverage: Include error messages, symptoms, tool names so Claude can find the skill.
Token efficiency: getting-started: <150 words. Frequently-loaded: <200 words total.
→ See for the full description-field guide with examples, anti-patterns,
token efficiency techniques, and the "workflow summary trap" explanation.
cso-guide.md对发现能力至关重要: 未来的 Claude 必须先找到你的 Skill,才能使用它。
Description 规则(摘要):
- 以“Use when...”开头——描述触发条件,而不是 Skill 的作用
- 绝不总结工作流或流程
- 使用具体的症状和情境,而不是抽象类别
- 除非 Skill 本身专用于某项技术,否则保持技术无关
交叉引用: 仅使用反引号——绝不要使用 语法(它会强制加载并浪费上下文)。
@命名: 使用“动词-名词”形式,例如 、、。不要使用模糊的类别名(、)。
write-skillguide-decisionfind-causeskill-utilshelpers关键词覆盖: 包含错误消息、症状和工具名称,让 Claude 能够找到该 Skill。
Token 效率: getting-started:少于 150 词;frequently-loaded:总计少于 200 词。
→ 参阅 ,了解完整的 description 字段指南,其中包含示例、反模式、Token 效率技巧以及“工作流摘要陷阱”的详细说明。
cso-guide.mdFlowchart Usage
流程图的使用
dot
digraph when_flowchart {
"Need to show information?" [shape=diamond];
"Decision where I might go wrong?" [shape=diamond];
"Use markdown" [shape=box];
"Small inline flowchart" [shape=box];
"Need to show information?" -> "Decision where I might go wrong?" [label="yes"];
"Decision where I might go wrong?" -> "Small inline flowchart" [label="yes"];
"Decision where I might go wrong?" -> "Use markdown" [label="no"];
}Use flowcharts ONLY for:
- Non-obvious decision points
- Process loops where you might stop too early
- "When to use A vs B" decisions
Never use flowcharts for:
- Reference material → Tables, lists
- Code examples → Markdown blocks
- Linear instructions → Numbered lists
- Labels without semantic meaning (step1, helper2)
See for graphviz style rules.
graphviz-conventions.dotVisualizing for your human partner: Use in this directory to render a skill's flowcharts to SVG:
render-graphs.jsbash
./render-graphs.js ../some-skill # Each diagram separately
./render-graphs.js ../some-skill --combine # All diagrams in one SVGdot
digraph when_flowchart {
"Need to show information?" [shape=diamond];
"Decision where I might go wrong?" [shape=diamond];
"Use markdown" [shape=box];
"Small inline flowchart" [shape=box];
"Need to show information?" -> "Decision where I might go wrong?" [label="yes"];
"Decision where I might go wrong?" -> "Small inline flowchart" [label="yes"];
"Decision where I might go wrong?" -> "Use markdown" [label="no"];
}仅在以下情况使用流程图:
- 决策点不明显
- 可能过早停止的流程循环
- “何时使用 A 还是 B”的决策
绝不用于:
- 参考资料 → 表格、列表
- 代码示例 → Markdown 代码块
- 线性说明 → 编号列表
- 没有语义含义的标签(step1、helper2)
Graphviz 样式规则见 。
graphviz-conventions.dot为你的协作伙伴可视化: 使用本目录中的 将 Skill 的流程图渲染为 SVG:
render-graphs.jsbash
./render-graphs.js ../some-skill # Each diagram separately
./render-graphs.js ../some-skill --combine # All diagrams in one SVGCode Examples
代码示例
One excellent example beats many mediocre ones
Choose most relevant language:
- Testing techniques → TypeScript/JavaScript
- System debugging → Shell/Python
- Data processing → Python
Good example:
- Complete and runnable
- Well-commented explaining WHY
- From real scenario
- Shows pattern clearly
- Ready to adapt (not generic template)
Don't:
- Implement in 5+ languages
- Create fill-in-the-blank templates
- Write contrived examples
You're good at porting - one great example is enough.
For skills that include executable scripts, see .
executable-code-skills.md一个优秀示例胜过许多平庸示例
选择最相关的语言:
- 测试技术 → TypeScript/JavaScript
- 系统调试 → Shell/Python
- 数据处理 → Python
优质示例:
- 完整且可运行
- 注释充分,解释了原因
- 来自真实场景
- 清晰展示模式
- 可以直接调整(而非通用模板)
不要:
- 使用 5 种以上语言实现
- 创建需要填空的模板
- 编写牵强的示例
你很擅长移植——一个优秀示例就够了。
对于包含可执行脚本的 Skill,请参阅 。
executable-code-skills.mdFile Organization
文件组织
Self-Contained Skill
自包含 Skill
defense-in-depth/
SKILL.md # Everything inlineWhen: All content fits, no heavy reference needed
defense-in-depth/
SKILL.md # Everything inline适用场景:所有内容都能容纳在正文中,无需重型参考资料
Skill with Reusable Tool
包含可复用工具的 Skill
retry-with-backoff/
SKILL.md # Overview + patterns
example.ts # Working helpers to adaptWhen: Tool is reusable code, not just narrative
retry-with-backoff/
SKILL.md # Overview + patterns
example.ts # Working helpers to adapt适用场景:工具是可复用代码,而不只是叙述
Skill with Heavy Reference
包含重型参考资料的 Skill
pptx/
SKILL.md # Overview + workflows
pptxgenjs.md # 600 lines API reference
ooxml.md # 500 lines XML structure
scripts/ # Executable toolsWhen: Reference material too large for inline
pptx/
SKILL.md # Overview + workflows
pptxgenjs.md # 600 lines API reference
ooxml.md # 500 lines XML structure
scripts/ # Executable tools适用场景:参考资料过大,无法放在正文中
The Iron Law (Same as TDD)
铁律(与 TDD 相同)
NO SKILL WITHOUT A FAILING TEST FIRSTThis applies to NEW skills AND EDITS to existing skills.
Write skill before testing? Delete it. Start over.
Edit skill without testing? Same violation.
No exceptions:
- Not for "simple additions"
- Not for "just adding a section"
- Not for "documentation updates"
- Don't keep untested changes as "reference"
- Don't "adapt" while running tests
- Delete means delete
REQUIRED BACKGROUND: The agent-skills:test-driven-development skill explains why this matters. Same principles apply to documentation.
NO SKILL WITHOUT A FAILING TEST FIRST这同时适用于新 Skill 和对现有 Skill 的编辑。
先写 Skill 再测试?删除它,重新开始。
未经测试就编辑 Skill?同样违规。
没有例外:
- “简单添加”也不例外
- “只是添加一个章节”也不例外
- “文档更新”也不例外
- 不要把未经测试的更改保留为“参考资料”
- 不要在运行测试时进行“调整”
- 删除就意味着彻底删除
必需背景: Skill 解释了为什么这一点很重要。相同的原则也适用于文档。
agent-skills:test-driven-developmentTesting All Skill Types
测试所有类型的 Skill
Different skill types need different test approaches:
不同类型的 Skill 需要采用不同的测试方法:
Discipline-Enforcing Skills (rules/requirements)
纪律约束型 Skill(规则/要求)
Examples: TDD, verification-before-completion, designing-before-coding
Test with:
- Academic questions: Do they understand the rules?
- Pressure scenarios: Do they comply under stress?
- Multiple pressures combined: time + sunk cost + exhaustion
- Identify rationalizations and add explicit counters
Success criteria: Agent follows rule under maximum pressure
→ See for the full pressure-testing methodology
(RED-GREEN-REFACTOR, pressure types, rationalization tables, meta-testing).
testing-skills-with-subagents.md示例: TDD、完成前验证、先设计后编码
测试方式:
- 学术问题:Agent 是否理解规则?
- 压力场景:Agent 在压力下是否遵守?
- 组合多种压力:时间 + 沉没成本 + 疲劳
- 找出合理化辩解并添加明确反驳
成功标准: Agent 在最大压力下仍遵守规则
→ 参阅 ,了解完整的压力测试方法,包括 RED-GREEN-REFACTOR、压力类型、合理化辩解表和元测试。
testing-skills-with-subagents.mdTechnique / Pattern / Reference Skills
技巧 / 模式 / 参考 Skill
For skills that improve output quality rather than enforce compliance, use empirical A/B
testing instead of pressure scenarios:
→ See for the full evaluation methodology
(quality A/B benchmark, blind comparison, trigger-description optimization).
evaluating-skills-with-subagents.mdThe sub-sections below describe what each skill type needs; the measurement approach is in
that document.
对于旨在提升输出质量而非强制遵守规则的 Skill,应采用经验性 A/B 测试,而不是压力场景:
→ 参阅 ,了解完整的评估方法,包括质量 A/B 基准测试、盲测比较和触发描述优化。
evaluating-skills-with-subagents.md以下各节介绍每种 Skill 类型需要测试的内容;具体测量方法见上述文档。
Technique Skills (how-to guides)
技巧型 Skill(操作指南)
Examples: find-cause, verify-sources, prevent-drift
Test with:
- Application scenarios: Can they apply the technique correctly?
- Variation scenarios: Do they handle edge cases?
- Missing information tests: Do instructions have gaps?
Success criteria: Agent successfully applies technique to new scenario
示例: find-cause、verify-sources、prevent-drift
测试方式:
- 应用场景:Agent 能否正确应用该技巧?
- 变化场景:Agent 能否处理边缘情况?
- 信息缺失测试:说明中是否存在缺口?
成功标准: Agent 能在新场景中成功应用该技巧
Pattern Skills (mental models)
模式型 Skill(心智模型)
Examples: reducing-complexity, information-hiding concepts
Test with:
- Recognition scenarios: Do they recognize when pattern applies?
- Application scenarios: Can they use the mental model?
- Counter-examples: Do they know when NOT to apply?
Success criteria: Agent correctly identifies when/how to apply pattern
示例: reducing-complexity、information-hiding 概念
测试方式:
- 识别场景:Agent 能否识别模式的适用时机?
- 应用场景:Agent 能否使用该心智模型?
- 反例:Agent 是否知道何时不应使用该模式?
成功标准: Agent 能正确识别并应用该模式
Reference Skills (documentation/APIs)
参考型 Skill(文档/API)
Examples: API documentation, command references, library guides
Test with:
- Retrieval scenarios: Can they find the right information?
- Application scenarios: Can they use what they found correctly?
- Gap testing: Are common use cases covered?
Success criteria: Agent finds and correctly applies reference information
示例: API 文档、命令参考、库指南
测试方式:
- 检索场景:Agent 能否找到正确的信息?
- 应用场景:Agent 能否正确使用找到的信息?
- 缺口测试:是否覆盖了常见用例?
成功标准: Agent 能找到并正确应用参考信息
Common Rationalizations for Skipping Testing
跳过测试的常见合理化辩解
| Excuse | Reality |
|---|---|
| "Skill is obviously clear" | Clear to you ≠ clear to other agents. Test it. |
| "It's just a reference" | References can have gaps, unclear sections. Test retrieval. |
| "Testing is overkill" | Untested skills have issues. Always. 15 min testing saves hours. |
| "I'll test if problems emerge" | Problems = agents can't use skill. Test BEFORE deploying. |
| "Too tedious to test" | Testing is less tedious than debugging bad skill in production. |
| "I'm confident it's good" | Overconfidence guarantees issues. Test anyway. |
| "Academic review is enough" | Reading ≠ using. Test application scenarios. |
| "No time to test" | Deploying untested skill wastes more time fixing it later. |
All of these mean: Test before deploying. No exceptions.
| 借口 | 现实情况 |
|---|---|
| “Skill 显然很清楚” | 你觉得清楚 ≠ 其他 Agent 也清楚。测试它。 |
| “这只是一份参考资料” | 参考资料可能存在缺口或不清楚的部分。测试检索能力。 |
| “测试是过度设计” | 未经测试的 Skill 总会有问题。15 分钟的测试可以节省数小时。 |
| “等出现问题时我再测试” | 出现问题 = Agent 无法使用 Skill。部署前就测试。 |
| “测试太繁琐” | 测试远不如在生产环境中调试糟糕的 Skill 繁琐。 |
| “我有信心它没问题” | 过度自信必然带来问题。仍然要测试。 |
| “学术审查已经足够” | 阅读 ≠ 使用。测试应用场景。 |
| “没有时间测试” | 部署未测试的 Skill 只会浪费更多时间在后续修复上。 |
所有这些借口都意味着:部署前测试。没有例外。
Bulletproofing & RED-GREEN-REFACTOR
强化 Skill 与 RED-GREEN-REFACTOR
Skills that enforce discipline need to resist rationalization. Agents are smart
and will find loopholes when under pressure.
Key techniques (summary):
- Close every loophole explicitly — forbid the specific workaround, not just the general rule
- Add a rationalization table: capture every excuse agents make → counter each one
- Add a "Red Flags — STOP" list for self-checking
- Address "spirit vs letter" arguments: add "Violating the letter IS violating the spirit"
RED: Run pressure scenario WITHOUT skill → document exact rationalizations verbatim.
GREEN: Write skill addressing those specific rationalizations → verify compliance.
REFACTOR: New rationalization found → add counter → re-test until bulletproof.
→ See for the complete methodology:
pressure scenario templates, all pressure types (time/sunk-cost/authority/exhaustion),
plugging holes systematically, meta-testing techniques, and worked examples.
testing-skills-with-subagents.md用于约束行为的 Skill 必须能够抵抗合理化辩解。Agent 很聪明,在压力下会找到漏洞。
关键技巧(摘要):
- 明确堵住每一个漏洞——禁止具体的绕过方法,而不只是笼统规则
- 添加合理化辩解表:记录 Agent 提出的每一个借口 → 逐一反驳
- 添加“危险信号——停止”列表,供自我检查
- 处理“精神 vs 字面”的争论:添加“违反字面要求就是违反精神要求”
RED: 不带 Skill 运行压力场景 → 逐字记录确切的合理化辩解。
GREEN: 编写 Skill 以解决这些具体合理化辩解 → 验证合规性。
REFACTOR: 发现新的合理化辩解 → 添加反驳 → 重新测试,直到坚不可摧。
→ 参阅 ,了解完整方法:压力场景模板、所有压力类型(时间/沉没成本/权威/疲劳)、系统性封堵漏洞、元测试技巧和实战示例。
testing-skills-with-subagents.mdAnti-Patterns
反模式
❌ Narrative Example
❌ 叙事式示例
"In session 2025-10-03, we found empty projectDir caused..."
Why bad: Too specific, not reusable
“在 2025-10-03 那次会话中,我们发现 projectDir 为空导致了……”
为何不好: 过于具体,无法复用
❌ Multi-Language Dilution
❌ 多语言稀释
example-js.js, example-py.py, example-go.go
Why bad: Mediocre quality, maintenance burden
example-js.js、example-py.py、example-go.go
为何不好: 质量平庸,维护负担沉重
❌ Code in Flowcharts
❌ 流程图中的代码
dot
step1 [label="import fs"];
step2 [label="read file"];Why bad: Can't copy-paste, hard to read
dot
step1 [label="import fs"];
step2 [label="read file"];为何不好: 无法复制粘贴,难以阅读
❌ Generic Labels
❌ 泛化标签
helper1, helper2, step3, pattern4
Why bad: Labels should have semantic meaning
helper1、helper2、step3、pattern4
为何不好: 标签应具有语义
❌ Non-descriptive skill name
❌ 描述性不足的 Skill 名称
skill-utilshelpersmisc-patternsskill-utilshelpersmisc-patterns为何不好: Claude 通过名称搜索——模糊名称无法触发。请使用“动词-名词”形式(见上文“命名”)。
❌ Windows-style paths
❌ Windows 风格路径
scripts\helper.pyreference\guide.mdscripts\helper.pyreference\guide.md为何不好: 在 Unix 上会失效。所有地方都应使用正斜杠。
❌ Too many options
❌ 过多选项
"You can use pypdf, or pdfplumber, or PyMuPDF, or pdf2image…"
Why bad: Decision fatigue. Provide one default; add escape hatch for the rare exception.
“你可以使用 pypdf,也可以使用 pdfplumber、PyMuPDF 或 pdf2image……”
为何不好: 决策疲劳。提供一个默认选项;仅为罕见的例外增加备用方案。
❌ Domain-by-domain catalog instead of a general rule
❌ 按领域罗列目录,而不是给出通用规则
Separate bullets/sections for "finance decisions", "health decisions", "legal decisions"
that each restate the same underlying rule with different nouns.
Why bad: Doesn't generalize to the next domain that shows up. When correcting a skill,
state the rule once at the level it actually applies, not as a growing list of examples.
分别为“财务决策”“健康决策”“法律决策”等设置项目符号或章节,每个部分只是用不同名词重述同一条底层规则。
为何不好: 无法泛化到下一个出现的领域。修正 Skill 时,应在实际适用层级上只陈述一次规则,而不是将其扩展成不断增长的示例列表。
STOP: Before Moving to Next Skill
停止:切换到下一个 Skill 之前
After writing ANY skill, you MUST STOP and complete the deployment process.
Do NOT:
- Create multiple skills in batch without testing each
- Move to next skill before current one is verified
- Skip testing because "batching is more efficient"
The deployment checklist below is MANDATORY for EACH skill.
编写任何 Skill 后,你必须停止并完成部署流程。
不要:
- 批量创建多个 Skill,而不逐个测试
- 当前 Skill 验证完成前就切换到下一个
- 因为“批量处理效率更高”而跳过测试
以下部署清单对每个 Skill 都是强制性的。
Skill Creation Checklist (TDD Adapted)
Skill 创建清单(适配 TDD)
IMPORTANT: Use the task-tracking tool (TaskCreate in Claude Code) to create a task for EACH checklist item below.
RED Phase - Write Failing Test:
- Create pressure scenarios (3+ combined pressures for discipline skills)
- Run scenarios WITHOUT skill - document baseline behavior verbatim
- Identify patterns in rationalizations/failures
GREEN Phase - Write Minimal Skill:
- Name uses only letters, numbers, hyphens (no parentheses/special chars)
- Name is verb-noun (e.g. ), not a vague category or noun
write-skill - YAML frontmatter with required and
namefields (max 1024 chars; see spec)description - set (
versionnew, bumped per semver on edits)1.0.0 - Description starts with "Use when..." and includes specific triggers/symptoms
- Description written in third person
- Keywords throughout for search (errors, symptoms, tools)
- Clear overview with core principle
- Address specific baseline failures identified in RED
- Code inline OR link to separate file
- One excellent example (not multi-language)
- Run scenarios WITH skill - verify agents now comply
REFACTOR Phase - Close Loopholes:
- Identify NEW rationalizations from testing
- Add explicit counters (if discipline skill)
- Build rationalization table from all test iterations
- Create red flags list
- Re-test until bulletproof
Quality Checks:
- Small flowchart only if decision non-obvious
- Quick reference table
- Common mistakes section
- No narrative storytelling
- Supporting files only for tools or heavy reference
- SKILL.md body under 500 lines (use progressive disclosure if over)
- No Windows-style paths (forward slashes only)
- Tested on Haiku, Sonnet, and Opus (not one model only)
- Prompt-structure pass (exact triggers, one item per condition) before drafting, e.g. with the plugin
write-prompt - Body and reference files write clean on the first draft: cut superfluous words, never fuse or drop meaning to shorten - no post-hoc tightening pass
Deployment:
- Every checklist item above re-verified against the finished file - drafting-time self-checks alone can miss gaps (e.g. a planned example that never made it in)
- Commit skill to git and push to your fork (if configured)
- Consider contributing back via PR (if broadly useful)
重要:使用任务跟踪工具(Claude Code 中的 TaskCreate),为下方每个清单项创建一个任务。
RED 阶段——编写失败测试:
- 创建压力场景(纪律约束型 Skill 需要组合 3 种以上压力)
- 在不带 Skill 的情况下运行场景——逐字记录基线行为
- 找出合理化辩解或失败行为中的模式
GREEN 阶段——编写最小 Skill:
- 名称仅使用字母、数字和连字符(不能使用括号或特殊字符)
- 名称采用“动词-名词”形式(例如 ),而不是模糊的类别名或名词
write-skill - YAML 前置元数据包含必需的 和
name字段(最多 1024 个字符;见规范)description - 已设置 (新 Skill 为
version,编辑时按 semver 递增)1.0.0 - Description 以“Use when...”开头,并包含具体的触发条件或症状
- Description 使用第三人称
- 全文包含便于搜索的关键词(错误、症状、工具)
- 清晰的概览,包含核心原则
- 解决 RED 阶段识别出的具体基线失败
- 代码直接内联,或链接到单独文件
- 提供一个优秀示例,而不是多语言示例
- 带着 Skill 运行场景——验证 Agent 现在能够遵守规则
REFACTOR 阶段——堵住漏洞:
- 找出测试中出现的新合理化辩解
- 添加明确反驳条款(如果属于纪律约束型 Skill)
- 根据所有测试迭代构建合理化辩解表
- 创建危险信号列表
- 重新测试,直到 Skill 经受住考验
质量检查:
- 仅在决策不明显时使用小型流程图
- 快速参考表
- 常见错误章节
- 不使用叙事式故事
- 支持文件仅用于工具或重型参考资料
- SKILL.md 正文少于 500 行(超过则使用渐进式披露)
- 不使用 Windows 风格路径(仅使用正斜杠)
- 已在 Haiku、Sonnet 和 Opus 上测试(不能只测试一个模型)
- 起草前完成提示词结构检查(精确触发条件,每个条件单独一项),例如使用 插件
write-prompt - 正文和参考文件初稿即应干净:删去多余词语,但绝不为缩短篇幅而合并或丢失含义;不做事后精简处理
部署:
- 根据最终文件重新核验上述每个清单项——仅在起草时自检可能会遗漏问题(例如,计划中的示例最终没有写入)
- 将 Skill 提交到 Git 并推送到你的 fork(如果已配置)
- 如果具有广泛适用性,考虑通过 PR 回贡
Discovery Workflow
发现工作流
How future Claude finds your skill:
- Encounters problem ("tests are flaky")
- Finds SKILL (description matches)
- Scans overview (is this relevant?)
- Reads patterns (quick reference table)
- Loads example (only when implementing)
Optimize for this flow - put searchable terms early and often.
未来的 Claude 如何找到你的 Skill:
- 遇到问题(“tests are flaky”)
- 找到 SKILL(description 匹配)
- 浏览概览(是否相关?)
- 阅读模式(快速参考表)
- 加载示例(仅在实现时)
针对这一流程进行优化——尽早并经常放置可搜索的术语。
The Bottom Line
核心结论
Creating skills IS TDD for process documentation.
Same Iron Law: No skill without failing test first.
Same cycle: RED (baseline) → GREEN (write skill) → REFACTOR (close loopholes).
Same benefits: Better quality, fewer surprises, bulletproof results.
If you follow TDD for code, follow it for skills. It's the same discipline applied to documentation.
Base: — (MIT). Evaluation machinery absorbed from Anthropic example (Apache-2.0). See .
obra/superpowerswriting-skillsskill-creatorSOURCES.md创建 Skill 本质上就是针对流程文档执行 TDD。
同样的铁律:没有先看到失败的测试,就不能编写 Skill。
同样的循环:RED(基线)→ GREEN(编写 Skill)→ REFACTOR(堵住漏洞)。
同样的收益:质量更高、意外更少、结果更加可靠。
如果你对代码遵循 TDD,也应对 Skill 遵循 TDD。这只是将同一种纪律应用到文档中。
基础: — (MIT)。评估机制吸收自 Anthropic 示例(Apache-2.0)。见 。
obra/superpowerswriting-skillsskill-creatorSOURCES.md