create-agent-skills
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreating Skills & Commands
技能与命令创建指南
This skill teaches how to create effective Claude Code skills following the official specification from code.claude.com/docs/en/skills.
本技能将指导你如何遵循code.claude.com/docs/en/skills官方规范,创建高效的Claude Code技能。
Commands and Skills Are Now The Same Thing
命令与技能现已统一
Custom slash commands have been merged into skills. A file at and a skill at both create and work the same way. Existing files keep working. Skills add optional features: a directory for supporting files, frontmatter to control invocation, and automatic context loading.
.claude/commands/review.md.claude/skills/review/SKILL.md/review.claude/commands/If a skill and a command share the same name, the skill takes precedence.
自定义斜杠命令已整合到技能体系中。路径下的命令文件,与路径下的技能文件,都会生成命令,且功能完全一致。已有的目录下的文件仍可正常使用。技能新增了可选特性:支持附属文件的目录结构、控制调用的前置元数据(frontmatter),以及自动上下文加载功能。
.claude/commands/review.md.claude/skills/review/SKILL.md/review.claude/commands/若技能与命令重名,技能将优先生效。
When To Create What
场景选择建议
Use a command file () when:
commands/name.md- Simple, single-file workflow
- No supporting files needed
- Task-oriented action (deploy, commit, triage)
Use a skill directory () when:
skills/name/SKILL.md- Need supporting reference files, scripts, or templates
- Background knowledge Claude should auto-load
- Complex enough to benefit from progressive disclosure
Both use identical YAML frontmatter and markdown content format.
使用命令文件()的场景:
commands/name.md- 简单的单文件工作流
- 无需附属文件
- 面向特定任务的操作(如部署、提交、问题分类)
使用技能目录()的场景:
skills/name/SKILL.md- 需要配套的参考文件、脚本或模板
- 需要Claude自动加载背景知识
- 逻辑复杂,适合采用渐进式内容披露方式
两者均使用完全相同的YAML前置元数据与Markdown内容格式。
Standard Markdown Format
标准Markdown格式
Use YAML frontmatter + markdown body with standard markdown headings. Keep it clean and direct.
markdown
---
name: my-skill-name
description: What it does and when to use it
---采用YAML前置元数据 + Markdown正文的结构,使用标准Markdown标题。保持内容简洁直接。
markdown
---
name: my-skill-name
description: 技能功能及适用场景
---My Skill Name
我的技能名称
Quick Start
快速开始
Immediate actionable guidance...
可立即执行的操作指引...
Instructions
详细步骤
Step-by-step procedures...
分步操作流程...
Examples
使用示例
Concrete usage examples...
undefined具体的使用案例...
undefinedFrontmatter Reference
前置元数据参考
All fields are optional. Only is recommended.
description| Field | Required | Description |
|---|---|---|
| No | Display name. Lowercase letters, numbers, hyphens (max 64 chars). Defaults to directory name. |
| Recommended | What it does AND when to use it. Claude uses this for auto-discovery. Max 1024 chars. |
| No | Hint shown during autocomplete. Example: |
| No | Set |
| No | Set |
| No | Tools Claude can use without permission prompts. Example: |
| No | Model to use. Options: |
| No | Set |
| No | Subagent type when |
所有字段均为可选,仅推荐填写字段。
description| 字段 | 是否必填 | 描述 |
|---|---|---|
| 否 | 显示名称。仅允许小写字母、数字、连字符(最多64字符)。默认值为目录名称。 |
| 推荐 | 技能功能及适用场景。Claude将据此进行自动发现。最多1024字符。 |
| 否 | 自动补全时显示的参数提示。示例: |
| 否 | 设置为 |
| 否 | 设置为 |
| 否 | Claude无需权限提示即可使用的工具。示例: |
| 否 | 使用的模型选项。可选值: |
| 否 | 设置为 |
| 否 | 当 |
Invocation Control
调用控制规则
| Frontmatter | User can invoke | Claude can invoke | When loaded |
|---|---|---|---|
| (default) | Yes | Yes | Description always in context, full content loads when invoked |
| Yes | No | Description not in context, loads only when user invokes |
| No | Yes | Description always in context, loads when relevant |
Use for workflows with side effects: , , , . You don't want Claude deciding to deploy because your code looks ready.
disable-model-invocation: true/deploy/commit/triage-prs/send-slack-messageUse for background knowledge that isn't a meaningful user action: coding conventions, domain context, legacy system docs.
user-invocable: false| 前置元数据配置 | 用户可调用 | Claude可自动调用 | 加载时机 |
|---|---|---|---|
| 默认配置 | 是 | 是 | 描述始终在上下文中,触发时加载完整内容 |
| 是 | 否 | 描述不在上下文中,仅当用户主动调用时加载 |
| 否 | 是 | 描述始终在上下文中,相关场景下自动加载 |
建议为带有副作用的工作流设置:如、、、。你肯定不希望Claude因为代码看起来没问题就自动执行部署操作。
disable-model-invocation: true/deploy/commit/triage-prs/send-slack-message建议为背景知识类内容设置:如编码规范、领域上下文、遗留系统文档等,这些并非用户可执行的操作。
user-invocable: falseDynamic Features
动态特性
Arguments
参数处理
Use placeholder for user input. If not present in content, arguments are appended automatically.
$ARGUMENTSyaml
---
name: fix-issue
description: Fix a GitHub issue
disable-model-invocation: true
---
Fix GitHub issue $ARGUMENTS following our coding standards.Access individual args: or shorthand , , .
$ARGUMENTS[0]$0$1$2使用占位符接收用户输入。若内容中未包含该占位符,参数将自动追加到内容末尾。
$ARGUMENTSyaml
---
name: fix-issue
description: 修复GitHub问题
disable-model-invocation: true
---
按照编码标准修复GitHub问题$ARGUMENTS。可通过或简写、、访问单个参数。
$ARGUMENTS[0]$0$1$2Dynamic Context Injection
动态上下文注入
The syntax runs shell commands before content is sent to Claude:
!`command`yaml
---
name: pr-summary
description: Summarize changes in a pull request
context: fork
agent: Explore
---使用语法可在内容发送给Claude前执行Shell命令:
!`command`yaml
---
name: pr-summary
description: 总结Pull Request中的变更
context: fork
agent: Explore
---Context
上下文信息
- PR diff: !
gh pr diff - Changed files: !
gh pr diff --name-only
Summarize this pull request...
undefined- PR差异:!
gh pr diff - 修改文件:!
gh pr diff --name-only
总结本次Pull Request的变更内容...
undefinedRunning in a Subagent
子Agent独立运行
Add to run in isolation. The skill content becomes the subagent's prompt. It won't have conversation history.
context: forkyaml
---
name: deep-research
description: Research a topic thoroughly
context: fork
agent: Explore
---
Research $ARGUMENTS thoroughly:
1. Find relevant files
2. Analyze the code
3. Summarize findings添加配置可让技能在独立上下文运行。技能内容将作为子Agent的提示词,不会包含对话历史。
context: forkyaml
---
name: deep-research
description: 深入研究指定主题
context: fork
agent: Explore
---
深入研究$ARGUMENTS:
1. 查找相关文件
2. 分析代码
3. 总结研究结果Progressive Disclosure
渐进式内容披露
Keep SKILL.md under 500 lines. Split detailed content into reference files:
my-skill/
├── SKILL.md # Entry point (required, overview + navigation)
├── reference.md # Detailed docs (loaded when needed)
├── examples.md # Usage examples (loaded when needed)
└── scripts/
└── helper.py # Utility script (executed, not loaded)Link from SKILL.md:
For API details, see [reference.md](reference.md).Keep references one level deep from SKILL.md. Avoid nested chains.
保持SKILL.md文件不超过500行。将详细内容拆分到参考文件中:
my-skill/
├── SKILL.md # 入口文件(必填,包含概述与导航)
├── reference.md # 详细文档(按需加载)
├── examples.md # 使用示例(按需加载)
└── scripts/
└── helper.py # 实用脚本(可执行,不加载为上下文)在SKILL.md中添加链接:
API详情请参考[reference.md](reference.md)。参考文件需保持与SKILL.md同级,避免嵌套层级过深。
Effective Descriptions
高效描述编写技巧
The description enables skill discovery. Include both what it does and when to use it.
Good:
yaml
description: Extract text and tables from PDF files, fill forms, merge documents. Use when working with PDF files or when the user mentions PDFs, forms, or document extraction.Bad:
yaml
description: Helps with documents描述是技能被自动发现的关键,需同时包含功能与触发场景。
优秀示例:
yaml
description: 从PDF文件中提取文本与表格、填充表单、合并文档。适用于处理PDF文件或用户提及PDF、表单、文档提取的场景。糟糕示例:
yaml
description: 处理文档What Would You Like To Do?
你想执行以下哪项操作?
- Create new skill - Build from scratch
- Create new command - Build a slash command
- Audit existing skill - Check against best practices
- Add component - Add workflow/reference/example
- Get guidance - Understand skill design
- 创建新技能 - 从零开始构建
- 创建新命令 - 构建斜杠命令
- 审计现有技能 - 对照最佳实践检查
- 添加组件 - 添加工作流/参考内容/示例
- 获取指导 - 理解技能设计思路
Creating a New Skill or Command
创建新技能或命令的步骤
Step 1: Choose Type
步骤1:选择类型
Ask: Is this a manual workflow (deploy, commit, triage) or background knowledge (conventions, patterns)?
- Manual workflow → command with
disable-model-invocation: true - Background knowledge → skill without
disable-model-invocation - Complex with supporting files → skill directory
思考:这是手动工作流(如部署、提交、分类)还是背景知识(如规范、模式)?
- 手动工作流 → 使用命令文件并设置
disable-model-invocation: true - 背景知识 → 使用技能文件,不设置
disable-model-invocation - 复杂且需附属文件 → 使用技能目录
Step 2: Create the File
步骤2:创建文件
Command:
markdown
---
name: my-command
description: What this command does
argument-hint: [expected arguments]
disable-model-invocation: true
allowed-tools: Bash(gh *), Read
---命令文件示例:
markdown
---
name: my-command
description: 该命令的功能
argument-hint: [预期参数]
disable-model-invocation: true
allowed-tools: Bash(gh *), Read
---Command Title
命令标题
Workflow
工作流
Step 1: Gather Context
步骤1:收集上下文
...
...
Step 2: Execute
步骤2:执行操作
...
...
Success Criteria
成功标准
- Expected outcome 1
- Expected outcome 2
**Skill:**
```markdown
---
name: my-skill
description: What it does. Use when [trigger conditions].
---- 预期结果1
- 预期结果2
**技能文件示例:**
```markdown
---
name: my-skill
description: 技能功能。适用于[触发条件]场景。
---Skill Title
技能标题
Quick Start
快速开始
[Immediate actionable example]
[可立即执行的示例]
Instructions
操作指引
[Core guidance]
[核心指导内容]
Examples
使用示例
[Concrete input/output pairs]
undefined[具体的输入/输出示例]
undefinedStep 3: Add Reference Files (If Needed)
步骤3:添加参考文件(如需)
Link from SKILL.md to detailed content:
markdown
For API reference, see [reference.md](reference.md).
For form filling guide, see [forms.md](forms.md).在SKILL.md中链接到详细内容:
markdown
API参考请见[reference.md](reference.md)。
表单填充指南请见[forms.md](forms.md)。Step 4: Test With Real Usage
步骤4:实际场景测试
- Test with actual tasks, not test scenarios
- Invoke directly with to verify
/skill-name - Check auto-triggering by asking something that matches the description
- Refine based on real behavior
- 在真实任务中测试,而非仅测试场景
- 通过直接调用以验证功能
/skill-name - 通过提问匹配描述的内容,检查自动触发是否正常
- 根据实际表现优化技能
Audit Checklist
审计检查清单
- Valid YAML frontmatter (name + description)
- Description includes trigger keywords and is specific
- Uses standard markdown headings (not XML tags)
- SKILL.md under 500 lines
- if it has side effects
disable-model-invocation: true - set if specific tools needed
allowed-tools - References one level deep, properly linked
- Examples are concrete, not abstract
- Tested with real usage
- 有效的YAML前置元数据(包含name与description)
- 描述包含触发关键词且具体明确
- 使用标准Markdown标题(而非XML标签)
- SKILL.md文件不超过500行
- 带有副作用的工作流已设置
disable-model-invocation: true - 已根据需求配置
allowed-tools - 参考文件与SKILL.md同级,链接正确
- 示例具体,非抽象描述
- 已在真实场景中测试
Anti-Patterns to Avoid
需避免的反模式
- XML tags in body - Use standard markdown headings
- Vague descriptions - Be specific with trigger keywords
- Deep nesting - Keep references one level from SKILL.md
- Missing invocation control - Side-effect workflows need
disable-model-invocation: true - Too many options - Provide a default with escape hatch
- Punting to Claude - Scripts should handle errors explicitly
- 正文使用XML标签 - 应使用标准Markdown标题
- 描述模糊 - 需明确包含触发关键词
- 参考文件嵌套过深 - 保持与SKILL.md同级
- 未配置调用控制 - 有副作用的工作流必须设置
disable-model-invocation: true - 选项过多 - 提供默认选项及扩展入口即可
- 依赖Claude自动处理 - 脚本应显式处理错误
Reference Files
参考文件
For detailed guidance, see:
- official-spec.md - Official skill specification
- best-practices.md - Skill authoring best practices
如需详细指导,请查看:
- official-spec.md - 官方技能规范
- best-practices.md - 技能编写最佳实践