sub-agent-creator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Sub-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:
RuleRequirementConsequence
Single-line description
description
must be one line, no
\n
Validation failure
No literal
\n
Use actual newlines in body, not
\n
escapes
Validation failure
Valid colors onlyIf specified: red, blue, green, yellow, purple, orange, pink, cyanAgent won't load
Valid models only
sonnet
,
opus
,
haiku
, or
inherit
Validation failure
Name formatLowercase letters, numbers, hyphens onlyValidation failure
子Agent必须严格遵循格式要求,否则会验证失败无法加载:
规则要求后果
单行描述
description
必须为单行,不能包含
\n
验证失败
禁止字面
\n
在正文使用实际换行,而非
\n
转义符
验证失败
仅使用有效颜色若指定颜色,只能是:red、blue、green、yellow、purple、orange、pink、cyanAgent无法加载
仅使用有效模型
sonnet
opus
haiku
inherit
验证失败
名称格式仅允许小写字母、数字、连字符验证失败

Examples of WRONG vs RIGHT

错误示例 vs 正确示例

yaml
undefined
yaml
undefined

WRONG - 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.

```yaml
description: Expert code reviewer. Use proactively after code changes.

```yaml

WRONG - 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:
  1. Run tests
  2. Report results
undefined

name: test-runner description: Run tests

You are a test runner. When invoked:
  1. Run tests
  2. Report results
undefined

Workflow

工作流程

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
    inherit
    . Only suggest
    haiku
    for simple, fast tasks. ALWAYS confirm before using non-inherit models.
  • Color: Auto-select from valid options (red, blue, green, yellow, purple, orange, pink, cyan) OR let user choose.
使用AskUserQuestion工具提出澄清问题,确认:
  • 标识符:Agent的命名是什么?(格式为小写字母加连字符)
  • 主动使用设置:该Agent应主动使用还是仅在明确请求时使用?
  • 模型:默认使用
    inherit
    。仅针对简单快速任务建议
    haiku
    。使用非inherit模型前必须确认。
  • 颜色:从有效选项中自动选择,或让用户选择。

3. Identify Helpful Context

3. 识别有用的上下文

Search the workspace for:
Relevant skills: Check
.claude/skills/
and project skills that would help the agent.
bash
ls .claude/skills/
Relevant documentation: Look for references files, CLAUDE.md, API docs, etc.
bash
find . -name "*.md" -type f | head -20
在工作区中搜索:
相关技能:检查
.claude/skills/
目录和项目中对Agent有帮助的技能。
bash
ls .claude/skills/
相关文档:查找参考文件、CLAUDE.md、API文档等。
bash
find . -name "*.md" -type f | head -20

4. Design the System Prompt

4. 设计系统提示词

Using the agent creation architect framework (see
references/agent-creation-prompt.md
):
  1. Extract Core Intent - Fundamental purpose and success criteria
  2. Design Expert Persona - Compelling identity with domain knowledge
  3. Architect Instructions - Behavioral boundaries, methodologies, edge cases
  4. Optimize for Performance - Decision frameworks, quality control
  5. 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
):
  1. 提取核心意图 - 基本目标和成功标准
  2. 设计专家角色 - 具备领域知识的鲜明身份
  3. 构建指令 - 行为边界、方法、边缘情况
  4. 优化性能 - 决策框架、质量控制
  5. 创建使用场景示例 - 展示委托逻辑的具体案例
系统提示词应使用第二人称(“你是……”、“你将……”)。

5. Write the Agent File

5. 编写Agent文件

Write the agent file to
.claude/agents/<identifier>.md
:
yaml
---
name: <identifier>
description: <single-line description with when to use>
model: inherit
---

<system prompt in markdown body>
Default settings:
  • model
    : Always
    inherit
    unless user confirms otherwise
  • tools
    : Omit to allow all tools (user preference: never restrict)
  • skills
    : Include if specific skills would help the agent
将Agent文件写入
.claude/agents/<identifier>.md
yaml
---
name: <identifier>
description: <single-line description with when to use>
model: inherit
---

<system prompt in markdown body>
默认设置:
  • model
    : 除非用户确认,否则始终使用
    inherit
  • tools
    : 省略该字段以允许使用所有工具(用户偏好:不限制)
  • skills
    : 若特定技能对Agent有帮助则包含

6. Validate Before Completing

6. 完成前验证

Run the validation script:
bash
python .claude/skills/sub-agent-creator/scripts/validate_agent.py .claude/agents/<identifier>.md
Only 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
description
field is Claude's primary signal for when to delegate. Include:
  • 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
字段是Claude判断何时委托的主要依据,应包含:
  • 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
/agents
command output.
  • scripts/validate_agent.py - 验证Agent文件格式错误
  • references/sub-agents-docs.md - 完整的Claude Code子Agent文档
  • references/agent-creation-prompt.md - Agent创建架构系统提示词框架
创建Agent后,验证其是否出现在
/agents
命令的输出中。