subagent-creator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSubagent Creator
Subagent 创建器
This skill provides guidance for creating effective, agent-agnostic subagents.
本Skill为创建高效、与Agent无关的Subagent提供指导。
What are Subagents?
什么是Subagent?
Subagents are specialized assistants that an AI agent can delegate tasks to. Characteristics:
- Isolated context: Each subagent has its own context window
- Parallel execution: Multiple subagents can run simultaneously
- Specialization: Configured with specific prompts and expertise
- Reusable: Defined once, used in multiple contexts
Subagent是AI Agent可将任务委托给的专用助手,具备以下特征:
- 隔离上下文:每个Subagent拥有独立的上下文窗口
- 并行执行:多个Subagent可同时运行
- 专业化:通过特定提示词和专业能力配置
- 可复用:定义一次,可在多场景中使用
When to Use Subagents vs Skills
Subagent与Skill的使用场景区分
Is the task complex with multiple steps?
├─ YES → Does it require isolated context?
│ ├─ YES → Use SUBAGENT
│ └─ NO → Use SKILL
│
└─ NO → Use SKILLUse Subagents for:
- Complex workflows requiring isolated context
- Long-running tasks that benefit from specialization
- Verification and auditing (independent perspective)
- Parallel workstreams
Use Skills for:
- Quick, one-off actions
- Domain knowledge without context isolation
- Reusable procedures that don't need isolation
任务是否为包含多步骤的复杂任务?
├─ 是 → 是否需要隔离上下文?
│ ├─ 是 → 使用 SUBAGENT
│ └─ 否 → 使用 SKILL
│
└─ 否 → 使用 SKILL适合使用Subagent的场景:
- 复杂工作流且需要隔离上下文
- 受益于专业化的长期运行任务
- 验证与审计(独立视角)
- 并行工作流
适合使用Skill的场景:
- 快速的一次性操作
- 无需上下文隔离的领域知识
- 不需要隔离的可复用流程
Subagent Structure
Subagent 结构
A subagent is typically a markdown file with frontmatter metadata:
markdown
---
name: agent-name
description: Description of when to use this subagent.
model: inherit # or fast, or specific model ID
readonly: false # true to restrict write permissions
---
You are an [expert in X].
When invoked:
1. [Step 1]
2. [Step 2]
3. [Step 3]
[Detailed instructions about expected behavior]
Report [type of expected result]:
- [Output format]
- [Metrics or specific information]Subagent通常是一个包含前置元数据的markdown文件:
markdown
---
name: agent-name
description: Description of when to use this subagent.
model: inherit # 或指定为fast,或具体模型ID
readonly: false # true 表示限制写入权限
---
You are an [expert in X].
When invoked:
1. [Step 1]
2. [Step 2]
3. [Step 3]
[Detailed instructions about expected behavior]
Report [type of expected result]:
- [Output format]
- [Metrics or specific information]Subagent Creation Process
Subagent 创建流程
1. Define the Purpose
1. 定义用途
- What specific responsibility does the subagent have?
- Why does it need isolated context?
- Does it involve multiple complex steps?
- Does it require deep specialization?
- 该Subagent的具体职责是什么?
- 为什么它需要隔离上下文?
- 它是否涉及多个复杂步骤?
- 它是否需要深度专业化?
2. Configure the Metadata
2. 配置元数据
name (required)
name(必填)
Unique identifier. Use kebab-case.
yaml
name: security-auditor唯一标识符,使用短横线分隔命名(kebab-case)。
yaml
name: security-auditordescription (critical)
description(关键)
CRITICAL for automatic delegation. Explains when to use this subagent.
Good descriptions:
- "Security specialist. Use when implementing auth, payments, or handling sensitive data."
- "Debugging specialist for errors and test failures. Use when encountering issues."
- "Validates completed work. Use after tasks are marked done."
Phrases that encourage automatic delegation:
- "Use proactively when..."
- "Always use for..."
- "Automatically delegate when..."
对自动委托至关重要,用于说明何时使用该Subagent。
优质示例:
- "安全专家。在实现认证、支付或处理敏感数据时使用。"
- "调试专家,负责处理错误和测试失败。遇到问题时使用。"
- "验证已完成的工作。在任务标记为完成后使用。"
促进自动委托的表述:
- "在...场景下主动使用"
- "所有...场景均需使用"
- "当...时自动委托"
model (optional)
model(可选)
yaml
model: inherit # Uses same model as parent (default)
model: fast # Uses fast model for quick tasksyaml
model: inherit # 使用与父Agent相同的模型(默认)
model: fast # 使用快速模型处理简单任务readonly (optional)
readonly(可选)
yaml
readonly: true # Restricts write permissionsyaml
readonly: true # 限制写入权限3. Write the Subagent Prompt
3. 编写Subagent提示词
Define:
- Identity: "You are an [expert]..."
- When invoked: Context of use
- Process: Specific steps to follow
- Expected output: Format and content
Template:
markdown
You are an [expert in X] specialized in [Y].
When invoked:
1. [First action]
2. [Second action]
3. [Third action]
[Detailed instructions about approach]
Report [type of result]:
- [Specific format]
- [Information to include]
- [Metrics or criteria]
[Philosophy or principles to follow]需定义以下内容:
- 身份定位:"你是一名[领域专家]..."
- 触发时机:使用场景
- 执行流程:需遵循的具体步骤
- 预期输出:格式与内容
模板:
markdown
你是一名专注于[Y]的[X领域专家]。
当被触发时:
1. [步骤1]
2. [步骤2]
3. [步骤3]
[关于预期行为的详细说明]
需提交[预期结果类型]:
- [输出格式]
- [需包含的指标或具体信息]
[需遵循的原则或理念]Common Subagent Patterns
常见Subagent模式
1. Verification Agent
1. 验证Agent
Purpose: Independently validates that completed work actually works.
markdown
---
name: verifier
description: Validates completed work. Use after tasks are marked done.
model: fast
---
You are a skeptical validator.
When invoked:
1. Identify what was declared as complete
2. Verify the implementation exists and is functional
3. Execute tests or relevant verification steps
4. Look for edge cases that may have been missed
Be thorough. Report:
- What was verified and passed
- What is incomplete or broken
- Specific issues to address用途:独立验证已完成工作的有效性。
markdown
---
name: verifier
description: Validates completed work. Use after tasks are marked done.
model: fast
---
你是一名严谨的验证者。
当被触发时:
1. 确认被标记为完成的任务内容
2. 验证实现是否存在且可正常运行
3. 执行测试或相关验证步骤
4. 排查可能被遗漏的边缘情况
请提供详细的验证报告:
- 已通过验证的内容
- 未完成或存在问题的内容
- 需要修复的具体问题2. Debugger
2. 调试Agent
Purpose: Expert in root cause analysis.
markdown
---
name: debugger
description: Debugging specialist. Use when encountering errors or test failures.
---
You are a debugging expert.
When invoked:
1. Capture the error message and stack trace
2. Identify reproduction steps
3. Isolate the failure location
4. Implement minimal fix
5. Verify the solution works
For each issue, provide:
- Root cause explanation
- Evidence supporting the diagnosis
- Specific code fix
- Testing approach用途:专注于根因分析的专家。
markdown
---
name: debugger
description: Debugging specialist. Use when encountering errors or test failures.
---
你是一名调试专家。
当被触发时:
1. 捕获错误信息与堆栈跟踪
2. 确定问题复现步骤
3. 定位故障发生位置
4. 实现最小化修复方案
5. 验证解决方案是否有效
针对每个问题,需提供:
- 根因分析说明
- 支持诊断的证据
- 具体的代码修复方案
- 测试方法3. Security Auditor
3. 安全审计Agent
Purpose: Security expert auditing code.
markdown
---
name: security-auditor
description: Security specialist. Use for auth, payments, or sensitive data.
---
You are a security expert.
When invoked:
1. Identify security-sensitive code paths
2. Check for common vulnerabilities
3. Confirm secrets are not hardcoded
4. Review input validation
Report findings by severity:
- **Critical** (must fix before deploy)
- **High** (fix soon)
- **Medium** (address when possible)
- **Low** (suggestions)用途:负责代码安全审计的专家。
markdown
---
name: security-auditor
description: Security specialist. Use for auth, payments, or sensitive data.
---
你是一名安全专家。
当被触发时:
1. 识别涉及安全的代码路径
2. 检查常见漏洞
3. 确认敏感信息未被硬编码
4. 审核输入验证逻辑
请按严重程度报告发现的问题:
- **Critical**(部署前必须修复)
- **High**(需尽快修复)
- **Medium**(尽可能处理)
- **Low**(优化建议)4. Code Reviewer
4. 代码评审Agent
Purpose: Code review with focus on quality.
markdown
---
name: code-reviewer
description: Code review specialist. Use when changes are ready for review.
---
You are a code review expert.
When invoked:
1. Analyze the code changes
2. Check readability, performance, patterns, error handling
3. Identify code smells and potential bugs
4. Suggest specific improvements
Report:
**✅ Approved / ⚠️ Approved with caveats / ❌ Changes needed**
**Issues Found:**
- **[Severity]** [Location]: [Issue]
- Suggestion: [How to fix]用途:专注于代码质量的评审专家。
markdown
---
name: code-reviewer
description: Code review specialist. Use when changes are ready for review.
---
你是一名代码评审专家。
当被触发时:
1. 分析代码变更内容
2. 检查可读性、性能、设计模式与错误处理
3. 识别代码异味与潜在Bug
4. 提出具体的改进建议
评审结果:
**✅ 批准 / ⚠️ 有条件批准 / ❌ 需要修改**
**发现的问题:**
- **[严重程度]** [位置]:[问题描述]
- 建议:[修复方案]Best Practices
最佳实践
✅ DO
✅ 建议做法
- Write focused subagents: One clear responsibility
- Invest in the description: Determines when to delegate
- Keep prompts concise: Direct and specific
- Share with team: Version control subagent definitions
- Test the description: Check correct subagent is triggered
- 编写聚焦的Subagent:职责单一明确
- 重视描述信息:决定了Agent何时触发委托
- 保持提示词简洁:直接且具体
- 与团队共享:对Subagent定义进行版本控制
- 测试描述信息:确认能触发正确的Subagent
❌ AVOID
❌ 避免事项
- Vague descriptions: "Use for general tasks" gives no signal
- Prompts too long: 2000 words don't make it smarter
- Too many subagents: Start with 2-3 focused ones
- 模糊的描述:“用于通用任务”无法提供有效触发信号
- 过长的提示词:2000词并不会让Subagent更智能
- 过多的Subagent:从2-3个聚焦的Subagent开始
Quality Checklist
质量检查清单
Before finalizing:
- Description is specific about when to delegate
- Name uses kebab-case
- One clear responsibility (not generic)
- Prompt is concise but complete
- Instructions are actionable
- Output format is well defined
- Model configuration appropriate
最终确定前需检查:
- 描述明确说明了何时触发委托
- 名称使用kebab-case格式
- 职责单一明确(非通用)
- 提示词简洁但完整
- 说明具备可操作性
- 输出格式定义清晰
- 模型配置合理
Output Messages
输出消息
When creating a subagent:
✅ Subagent created successfully!
📁 Location: .agent/subagents/[name].md
🎯 Purpose: [brief description]
🔧 How to invoke:
- Automatic: Agent delegates when it detects [context]
- Explicit: /[name] [instruction]
💡 Tip: Include keywords like "use proactively" to encourage delegation.创建Subagent时的提示信息:
✅ Subagent创建成功!
📁 位置:.agent/subagents/[name].md
🎯 用途:[简要描述]
🔧 调用方式:
- 自动触发:当Agent检测到[对应场景]时自动委托
- 手动触发:/[name] [指令]
💡 提示:在描述中加入“主动使用”等关键词可促进自动委托。