/team — Native Claude Code Teams Orchestrator
/team <goal> runs the closed-loop multi-agent protocol from ~/.claude/rules/agent-team-os.md end-to-end with native primitives. Replaces Shipwright; depends only on the Claude Code harness.
The protocol you run
1. SCOPE — distill goal into 3–8 testable contracts (with user)
2. PLAN — write the plan; identify which contracts are independent (parallel) vs sequential
3. SPAWN — Agent tool with isolation: worktree, model: sonnet, tools scoped to role
4. WATCH — TodoWrite tracks tasks; agents report back via TaskUpdate
5. VERIFY — for each task close, spawn verifier (model: sonnet)
6. CRITIQUE — every N completions, spawn critic to find half-fixes & cross-agent regressions
7. REFLEX — recurring failures from same agent → spawn agent-tuner with /tune-agent
8. MERGE — git diff each worktree, merge sequentially with tests between, surface conflicts
9. CLOSE — write closing report + update knowledge + run /mine-transcripts on this session
Hard rules
- Never call
TeamDelete, git worktree remove, or ExitWorktree until after all branches are merged. See rules/worktree-merge-before-cleanup.md.
- Never mark a task complete without
RESULT_verifier=PASS.
- Never skip the critic on the closure of CRITICAL or REGRESSION-tagged tasks.
- Always keep the active task list in
TodoWrite — every spawn updates it.
- Always report cost+token totals in the closing summary. If the run cost >$10, flag it.
Step-by-step
Step 1 — Scope (with user)
- Distill the goal into 3–8 testable contracts. Each contract is one sentence: "X must do Y when Z."
- If you can't list ≥3 contracts, the goal is too small for /team — just do it.
- Confirm with the user before spawning anyone.
Step 2 — Plan
- Group contracts into independent vs sequential clusters.
- For each cluster, decide: which specialist(s) handle this?
- General task →
general-purpose
- Migration →
migration-planner
- Bug regression →
regression-hunter
- Perf →
latency-profiler
- Security →
security-reviewer
- (See
~/.claude/agents/ for the full roster — match agent description to task.)
- Write the plan inline in this conversation. Don't burn context with a separate plan file unless the user wants one.
Step 3 — Spawn
For each independent unit:
Agent({
description: "<short description>",
subagent_type: "general-purpose", // or specialist
isolation: "worktree", // ALWAYS for implementation tasks
prompt: "..." // include: contract, file paths, no-go zones, when to /verify
})
For parallel dispatch: emit multiple Agent calls in a SINGLE message. Don't sequentially await unless there's a real dependency.
Step 4 — Watch
TodoWrite immediately after spawn: each task in_progress
- When an agent reports back, mark its task completed (after verify passes)
- If the user asks for a status, just
TodoWrite view + a 2-line summary
Step 5 — Verify (per task close)
- Spawn
/verify (which spawns the verifier agent)
- Read
RESULT_verifier=...
- PASS →
TodoWrite mark complete
- FAIL → keep task open, surface the failure, prompt the responsible agent to fix
- INCONCLUSIVE → escalate to user; do not silently pass
Step 6 — Critique (every 3 completions, or at fleet end)
- Spawn the
critic agent (read-only) with the list of just-completed tasks
- Critic returns CRITICAL / HIGH / MED findings; CRITICAL ones become new tasks (CRITIC- prefix)
- Critic also checks for cross-agent regressions: did Agent A's change break Agent B's work?
Step 7 — Reflexion (only if pattern emerges)
- If verifier or critic finds the SAME failure mode from the SAME agent twice, that's a tuning candidate
- Spawn
/tune-agent <agent-name> with the failure evidence
- It proposes a prompt patch; you (lead) approve or reject
- Approved patches land in the agent's
.md with backup at ~/.claude/agents/.history/
Step 8 — Merge
git worktree list shows all branches
- For each:
git diff <main>..<branch>, then merge
- After every merge, run the project's test suite — surface failures immediately
- DO NOT remove worktrees until all merges complete
Step 9 — Close
- Write a closing report to the conversation:
- Goal recap, contracts satisfied (link to evidence)
- Tasks: completed / deferred (with reason)
- Critic findings: addressed / accepted as known issues
- Cost / tokens / wall time
- Lessons learned (auto-extracted from this session)
- Run
/mine-transcripts --since 1h to capture this fleet's lessons
- Update
~/.claude/knowledge/connections/ if a new architectural insight emerged
Output discipline
- Status updates: 2 lines max per teammate update — don't paste their work back to the user
- Use
TodoWrite as the source of truth, not chat narration
- Closing report under 500 words
Common failure modes you must avoid
- Spawning a fleet for a 1-hour task — overhead exceeds value
- Spawning agents without contracts — they thrash because they can't tell when they're done
- Skipping verifier because "it obviously works" — that exact phrase has cost users tens of hours
- Removing worktrees before merge — destroys all the agent's work
- Critic running on unrelated work — scope the critic to just-closed tasks
- Letting the critic loop run forever — cap at 3 critic passes; remaining findings become explicit deferred tasks
1---2name: team3description: Spin up a native Claude Code Teams fleet to tackle a multi-step task — lead orchestrates, specialists work in parallel worktrees, critic + verifier loop guards quality. Use when the task has 3+ independent sub-tasks, when you need different specialists, or when isolation between concerns is required. Triggers on /team, "spin up a team", "fan out", "fleet this".4---56# /team — Native Claude Code Teams Orchestrator78`/team <goal>` runs the closed-loop multi-agent protocol from `~/.claude/rules/agent-team-os.md` end-to-end with native primitives. Replaces Shipwright; depends only on the Claude Code harness.910## The protocol you run1112```131. SCOPE — distill goal into 3–8 testable contracts (with user)142. PLAN — write the plan; identify which contracts are independent (parallel) vs sequential153. SPAWN — Agent tool with isolation: worktree, model: sonnet, tools scoped to role164. WATCH — TodoWrite tracks tasks; agents report back via TaskUpdate175. VERIFY — for each task close, spawn verifier (model: sonnet)186. CRITIQUE — every N completions, spawn critic to find half-fixes & cross-agent regressions197. REFLEX — recurring failures from same agent → spawn agent-tuner with /tune-agent208. MERGE — git diff each worktree, merge sequentially with tests between, surface conflicts219. CLOSE — write closing report + update knowledge + run /mine-transcripts on this session22```2324## Hard rules2526- **Never** call `TeamDelete`, `git worktree remove`, or `ExitWorktree` until **after** all branches are merged. See `rules/worktree-merge-before-cleanup.md`.27- **Never** mark a task complete without `RESULT_verifier=PASS`.28- **Never** skip the critic on the closure of CRITICAL or REGRESSION-tagged tasks.29- **Always** keep the active task list in `TodoWrite` — every spawn updates it.30- **Always** report cost+token totals in the closing summary. If the run cost >$10, flag it.3132## Step-by-step3334### Step 1 — Scope (with user)35- Distill the goal into 3–8 testable contracts. Each contract is one sentence: "X must do Y when Z."36- If you can't list ≥3 contracts, the goal is too small for /team — just do it.37- Confirm with the user before spawning anyone.3839### Step 2 — Plan40- Group contracts into independent vs sequential clusters.41- For each cluster, decide: which specialist(s) handle this?42 - General task → `general-purpose`43 - Migration → `migration-planner`44 - Bug regression → `regression-hunter`45 - Perf → `latency-profiler`46 - Security → `security-reviewer`47 - (See `~/.claude/agents/` for the full roster — match agent description to task.)48- Write the plan inline in this conversation. Don't burn context with a separate plan file unless the user wants one.4950### Step 3 — Spawn51For each independent unit:5253```54Agent({55 description: "<short description>",56 subagent_type: "general-purpose", // or specialist57 isolation: "worktree", // ALWAYS for implementation tasks58 prompt: "..." // include: contract, file paths, no-go zones, when to /verify59})60```6162For parallel dispatch: emit multiple `Agent` calls in a SINGLE message. Don't sequentially await unless there's a real dependency.6364### Step 4 — Watch65- `TodoWrite` immediately after spawn: each task in_progress66- When an agent reports back, mark its task completed (after verify passes)67- If the user asks for a status, just `TodoWrite` view + a 2-line summary6869### Step 5 — Verify (per task close)70- Spawn `/verify` (which spawns the `verifier` agent)71- Read `RESULT_verifier=...`72- PASS → `TodoWrite` mark complete73- FAIL → keep task open, surface the failure, prompt the responsible agent to fix74- INCONCLUSIVE → escalate to user; do not silently pass7576### Step 6 — Critique (every 3 completions, or at fleet end)77- Spawn the `critic` agent (read-only) with the list of just-completed tasks78- Critic returns CRITICAL / HIGH / MED findings; CRITICAL ones become new tasks (CRITIC- prefix)79- Critic also checks for cross-agent regressions: did Agent A's change break Agent B's work?8081### Step 7 — Reflexion (only if pattern emerges)82- If verifier or critic finds the SAME failure mode from the SAME agent twice, that's a tuning candidate83- Spawn `/tune-agent <agent-name>` with the failure evidence84- It proposes a prompt patch; you (lead) approve or reject85- Approved patches land in the agent's `.md` with backup at `~/.claude/agents/.history/`8687### Step 8 — Merge88- `git worktree list` shows all branches89- For each: `git diff <main>..<branch>`, then merge90- After every merge, run the project's test suite — surface failures immediately91- DO NOT remove worktrees until all merges complete9293### Step 9 — Close94- Write a closing report to the conversation:95 - Goal recap, contracts satisfied (link to evidence)96 - Tasks: completed / deferred (with reason)97 - Critic findings: addressed / accepted as known issues98 - Cost / tokens / wall time99 - Lessons learned (auto-extracted from this session)100- Run `/mine-transcripts --since 1h` to capture this fleet's lessons101- Update `~/.claude/knowledge/connections/` if a new architectural insight emerged102103## Output discipline104105- Status updates: 2 lines max per teammate update — don't paste their work back to the user106- Use `TodoWrite` as the source of truth, not chat narration107- Closing report under 500 words108109## Common failure modes you must avoid1101111. **Spawning a fleet for a 1-hour task** — overhead exceeds value1122. **Spawning agents without contracts** — they thrash because they can't tell when they're done1133. **Skipping verifier because "it obviously works"** — that exact phrase has cost users tens of hours1144. **Removing worktrees before merge** — destroys all the agent's work1155. **Critic running on unrelated work** — scope the critic to just-closed tasks1166. **Letting the critic loop run forever** — cap at 3 critic passes; remaining findings become explicit deferred tasks