spawn
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese/hub:spawn — Launch Parallel Agents
/hub:spawn — 启动并行Agent
Spawn N subagents that work on the same task in parallel, each in an isolated git worktree.
在独立的git worktree中生成N个并行处理同一任务的子Agent。
Usage
使用方法
/hub:spawn # Spawn agents for the latest session
/hub:spawn 20260317-143022 # Spawn agents for a specific session
/hub:spawn --template optimizer # Use optimizer template for dispatch prompts
/hub:spawn --template refactorer # Use refactorer template/hub:spawn # 为最新会话生成Agent
/hub:spawn 20260317-143022 # 为指定会话生成Agent
/hub:spawn --template optimizer # 使用optimizer模板生成调度提示词
/hub:spawn --template refactorer # 使用refactorer模板Templates
模板
When is provided, use the dispatch prompt from instead of the default prompt below. Available templates:
--template <name>references/agent-templates.md| Template | Pattern | Use Case |
|---|---|---|
| Edit → eval → keep/discard → repeat x10 | Performance, latency, size reduction |
| Restructure → test → iterate until green | Code quality, tech debt |
| Write tests → measure coverage → repeat | Test coverage gaps |
| Reproduce → diagnose → fix → verify | Bug fix with competing approaches |
When using a template, replace all with values from the session config. Assign each agent a different strategy appropriate to the template and task — diverse strategies maximize the value of parallel exploration.
{variables}当使用参数时,将使用中的调度提示词,而非下方的默认提示词。可用模板:
--template <name>references/agent-templates.md| 模板 | 模式 | 使用场景 |
|---|---|---|
| 编辑 → 评估 → 保留/舍弃 → 重复10次 | 性能优化、延迟降低、体积缩减 |
| 重构 → 测试 → 迭代直至通过 | 代码质量提升、技术债务处理 |
| 编写测试 → 度量覆盖率 → 重复 | 测试覆盖率缺口填补 |
| 复现 → 诊断 → 修复 → 验证 | 采用多种方案修复Bug |
使用模板时,需将所有替换为会话配置中的值。为每个Agent分配不同的策略,使其适配模板与任务——多样化策略能最大化并行探索的价值。
{variables}What It Does
工作流程
- Load session config from
.agenthub/sessions/{session-id}/config.yaml - For each agent 1..N:
- Write task assignment to
.agenthub/board/dispatch/ - Build agent prompt with task, constraints, and board write instructions
- Write task assignment to
- Launch ALL agents in a single message with multiple Agent tool calls:
Agent(
prompt: "You are agent-{i} in hub session {session-id}.
Your task: {task}
Read your full assignment at .agenthub/board/dispatch/{seq}-agent-{i}.md
Instructions:
1. Work in your worktree — make changes, run tests, iterate
2. Commit all changes with descriptive messages
3. Write your result summary to .agenthub/board/results/agent-{i}-result.md
Include: approach taken, files changed, metric if available, confidence level
4. Exit when done
Constraints:
- Do NOT read or modify other agents' work
- Do NOT access .agenthub/board/results/ for other agents
- Commit early and often with descriptive messages
- If you hit a dead end, commit what you have and explain in your result",
isolation: "worktree"
)- Update session state to via:
running
bash
python {skill_path}/scripts/session_manager.py --update {session-id} --state running- 从加载会话配置
.agenthub/sessions/{session-id}/config.yaml - 为每个Agent(1..N)执行以下操作:
- 将任务分配写入
.agenthub/board/dispatch/ - 结合任务、约束条件和看板写入指令构建Agent提示词
- 将任务分配写入
- 在单条消息中启动所有Agent,包含多个Agent工具调用:
Agent(
prompt: "你是hub会话{session-id}中的agent-{i}。
你的任务:{task}
请在.agenthub/board/dispatch/{seq}-agent-{i}.md查看完整任务分配
指令:
1. 在你的worktree中工作——修改代码、运行测试、迭代优化
2. 提交所有更改并添加描述性提交信息
3. 将结果摘要写入.agenthub/board/results/agent-{i}-result.md
内容需包含:采用的方案、修改的文件、可用指标、置信度
4. 完成后退出
约束:
- 请勿读取或修改其他Agent的工作内容
- 请勿访问其他Agent的.agenthub/board/results/目录
- 尽早并频繁提交,提交信息需具有描述性
- 若陷入瓶颈,提交已完成的工作并在结果中说明原因",
isolation: "worktree"
)- 通过以下命令将会话状态更新为:
running
bash
python {skill_path}/scripts/session_manager.py --update {session-id} --state runningCritical Rules
关键规则
- All agents in ONE message — spawn all Agent tool calls simultaneously for true parallelism
- isolation: "worktree" is mandatory — each agent needs its own filesystem
- Never modify session config after spawn — agents rely on stable configuration
- Each agent gets a unique board post — dispatch posts are numbered sequentially
- 所有Agent在单条消息中启动——同时生成所有Agent工具调用以实现真正的并行
- isolation: "worktree"为必填项——每个Agent需要独立的文件系统
- 生成后请勿修改会话配置——Agent依赖稳定的配置信息
- 每个Agent对应唯一的看板帖子——调度帖子按顺序编号
After Spawn
生成后操作
Tell the user:
- {N} agents launched in parallel
- Each working in an isolated worktree
- Monitor with
/hub:status - Evaluate when done with
/hub:eval
告知用户:
- 已并行启动{N}个Agent
- 每个Agent在独立的worktree中工作
- 使用监控状态
/hub:status - 完成后使用进行评估
/hub:eval