mcpField
S
subagent-creator

subagent-creator

github.com/tech-leads-clubAgent 工作流7.1k915 次安装3 天前更新
代码仓库

关于 subagent-creator

subagent-creator 是用于设计可复用、适配不同 Agent 的子 Agent 的技能。它介绍如何设定职责、元数据、提示词和输出要求,并提供验证与调试等常见角色示例。

主要功能

  1. 01聚焦职责的定义指南
  2. 02Frontmatter 元数据配置
  3. 03提示词结构与输出格式
  4. 04验证和调试 Agent 模式
  5. 05子 Agent 定义质量清单

适用场景

  1. 01创建用于独立审查的验证 Agent
  2. 02定义调试或安全审计专员
  3. 03为团队准备可复用的子 Agent 文件

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/tech-leads-club/agent-skills --skill subagent-creator

安装后在 Claude Code 中输入/subagent-creator确认已加载。

详细介绍

Subagent 创建器

本技能为创建高效、与 Agent 无关的 subagent 提供指导。

什么是 Subagent?

Subagent 是 AI Agent 可以委派任务的专用助手。其特点包括:

  • 上下文隔离:每个 subagent 都有自己的上下文窗口
  • 并行执行:多个 subagent 可以同时运行
  • 专门化:通过特定提示词和专业知识进行配置
  • 可复用:定义一次,可在多个上下文中使用
何时使用 Subagent,何时使用技能
Is the task complex with multiple steps?
├─ YES → Does it require isolated context?
│         ├─ YES → Use SUBAGENT
│         └─ NO → Use SKILL
│
└─ NO → Use SKILL

在以下情况下使用 Subagent:

  • 需要隔离上下文的复杂工作流
  • 适合由专业人员处理的长时间运行任务
  • 验证和审计(独立视角)
  • 并行工作流

在以下情况下使用技能:

  • 快速、一次性操作
  • 无需隔离上下文的领域知识
  • 无需隔离的可复用流程

Subagent 结构

Subagent 通常是带有 frontmatter 元数据的 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 创建流程

1. 定义用途
  • Subagent 具体负责什么?
  • 为什么需要隔离上下文?
  • 是否包含多个复杂步骤?
  • 是否需要深入的专业知识?
2. 配置元数据
name(必需)

唯一标识符。使用 kebab-case。

name: security-auditor
description(关键)

对自动委派至关重要。说明何时使用此 subagent。

良好的描述:

  • “安全专家。实现身份验证、支付功能或处理敏感数据时使用。”
  • “错误和测试失败的调试专家。遇到问题时使用。”
  • “验证已完成的工作。任务标记为完成后使用。”

有助于触发自动委派的短语:

  • “在……时主动使用”
  • “始终用于……”
  • “在……时自动委派”
model(可选)
model: inherit  # Uses same model as parent (default)
model: fast     # Uses fast model for quick tasks
readonly(可选)
readonly: true # Restricts write permissions
3. 编写 Subagent 提示词

定义:

  1. 身份:“你是一位[专家]……”
  2. 调用时机:使用场景
  3. 流程:要遵循的具体步骤
  4. 预期输出:格式和内容

模板:

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]

常见 Subagent 模式

1. 验证 Agent

用途:独立验证已完成的工作是否确实可用。

---
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
2. 调试器

用途:根因分析专家。

---
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
3. 安全审计员

用途:审计代码的安全专家。

---
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)
4. 代码审查员

用途:侧重质量的代码审查。

---
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]

最佳实践

✅ 应做事项
  • 编写专注的 subagent:每个 subagent 只承担一项明确职责
  • 认真撰写描述:描述决定何时委派
  • 保持提示词简洁:直接、具体
  • 与团队共享:对 subagent 定义进行版本控制
  • 测试描述:确认能触发正确的 subagent
❌ 应避免事项
  • 描述含糊:“用于一般任务”没有提供任何提示
  • 提示词过长:2000 个单词不会让它变得更聪明
  • Subagent 过多:从 2-3 个专注的 subagent 开始

质量检查清单

定稿前:

  • 描述明确说明何时委派
  • 名称使用 kebab-case
  • 职责明确且唯一(而非泛泛而谈)
  • 提示词简洁但完整
  • 指令可执行
  • 输出格式定义清楚
  • 模型配置恰当

输出消息

创建 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.

评论

支持 Markdown