使用 git worktree 隔离实现并行多智能体编程冲刺。适用于在同一仓库中同时运行 2 个以上、涉及不同代码区域的编码任务。
Parallel multi-agent coding sprints using git worktree isolation.
Trigger phrases: "Run a swarm sprint", "Parallel sprint on [repo]", "Use swarm for these tasks"
Before spawning any agents, run the conflict analyzer:
bash
node <skill-dir>/scripts/swarm.js --repo <repo_path> --tasks tasks.json --plan-only
Read the output:
✓ No conflicts → all tasks run in parallel⚠ HIGH conflict → affected tasks auto-serialized into separate groupsLOW conflict → runs parallel, watch the mergeNever skip this step. Two agents modifying the same file = merge conflict = wasted work.
json
[
{
"id": "short-unique-id",
"description": "Exactly what to build — be specific",
"role": "coder",
"successCriteria": ["Specific outcome", "TypeScript compiles clean"]
}
]
bash
node <skill-dir>/scripts/swarm.js --repo <repo_path> --tasks tasks.json --plan-only
bash
node <skill-dir>/scripts/swarm.js --repo <repo_path> --tasks tasks.json
Creates isolated git worktree + branch per task. Writes swarm-packages.json.
Read swarm-packages.json. For each package, spawn a subagent with:
worktreePathinstructions fieldgit add -A && git commit before reporting backbash
git diff main..swarm/<branch-name>
bash
git merge swarm/<branch-name>
Merge one at a time. Verify TypeScript clean after each.
bash
node <skill-dir>/scripts/swarm.js --repo <repo_path> --cleanup swarm-packages.json
Deletes all worktrees and branches. Always run this.
RoleBehaviorcoderImplements task. No unrelated refactoring. Runs tsc when done.reviewerReviews diff skeptically. Flags bugs, type errors, missing error handling.testerWrites tests following existing patterns.
schema.prisma, migration SQLmemory/swarm-log.mdbash
node <skill-dir>/scripts/swarm.js --repo <repo_path> --tasks tasks.json --dry-run