sub-agent-creator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSub-Agent Creator
子Agent创建工具
Interactive skill for creating Claude Code subagents. Guides the complete process: gathering requirements, designing the agent's purpose and persona, selecting helpful skills and documentation, and writing a properly formatted agent file to .
.claude/agents/适用于创建Claude Code子Agent的交互式技能。指导完整流程:收集需求、设计Agent的目标和角色、选择有用的技能和文档,以及将格式规范的Agent文件写入目录。
.claude/agents/Critical Formatting Rules
关键格式规则
Subagents MUST follow strict formatting or they will fail validation and not load:
| Rule | Requirement | Consequence |
|---|---|---|
| Single-line description | | Validation failure |
No literal | Use actual newlines in body, not | Validation failure |
| Valid colors only | If specified: red, blue, green, yellow, purple, orange, pink, cyan | Agent won't load |
| Valid models only | | Validation failure |
| Name format | Lowercase letters, numbers, hyphens only | Validation failure |
子Agent必须严格遵循格式要求,否则会验证失败无法加载:
| 规则 | 要求 | 后果 |
|---|---|---|
| 单行描述 | | 验证失败 |
禁止字面 | 在正文使用实际换行,而非 | 验证失败 |
| 仅使用有效颜色 | 若指定颜色,只能是:red、blue、green、yellow、purple、orange、pink、cyan | Agent无法加载 |
| 仅使用有效模型 | | 验证失败 |
| 名称格式 | 仅允许小写字母、数字、连字符 | 验证失败 |
Examples of WRONG vs RIGHT
错误示例 vs 正确示例
yaml
undefinedyaml
undefinedWRONG - Multi-line YAML syntax
WRONG - Multi-line YAML syntax
description: |
Expert code reviewer.
Use after code changes.
description: |
Expert code reviewer.
Use after code changes.
WRONG - Actual newlines in value
WRONG - Actual newlines in value
description: Expert code reviewer.
Use after code changes.
description: Expert code reviewer.
Use after code changes.
RIGHT - ONE continuous line
RIGHT - ONE continuous line
description: Expert code reviewer. Use proactively after code changes.
```yamldescription: Expert code reviewer. Use proactively after code changes.
```yamlWRONG - Literal \n in body
WRONG - Literal \n in body
name: test-runner description: Run tests
You are a test runner.\nWhen invoked:\n1. Run tests\n2. Report results
name: test-runner description: Run tests
You are a test runner.\nWhen invoked:\n1. Run tests\n2. Report results
RIGHT - Actual newlines
RIGHT - Actual newlines
name: test-runner description: Run tests
You are a test runner.
When invoked:
- Run tests
- Report results
undefinedname: test-runner description: Run tests
You are a test runner.
When invoked:
- Run tests
- Report results
undefinedWorkflow
工作流程
1. Understand Requirements
1. 理解需求
When this skill triggers, the user has described what kind of agent they want. First, extract:
- Core purpose: What should this agent do?
- Trigger conditions: When should Claude delegate to this agent?
- Key capabilities: What specific tasks will it handle?
- Existing context: Any relevant skills, docs, or project patterns?
当触发该技能时,用户已描述所需Agent的类型。首先提取:
- 核心目标:该Agent应完成什么任务?
- 触发条件:Claude应在何时委托给该Agent?
- 关键能力:它将处理哪些具体任务?
- 现有上下文:是否有相关技能、文档或项目模式?
2. Use AskUserQuestion for Details
2. 使用AskUserQuestion获取细节
Ask clarifying questions using the AskUserQuestion tool. Confirm:
- Identifier: What should the agent be named? (lowercase-with-hyphens)
- Proactive usage: Should this agent be used proactively or only on explicit request?
- Model: Default to . Only suggest
inheritfor simple, fast tasks. ALWAYS confirm before using non-inherit models.haiku - Color: Auto-select from valid options (red, blue, green, yellow, purple, orange, pink, cyan) OR let user choose.
使用AskUserQuestion工具提出澄清问题,确认:
- 标识符:Agent的命名是什么?(格式为小写字母加连字符)
- 主动使用设置:该Agent应主动使用还是仅在明确请求时使用?
- 模型:默认使用。仅针对简单快速任务建议
inherit。使用非inherit模型前必须确认。haiku - 颜色:从有效选项中自动选择,或让用户选择。
3. Identify Helpful Context
3. 识别有用的上下文
Search the workspace for:
Relevant skills: Check and project skills that would help the agent.
.claude/skills/bash
ls .claude/skills/Relevant documentation: Look for references files, CLAUDE.md, API docs, etc.
bash
find . -name "*.md" -type f | head -20在工作区中搜索:
相关技能:检查目录和项目中对Agent有帮助的技能。
.claude/skills/bash
ls .claude/skills/相关文档:查找参考文件、CLAUDE.md、API文档等。
bash
find . -name "*.md" -type f | head -204. Design the System Prompt
4. 设计系统提示词
Using the agent creation architect framework (see ):
references/agent-creation-prompt.md- Extract Core Intent - Fundamental purpose and success criteria
- Design Expert Persona - Compelling identity with domain knowledge
- Architect Instructions - Behavioral boundaries, methodologies, edge cases
- Optimize for Performance - Decision frameworks, quality control
- Create whenToUse Examples - Concrete examples showing delegation
The system prompt should be in second person ("You are...", "You will...").
使用Agent创建架构框架(参考):
references/agent-creation-prompt.md- 提取核心意图 - 基本目标和成功标准
- 设计专家角色 - 具备领域知识的鲜明身份
- 构建指令 - 行为边界、方法、边缘情况
- 优化性能 - 决策框架、质量控制
- 创建使用场景示例 - 展示委托逻辑的具体案例
系统提示词应使用第二人称(“你是……”、“你将……”)。
5. Write the Agent File
5. 编写Agent文件
Write the agent file to :
.claude/agents/<identifier>.mdyaml
---
name: <identifier>
description: <single-line description with when to use>
model: inherit
---
<system prompt in markdown body>Default settings:
- : Always
modelunless user confirms otherwiseinherit - : Omit to allow all tools (user preference: never restrict)
tools - : Include if specific skills would help the agent
skills
将Agent文件写入:
.claude/agents/<identifier>.mdyaml
---
name: <identifier>
description: <single-line description with when to use>
model: inherit
---
<system prompt in markdown body>默认设置:
- : 除非用户确认,否则始终使用
modelinherit - : 省略该字段以允许使用所有工具(用户偏好:不限制)
tools - : 若特定技能对Agent有帮助则包含
skills
6. Validate Before Completing
6. 完成前验证
Run the validation script:
bash
python .claude/skills/sub-agent-creator/scripts/validate_agent.py .claude/agents/<identifier>.mdOnly proceed if validation passes. Fix any errors and re-validate.
运行验证脚本:
bash
python .claude/skills/sub-agent-creator/scripts/validate_agent.py .claude/agents/<identifier>.md仅在验证通过后继续。修复所有错误并重新验证。
Agent File Template
Agent文件模板
yaml
---
name: agent-identifier
description: Brief single-line description starting with what it does. Use proactively when [trigger condition].
model: inherit
skills:
- relevant-skill-1
- relevant-skill-2
---
You are an expert [domain] specialist.
When invoked:
1. [First step]
2. [Second step]
3. [Continue as needed]
Your approach:
- [Guideline 1]
- [Guideline 2]
For each [task], provide:
- [Output format 1]
- [Output format 2]
Focus on [core principle].yaml
---
name: agent-identifier
description: Brief single-line description starting with what it does. Use proactively when [trigger condition].
model: inherit
skills:
- relevant-skill-1
- relevant-skill-2
---
You are an expert [domain] specialist.
When invoked:
1. [First step]
2. [Second step]
3. [Continue as needed]
Your approach:
- [Guideline 1]
- [Guideline 2]
For each [task], provide:
- [Output format 1]
- [Output format 2]
Focus on [core principle].Description Best Practices
描述最佳实践
The field is Claude's primary signal for when to delegate. Include:
description- What the agent does: "Expert code reviewer specializing in..."
- When to use: "Use proactively after writing code" or "Use when analyzing..."
- Triggers: Specific situations that should trigger delegation
Examples:
yaml
description: Test execution specialist. Use proactively after writing tests or modifying test files.
description: Database query analyst. Use when needing to analyze data or generate reports from BigQuery.
description: Code archaeology expert. Use when exploring legacy codebases or understanding unfamiliar code.description- Agent功能:“专业代码评审员,擅长……”
- 使用时机:“编写代码后主动使用”或“分析……时使用”
- 触发场景:应触发委托的具体情况
示例:
yaml
description: Test execution specialist. Use proactively after writing tests or modifying test files.
description: Database query analyst. Use when needing to analyze data or generate reports from BigQuery.
description: Code archaeology expert. Use when exploring legacy codebases or understanding unfamiliar code.Resources
资源
- scripts/validate_agent.py - Validates agent files for formatting errors
- references/sub-agents-docs.md - Complete Claude Code subagents documentation
- references/agent-creation-prompt.md - Agent creation architect system prompt framework
After creating an agent, verify it appears in command output.
/agents- scripts/validate_agent.py - 验证Agent文件格式错误
- references/sub-agents-docs.md - 完整的Claude Code子Agent文档
- references/agent-creation-prompt.md - Agent创建架构系统提示词框架
创建Agent后,验证其是否出现在命令的输出中。
/agents