Team
Run one increment with N agents in parallel — any vendor, any subscription
(Claude Code, Codex, OpenCode, Cursor, Gemini, a human). Coordination happens
only through committed files: tasks.md (definitions), ledger.jsonl
(append-only state), handoff.md. No message bus, no shared memory; Claude
Code's TeamCreate/Task tools are accelerators, never requirements.
You are the orchestrator
- You plan, split, spawn, watch, merge, close. You do not implement.
- Fan out when domains ≥ 3 or tasks ≥ 15 or the user asked for parallel work; otherwise
sw:do directly.
- One increment, one
tasks.md, one ledger. Do not create per-agent increments.
The 5 rules every agent gets (paste verbatim into each agent prompt)
- One worktree per agent:
git worktree add ../<id>-<agent> -b inc/<id>-<agent> (Claude: claude --worktree <id>-<agent>). Branch name contains the increment id. Set SPECWEAVE_AGENT=<agent> (else id = <tool>@<host>).
- Claim before edit:
specweave task next <id> → specweave task claim T-NN <id>. Edit only that task's Files. Need another file → claim its task or add a task.
- Append only: never edit or delete ledger lines, never edit another task's state line. On a ledger merge conflict keep every line from both sides (
.gitattributes has **/ledger.jsonl merge=union).
- Done needs evidence: commit with the id in the subject, then
specweave task done T-NN <id> --run "<Test>" (exit 0 required). Paste the output in your reply.
- When stopping:
specweave task release --all-mine then specweave handoff <id>.
No CLI on that machine? The agent appends the JSON line itself:
{"t":"T-NN","e":"claim|done|release|block|skip","by":"<agent>","at":"<ISO UTC>","evidence":"<sha + test>","note":"…"}.
Phase 1 — Split (before spawning)
- Read
spec.md once. Confirm tasks.md is in 2.0 form: ### T-NN Title + - AC: … | Files: … | Test: …. If not, rewrite it (this is the only time tasks.md changes structure).
- Files are the ownership unit. Two tasks that touch the same file cannot run in parallel: merge them into one task or add
**Dependencies**: T-NN. Shared contracts (types, API schemas, migrations) go into an early task that everything else depends on.
- Group tasks into lanes (backend / frontend / db / tests / docs …) so each lane's Files are disjoint. Lanes = agents. 2–5 agents; more rarely helps.
- Run
specweave task list <id> — it must show every task open. Commit tasks.md.
Phase 2 — Spawn
For each lane spawn one agent (Claude: Task({ subagent_type: "general-purpose", … }) or a TeamCreate teammate; other vendors: a terminal in the lane's worktree with the prompt below). Prompt template:
You are agent <agent> on increment <id> (<title>). Worktree: <path>. Branch inc/<id>-<agent>.
Your lane: <lane name>. Tasks you may claim: T-NN, T-MM (others belong to other lanes).
Rules: <the 5 rules above>.
Loop: specweave task next <id> → claim → implement inside Files → commit "<id>: …" → task done --run.
Contract: <shared types / API / schema the lane must respect>.
When your tasks are done or you are blocked: task release --all-mine, specweave handoff <id>, then reply with:
DONE: T-NN (sha, test output tail) | BLOCKED: T-MM (reason) | HANDOFF: <handoff.md path>
Agent templates for common lanes live in agents/ (backend, frontend, database, security, testing, pm, architect, researcher, reviewer-security, brainstorm-*). _protocol.md is prepended automatically by specweave team.
Phase 3 — Watch (cheap)
- Poll
specweave task list <id> (or read ledger.jsonl) instead of chatting. blocked rows are your queue: unblock (provide the secret, split the task, decide) and reply to that agent only.
- Stale claim (older than
tasks.leaseHours, default 2h) with no progress → the agent is gone: task claim --force by a replacement agent, or reassign the lane.
- Do not re-read agents' full diffs; read their DONE lines and the ledger evidence.
Phase 4 — Merge
- Every agent has released + handed off. Merge lane branches into the increment branch in dependency order; ledger conflicts resolve by union (keep all lines). tasks.md conflicts: keep both agents' state lines, then
specweave task render <id>.
specweave verify <id> on the merged tree → reports/verify.json. Red → open a fix task, assign one agent, repeat.
sw:review (optional, recommended) on the merged diff → reports/review.md.
specweave complete <id> --yes (add --reason only if the user accepts a red verify). Only the lead closes.
- Remove worktrees:
git worktree remove ../<id>-<agent>.
Other modes (same skeleton, different lanes)
| Mode |
Lanes |
Merge artifact |
| brainstorm |
advocate / critic / pragmatist (see agents/brainstorm-*.md) |
reports/brainstorm.md, then sw:increment |
| plan |
pm (spec.md) + architect (Approach/plan.md) in parallel |
reviewed spec.md before any task is claimed |
| review |
correctness / security / spec-compliance lenses (sw:review --full runs these) |
reports/review.md |
| research |
one topic per agent |
reports/research-<topic>.md |
| test |
unit / integration / e2e |
specweave verify commands in testing.commands |
Anti-patterns
- Agents editing files outside their task's
Files ("I just fixed a typo there") — that is how merges break. Add a task.
- Marking
[x] in tasks.md by hand. The ledger wins; task render overwrites it.
- Per-agent increments to avoid conflicts — you lose the single ledger and the single verify.
- The lead implementing "just this small piece". Spawn an agent or finish the team first.
- Closing while a claim is live. Wait for release/handoff or take it over explicitly.
Resources
1---2name: team3description: Run one increment with several agents in parallel - a worktree each, claims through the ledger, one closure. Use when the work has 3+ disjoint lanes, or when saying "team" or "parallel agents".4---56# Team78Run one increment with N agents in parallel — **any vendor, any subscription**9(Claude Code, Codex, OpenCode, Cursor, Gemini, a human). Coordination happens10only through committed files: `tasks.md` (definitions), `ledger.jsonl`11(append-only state), `handoff.md`. No message bus, no shared memory; Claude12Code's TeamCreate/Task tools are accelerators, never requirements.1314## You are the orchestrator1516- You plan, split, spawn, watch, merge, close. You do **not** implement.17- Fan out when domains ≥ 3 or tasks ≥ 15 or the user asked for parallel work; otherwise `sw:do` directly.18- One increment, one `tasks.md`, one ledger. Do not create per-agent increments.1920## The 5 rules every agent gets (paste verbatim into each agent prompt)21221. **One worktree per agent**: `git worktree add ../<id>-<agent> -b inc/<id>-<agent>` (Claude: `claude --worktree <id>-<agent>`). Branch name contains the increment id. Set `SPECWEAVE_AGENT=<agent>` (else id = `<tool>@<host>`).232. **Claim before edit**: `specweave task next <id>` → `specweave task claim T-NN <id>`. Edit only that task's `Files`. Need another file → claim its task or add a task.243. **Append only**: never edit or delete ledger lines, never edit another task's state line. On a ledger merge conflict keep every line from both sides (`.gitattributes` has `**/ledger.jsonl merge=union`).254. **Done needs evidence**: commit with the id in the subject, then `specweave task done T-NN <id> --run "<Test>"` (exit 0 required). Paste the output in your reply.265. **When stopping**: `specweave task release --all-mine` then `specweave handoff <id>`.2728No CLI on that machine? The agent appends the JSON line itself:29`{"t":"T-NN","e":"claim|done|release|block|skip","by":"<agent>","at":"<ISO UTC>","evidence":"<sha + test>","note":"…"}`.3031## Phase 1 — Split (before spawning)32331. Read `spec.md` once. Confirm `tasks.md` is in 2.0 form: `### T-NN Title` + `- AC: … | Files: … | Test: …`. If not, rewrite it (this is the only time tasks.md changes structure).342. **Files are the ownership unit.** Two tasks that touch the same file cannot run in parallel: merge them into one task or add `**Dependencies**: T-NN`. Shared contracts (types, API schemas, migrations) go into an early task that everything else depends on.353. Group tasks into lanes (backend / frontend / db / tests / docs …) so each lane's Files are disjoint. Lanes = agents. 2–5 agents; more rarely helps.364. Run `specweave task list <id>` — it must show every task `open`. Commit `tasks.md`.3738## Phase 2 — Spawn3940For each lane spawn one agent (Claude: `Task({ subagent_type: "general-purpose", … })` or a TeamCreate teammate; other vendors: a terminal in the lane's worktree with the prompt below). Prompt template:4142```43You are agent <agent> on increment <id> (<title>). Worktree: <path>. Branch inc/<id>-<agent>.44Your lane: <lane name>. Tasks you may claim: T-NN, T-MM (others belong to other lanes).45Rules: <the 5 rules above>.46Loop: specweave task next <id> → claim → implement inside Files → commit "<id>: …" → task done --run.47Contract: <shared types / API / schema the lane must respect>.48When your tasks are done or you are blocked: task release --all-mine, specweave handoff <id>, then reply with:49 DONE: T-NN (sha, test output tail) | BLOCKED: T-MM (reason) | HANDOFF: <handoff.md path>50```5152Agent templates for common lanes live in `agents/` (backend, frontend, database, security, testing, pm, architect, researcher, reviewer-security, brainstorm-*). `_protocol.md` is prepended automatically by `specweave team`.5354## Phase 3 — Watch (cheap)5556- Poll `specweave task list <id>` (or read `ledger.jsonl`) instead of chatting. `blocked` rows are your queue: unblock (provide the secret, split the task, decide) and reply to that agent only.57- Stale claim (older than `tasks.leaseHours`, default 2h) with no progress → the agent is gone: `task claim --force` by a replacement agent, or reassign the lane.58- Do not re-read agents' full diffs; read their DONE lines and the ledger evidence.5960## Phase 4 — Merge61621. Every agent has released + handed off. Merge lane branches into the increment branch in dependency order; ledger conflicts resolve by union (keep all lines). tasks.md conflicts: keep both agents' state lines, then `specweave task render <id>`.632. `specweave verify <id>` on the merged tree → `reports/verify.json`. Red → open a fix task, assign one agent, repeat.643. `sw:review` (optional, recommended) on the merged diff → `reports/review.md`.654. `specweave complete <id> --yes` (add `--reason` only if the user accepts a red verify). Only the lead closes.665. Remove worktrees: `git worktree remove ../<id>-<agent>`.6768## Other modes (same skeleton, different lanes)6970| Mode | Lanes | Merge artifact |71|---|---|---|72| brainstorm | advocate / critic / pragmatist (see `agents/brainstorm-*.md`) | `reports/brainstorm.md`, then `sw:increment` |73| plan | pm (spec.md) + architect (Approach/plan.md) in parallel | reviewed spec.md before any task is claimed |74| review | correctness / security / spec-compliance lenses (`sw:review --full` runs these) | `reports/review.md` |75| research | one topic per agent | `reports/research-<topic>.md` |76| test | unit / integration / e2e | `specweave verify` commands in `testing.commands` |7778## Anti-patterns7980- Agents editing files outside their task's `Files` ("I just fixed a typo there") — that is how merges break. Add a task.81- Marking `[x]` in tasks.md by hand. The ledger wins; `task render` overwrites it.82- Per-agent increments to avoid conflicts — you lose the single ledger and the single verify.83- The lead implementing "just this small piece". Spawn an agent or finish the team first.84- Closing while a claim is live. Wait for release/handoff or take it over explicitly.8586## Resources8788- `specweave task --help`, `specweave verify --help`, `specweave handoff --help`89- [Official Documentation](https://verified-skill.com/docs/reference/skills#team)