创建你的第一个 Skill
这篇教程将引导你完成创建一个 Skill 的完整流程。我们将创建一个简单的 “代码审查检查清单” Skill,它帮助 Claude 在代码审查时遵循一致的检查项。
This tutorial walks you through creating a complete Skill. We’ll build a simple “Code Review Checklist” Skill that helps Claude follow consistent checklist items during code reviews.
Step 1: 创建项目结构
Section titled “Step 1: 创建项目结构”首先创建 Skill 的目录结构。最小结构只需一个 SKILL.md 文件。
First, create the Skill directory structure. The minimal structure needs only a SKILL.md file.
mkdir code-review-checklistcd code-review-checklisttouch SKILL.mdStep 2: 编写 SKILL.md
Section titled “Step 2: 编写 SKILL.md”SKILL.md 是 Skill 的核心。它包含 YAML frontmatter(元数据)和 Markdown body(指令)。
SKILL.md is the core of the Skill. It contains YAML frontmatter (metadata) and Markdown body (instructions).
Step 3: 添加参考文档(可选)
Section titled “Step 3: 添加参考文档(可选)”如果你的 Skill 需要参考信息(如公司编码规范、API 文档等),可以放在 references/ 目录中。
If your Skill needs reference information (e.g., company coding standards, API docs), place them in the references/ directory.
mkdir referencescat > references/coding-standards.md << 'EOF'# Company Coding Standards
- Use 2-space indentation- Prefer async/await over raw promises- Maximum function length: 50 lines- Required test coverage: 80%EOFStep 4: 测试你的 Skill
Section titled “Step 4: 测试你的 Skill”在 Claude Code 中注册并测试你的 Skill:
Register and test your Skill in Claude Code:
# Register your skill in Claude Code# Add to .claude/settings.json or use /plugin# Then test it:echo "Review this PR: [paste diff]" | claude验证 Claude 是否:
- 正确触发了你的 Skill(检查是否按 checklist 格式输出)
- 覆盖了所有检查维度
- 输出格式符合 Review Output Format 定义
Verify Claude:
- Correctly triggered your Skill (check if output follows checklist format)
- Covered all review dimensions
- Output format matches Review Output Format definition
Step 5: 迭代优化
Section titled “Step 5: 迭代优化”基于测试结果迭代改进:
- 如果 Skill 没有被触发 → 增强
description字段 - 如果遗漏了某个检查维度的 → 补充 checklist 条目
- 如果输出格式不稳定 → 在 “Review Output Format” 中增加更具体的指令
参考 skill-creator 学习如何使用量化评估体系来系统性地优化你的 Skill。
Iterate based on test results:
- If Skill is not triggered → strengthen the
descriptionfield - If a review dimension is missed → add checklist items
- If output format is inconsistent → add more specific instructions in “Review Output Format”
See skill-creator to learn how to use a quantitative evaluation system to systematically optimize your Skill.