附录 B
附录 B:SKILL.md 模板
创建新 skill 时复制此模板。完整示例见第九章,设计模式见第八章。
最简模板
适用于工作流简单的 skill:
---
name: my-skill-name
description: What this skill does and when to use it. Include trigger words Claude should recognize.
---
# My Skill Name
## Purpose
One sentence explaining the goal.
## Inputs
- What files or information the user provides
## Process
1. Step one
2. Step two
3. Step three
## Output
What gets generated and where it goes.
最简 skill 示例:
---
name: standup-notes
description: Generate standup notes from yesterday's git commits. Use when user mentions standup, daily update, or what I did yesterday.
---
# Standup Notes
## Purpose
Create formatted standup notes from recent commits.
## Inputs
- Git repository with commit history
## Process
1. Read commits from the past 24 hours
2. Group by type (feature, fix, refactor)
3. Write in first person, past tense
## Output
Print standup notes to terminal. Do not create a file.
综合模板
适用于需要详细指令的复杂 skill:
---
name: my-skill-name
description: Detailed description of what this skill does. Mention specific trigger phrases: analysis, synthesis, report generation. Auto-invoke when user mentions [keyword1], [keyword2], or [keyword3].
---
# My Skill Name
## Purpose
Explain the goal and value of this skill in 2-3 sentences. What problem does it solve? What outcome does it produce?
## Expected Inputs
- **Required:** File types, formats, or information the user must provide
- **Optional:** Additional context that improves results
- Supports: List compatible formats (CSV, JSON, plain text)
## Process
Follow these steps in order:
1. **Read and validate inputs**
- Check that required files exist
- Identify relevant columns or fields
2. **Analyze content**
- Describe the analysis methodology
- Include specific criteria or thresholds
3. **Generate output**
- Specify the output format
- Note any formatting requirements
4. **Quality check**
- Verify output meets criteria before finishing
## Output Format
Generate file: `path/to/output-[date].md`
Structure:
## Section One
[What goes here]
## Section Two
[What goes here]
## Quality Criteria
- Criterion one (specific and measurable)
- Criterion two
- Criterion three
## Edge Cases
- **Small datasets:** How to handle insufficient data
- **Malformed input:** What to do when input is incomplete
- **Ambiguous requests:** How to interpret unclear instructions
## Usage Examples
**Standard:** "Run [skill name] on [file]"
**Detailed:** "Run [skill name] on [file] with comprehensive analysis"
**Quick:** "Run [skill name] on [file], just the summary"
字段参考
| 字段 | 必需 | 用途 |
|---|---|---|
| name | 是 | 唯一标识符,小写加连字符 |
| description | 是 | 发现文本——Claude 用它决定何时激活。包含触发词。 |
各节指南
Purpose:最多一段。以用户得到什么来开头,而不是 skill 内部做什么。
Expected Inputs:对格式要具体。"CSV 文件"过于模糊;"CSV 文件,反馈文本在一列中"告诉 Claude 要找什么。
Process:对步骤编号。使用祈使语气("读取文件"而不是"文件应该被读取")。包含决策点("如果 X,则 Y")。
Output Format:展示确切的结构。使用代码块作为模板。指定文件路径模式。
Quality Criteria:使这些可测试。"质量好"是没用的;"引用逐字准确,而非改写"是可操作的。
Edge Cases:记录三种最常见的失败场景。这能节省日后调试时间。
文件结构
.claude/skills/
└── my-skill-name/
├── SKILL.md # 必需
├── scripts/ # 可选的辅助脚本
│ └── helper.py
└── resources/ # 可选的模板、评分标准
└── template.md
存放位置选项:
- .claude/skills/ — 项目特定,通过 git 与团队共享
- ~/.claude/skills/ — 个人,在所有项目中可用
常见错误
模糊的描述:"帮助处理反馈"不会触发。应使用:"将客户反馈综合为主题报告。当用户提到反馈分析、NPS 综合或支持工单主题时自动调用。"
缺少触发词:Claude 将你的请求与 skill 描述匹配。如果你的描述不包含用户实际使用的词,skill 就不会激活。
指令过长:将 SKILL.md 保持在 5,000 字以内。将参考资料移到 resources/ 中的独立文件。
没有质量标准:没有明确的标准,输出质量会变化。定义"做得好"是什么样子。
创建 skill 后,重启 Claude Code 来加载它。在提交前用真实数据测试。