agent-creator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAgent Creator for Claude Code
适用于Claude Code的Agent创建工具
Overview
概述
Two distinct agent types in Claude Code:
| Type | Official Name | Communication | Use When |
|---|---|---|---|
| A | Subagent | Hierarchical (parent spawns child) | Autonomous task, delegated by an orchestrator |
| B | Multi-Agent Swarm | Peer-to-peer via sessions (tmux) | Coordinated agents that message each other |
Claude Code中的两种不同Agent类型:
| 类型 | 官方名称 | 通信方式 | 使用场景 |
|---|---|---|---|
| A | Subagent | 层级式(父Agent生成子Agent) | 由编排器委派的自主任务 |
| B | Multi-Agent Swarm | 通过会话(tmux)进行对等通信 | 可相互发送消息的协同Agent |
Step 0: Qualify the User's Intent
步骤0:确认用户意图
Before writing any agent, ask these questions:
- What task should the agent handle?
- Where will it live?
- Project: (shared with all project users)
.claude/agents/ - Global: (personal, all projects)
~/.claude/agents/ - Plugin-bundled: (ships with a skill)
skills/my-skill/agents/
- Project:
- Does it need to communicate with other running Claude Code sessions?
- No → Type A: Subagent
- Yes → Type B: Multi-Agent Swarm
- Permissions: Should it run commands, edit files, or be read-only?
- Should it run in background or block the current session?
在编写任何Agent之前,请询问以下问题:
- 该Agent应处理什么任务?
- 它将存储在何处?
- 项目级:(与项目所有用户共享)
.claude/agents/ - 全局级:(个人使用,适用于所有项目)
~/.claude/agents/ - 插件捆绑:(随Skill一起发布)
skills/my-skill/agents/
- 项目级:
- 它是否需要与其他运行中的Claude Code会话通信?
- 不需要 → 类型A:Subagent
- 需要 → 类型B:Multi-Agent Swarm
- 权限设置:它是否需要运行命令、编辑文件,还是仅为只读权限?
- 它应在后台运行还是阻塞当前会话?
Frontmatter Standard
前置元数据标准
Every agent file must include project metadata (required by this project) and agent configuration fields.
每个Agent文件必须包含项目元数据(本项目要求必填)和Agent配置字段。
Project Metadata (required on all agents)
项目元数据(所有Agent必填)
yaml
created-at: YYYY-MM-DD
created-by: "Firstname Lastname <email@example.com>"
credits: https://... # Optional — only if derived from external workAlways ask the user for their first name, last name, and email before writing the file. Never guess or skip .
created-byyaml
created-at: YYYY-MM-DD
created-by: "Firstname Lastname <email@example.com>"
credits: https://... # 可选 — 仅当基于外部工作衍生时填写在编写文件前,务必向用户询问其姓名和邮箱。切勿猜测或跳过字段。
created-byAgent Configuration Fields
Agent配置字段
| Field | Required | Values | Notes |
|---|---|---|---|
| Yes | | 3–50 chars, start/end alphanumeric |
| Yes | Text + | Primary triggering mechanism |
| No | | Default: |
| No | | UI identifier |
| No | Array of tool names | Omit = all tools |
| No | Array of tool names | Explicitly deny |
| No | | Override permission prompts |
| No | Integer | Cap agentic turns |
| No | | Run without blocking current session |
| No | | Reasoning effort level |
| No | | Isolated git worktree environment |
| No | | Persistent memory scope |
| No | Array of skill paths | Pre-loaded skills at startup |
Color guide: blue/cyan = analysis · green = generation · yellow = validation · red = security · magenta = creative/refactoring
| 字段 | 是否必填 | 可选值 | 说明 |
|---|---|---|---|
| 是 | | 3–50个字符,首尾为字母数字 |
| 是 | 文本 + | 主要触发机制 |
| 否 | | 默认值: |
| 否 | | UI识别标识 |
| 否 | 工具名称数组 | 省略则启用所有工具 |
| 否 | 工具名称数组 | 明确禁用指定工具 |
| 否 | | 覆盖权限提示设置 |
| 否 | 整数 | 限制Agent交互轮次 |
| 否 | | 在不阻塞当前会话的情况下运行 |
| 否 | | 推理努力级别 |
| 否 | | 隔离的git工作树环境 |
| 否 | | 持久化内存范围 |
| 否 | Skill路径数组 | 启动时预加载的Skill |
颜色指南: blue/cyan = 分析 · green = 生成 · yellow = 验证 · red = 安全 · magenta = 创意/重构
Pre-loading Skills (skills
field)
skills预加载Skill(skills
字段)
skillsWhen creating an agent, suggest pre-loading relevant skills from the project. Skills give the agent additional domain expertise at startup.
Discover available skills dynamically — before suggesting anything, scan the project:
1. Glob: **/SKILL.md (search both skills/ and .claude/skills/, wherever they live)
2. For each result, read the `name` and `description` fields from the frontmatter
3. Based on the agent's domain, propose the relevant onesThen ask the user: "Should this agent have any skills pre-loaded?" and show only the ones that match the agent's responsibilities.
Example frontmatter with skills:
yaml
skills:
- skills/react-best-practices
- skills/typescript-advanced-types创建Agent时,建议从项目中预加载相关Skill。Skill可为Agent在启动时提供额外的领域专业知识。
动态发现可用Skill — 在提出建议前,先扫描项目:
1. 全局搜索:**/SKILL.md(搜索skills/和.claude/skills/目录,无论其位置)
2. 对于每个结果,从前置元数据中读取`name`和`description`字段
3. 根据Agent的领域,推荐相关的Skill然后询问用户:“是否需要为该Agent预加载某些Skill?” 并仅展示与Agent职责匹配的Skill。
包含Skill的前置元数据示例:
yaml
skills:
- skills/react-best-practices
- skills/typescript-advanced-typesType A: Subagent
类型A:Subagent
A standalone agent spawned hierarchically. An orchestrator (Claude or another agent) delegates a task to it.
独立的层级式生成Agent。编排器(Claude或其他Agent)将任务委派给它。
File Template
文件模板
markdown
---
created-at: YYYY-MM-DD
created-by: "Firstname Lastname <email@example.com>"
name: my-agent
description: Use this agent when [conditions]. Examples:
<example>
Context: [Situation]
user: "[Request]"
assistant: "[Response using this agent]"
<commentary>
[Why this agent triggers here]
</commentary>
</example>
model: inherit
color: blue
tools: ["Read", "Grep", "Glob"]
---
You are [role] specializing in [domain].
**Your Core Responsibilities:**
1. [Primary responsibility]
2. [Secondary responsibility]
**Process:**
1. [Step 1]
2. [Step 2]
**Output Format:**
[What to produce and how to structure it]markdown
---
created-at: YYYY-MM-DD
created-by: "Firstname Lastname <email@example.com>"
name: my-agent
description: 在[条件]下使用此Agent。示例:
<example>
上下文:[场景]
用户:"[请求]"
助手:"[使用此Agent的响应]"
<commentary>
[此Agent在此处触发的原因]
</commentary>
</example>
model: inherit
color: blue
tools: ["Read", "Grep", "Glob"]
---
你是专注于[领域]的[角色]。
**核心职责:**
1. [主要职责]
2. [次要职责]
**流程:**
1. [步骤1]
2. [步骤2]
**输出格式:**
[需生成的内容及其结构]Invocation
调用方式
undefinedundefinedNatural language — Claude decides
自然语言 — 由Claude决定
Use the my-agent subagent to analyze the codebase
使用my-agent子Agent分析代码库
@-mention — forces this specific agent for one task
@提及 — 强制指定此Agent执行单个任务
@"my-agent (agent)" check the auth module
undefined@"my-agent (agent)" 检查认证模块
undefinedRestricting Which Subagents an Orchestrator Can Spawn
限制编排器可生成的Subagent
In an orchestrator agent's frontmatter, limit spawnable subagents:
yaml
tools: Agent(worker, researcher), Read, Bash在编排器Agent的前置元数据中,限制可生成的Subagent:
yaml
tools: Agent(worker, researcher), Read, BashDescription Best Practices
描述最佳实践
The field is the sole triggering mechanism. Include 2–4 blocks covering:
description<example>- Explicit request (user directly asks)
- Proactive triggering (agent activates after relevant work)
- Variations in phrasing
See for the full guide.
references/triggering-examples.mddescription<example>- 明确请求(用户直接询问)
- 主动触发(Agent在相关工作后激活)
- 表述变体
完整指南请参阅。
references/triggering-examples.mdSystem Prompt Design
系统提示词设计
Write in second person (, ). See for complete patterns (Analysis, Generation, Validation, Orchestration) with structure templates and edge case guidance.
You are...You will...references/system-prompt-design.md使用第二人称撰写(,)。完整模式(分析、生成、验证、编排)及结构模板和边缘情况指导,请参阅。
你是...你将...references/system-prompt-design.mdType B: Multi-Agent Swarm
类型B:Multi-Agent Swarm
Multiple Claude Code sessions coordinating via shared state. Each session runs independently and notifies a coordinator when idle.
多个Claude Code会话通过共享状态进行协同。每个会话独立运行,并在空闲时通知协调器。
When to Use
使用场景
- Tasks that can be parallelized (multiple PRs, multiple services, multiple modules)
- Workflows requiring specialized agents for different phases
- Long-running work exceeding a single session's context
- Independent tasks with explicit dependencies
- 可并行化的任务(多个PR、多个服务、多个模块)
- 不同阶段需要专业Agent的工作流
- 超出单个会话上下文限制的长时间运行任务
- 具有明确依赖关系的独立任务
Architecture
架构
Coordinator session (e.g. "team-leader")
├── Worker session A ("auth-agent") → works on Task 3.5
├── Worker session B ("db-agent") → works on Task 4.2
└── Worker session C ("api-agent") → works on Task 5.1
↕ communicate via tmux send-keys协调器会话(例如"team-leader")
├── 工作者会话A("auth-agent") → 处理任务3.5
├── 工作者会话B("db-agent") → 处理任务4.2
└── 工作者会话C("api-agent") → 处理任务5.1
↕ 通过tmux send-keys进行通信State File
状态文件
Each worker session reads to know its task and coordinator:
.claude/multi-agent-swarm.local.mdyaml
---
agent_name: auth-agent
task_number: 3.5
pr_number: TBD
coordinator_session: team-leader
enabled: true
dependencies: ["Task 3.4"]
additional_instructions: "Use JWT, not sessions"
---每个工作者会话读取以了解其任务和协调器:
.claude/multi-agent-swarm.local.mdyaml
---
agent_name: auth-agent
task_number: 3.5
pr_number: TBD
coordinator_session: team-leader
enabled: true
dependencies: ["Task 3.4"]
additional_instructions: "使用JWT,而非会话"
---Task Assignment: Implement Authentication
任务分配:实现认证功能
Requirements
需求
- JWT token generation and validation
- Refresh token flow
- JWT令牌生成与验证
- 刷新令牌流程
Success Criteria
成功标准
- Auth endpoints pass all tests
- PR created and CI green
- 认证端点通过所有测试
- 创建PR且CI验证通过
Coordination
协同机制
Depends on Task 3.4 (user model).
Report status to coordinator session 'team-leader'.
undefined依赖于任务3.4(用户模型)。
向协调器会话'team-leader'报告状态。
undefinedState File Fields
状态文件字段
| Field | Required | Description |
|---|---|---|
| Yes | Identifier for this agent in the swarm |
| Yes | Task ordering (e.g. |
| Yes | tmux session name of the coordinator |
| Yes | |
| No | Associated PR number |
| No | Task IDs that must complete first |
| No | Per-agent override instructions |
| 字段 | 是否必填 | 描述 |
|---|---|---|
| 是 | 集群中此Agent的标识符 |
| 是 | 任务顺序(例如 |
| 是 | 协调器的tmux会话名称 |
| 是 | |
| 否 | 关联的PR编号 |
| 否 | 必须先完成的任务ID |
| 否 | 针对该Agent的覆盖指令 |
Idle Notification Hook
空闲通知钩子
Add a hook to each worker's that calls a notify script on idle. See → Example 5 for the full block and script.
Stop.claude/settings.jsonexamples/complete-agent-examples.mdsettings.jsonnotify-coordinator.sh在每个工作者的中添加钩子,使其在空闲时调用通知脚本。完整的块和脚本,请参阅 → 示例5。
.claude/settings.jsonStopsettings.jsonnotify-coordinator.shexamples/complete-agent-examples.mdCoordinator System Prompt Pattern
协调器系统提示词模板
You are the coordinator of a multi-agent swarm managing parallel development tasks.
**Your Core Responsibilities:**
1. Assign tasks to worker agents via their tmux sessions
2. Track task dependencies — only assign a task when its dependencies are complete
3. Handle worker notifications (agents message you when idle)
4. Consolidate completed work into a final report
**Coordination Process:**
1. Maintain a backlog of pending tasks with their dependencies
2. When a worker becomes idle: identify the next unblocked task and assign it
3. To assign a task: tmux send-keys -t <session> "<task description>" Enter
4. When all tasks complete: produce a summary of all PRs and outcomes
**State:** Track which tasks are pending/in-progress/done, and which session owns each.你是管理并行开发任务的多Agent集群协调器。
**核心职责:**
1. 通过tmux会话向工作者Agent分配任务
2. 跟踪任务依赖关系 — 仅在依赖任务完成后分配新任务
3. 处理工作者通知(Agent在空闲时向你发送消息)
4. 将已完成的工作整合为最终报告
**协同流程:**
1. 维护带有依赖关系的待处理任务积压
2. 当工作者空闲时:识别下一个未阻塞的任务并分配
3. 分配任务:tmux send-keys -t <session> "<任务描述>" Enter
4. 所有任务完成后:生成所有PR和结果的摘要
**状态跟踪:** 记录哪些任务处于待处理/进行中/已完成状态,以及每个任务所属的会话。Full Swarm Example
完整集群示例
See → "Example 5: Multi-Agent Swarm".
examples/complete-agent-examples.md请参阅 → “示例5:Multi-Agent Swarm”。
examples/complete-agent-examples.mdQuick Reference
快速参考
Which type?
如何选择类型?
Does the agent need to message other running Claude Code sessions?
├── No → Type A: Subagent
│ .claude/agents/my-agent.md
└── Yes → Type B: Multi-Agent Swarm
.claude/multi-agent-swarm.local.md该Agent是否需要与其他运行中的Claude Code会话通信?
├── 不需要 → 类型A:Subagent
│ .claude/agents/my-agent.md
└── 需要 → 类型B:Multi-Agent Swarm
.claude/multi-agent-swarm.local.mdMinimal Subagent
最简Subagent示例
yaml
---
created-at: 2026-03-31
created-by: "Name <email>"
name: my-agent
description: Use this agent when... Examples: <example>...</example>
model: inherit
---
You are an agent that does X.
1. Step one
2. Step two
Output: [what to produce]yaml
---
created-at: 2026-03-31
created-by: "Name <email>"
name: my-agent
description: 在...场景下使用此Agent。示例:<example>...</example>
model: inherit
---
你是一个执行X任务的Agent。
1. 步骤一
2. 步骤二
输出:[需生成的内容]Reference Files
参考文件
- — Patterns for Analysis, Generation, Validation, Orchestration agents
references/system-prompt-design.md - — Writing
references/triggering-examples.mdblocks for reliable triggering<example> - — AI-assisted agent generation prompt
references/agent-creation-system-prompt.md
- — 分析、生成、验证、编排型Agent的模板
references/system-prompt-design.md - — 编写
references/triggering-examples.md块以实现可靠触发的指南<example> - — AI辅助Agent生成提示词
references/agent-creation-system-prompt.md
Example Files
示例文件
- — Production-ready templates (subagents + swarm)
examples/complete-agent-examples.md - — AI-assisted generation workflow
examples/agent-creation-prompt.md
- — 生产就绪模板(Subagent + 集群)
examples/complete-agent-examples.md - — AI辅助生成工作流
examples/agent-creation-prompt.md