Agent Teams
Agent teams coordinate multiple Claude Code instances working in parallel. One session acts as team lead (coordinator); others are teammates (workers), each with its own context window. Teammates can communicate directly with each other — unlike subagents, which only report back to the parent. Enable:CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 in settings.json env block.
Architecture
State stored locally:
- Team config:
~/.claude/teams/{team-name}/config.json - Task list:
~/.claude/tasks/{team-name}/
When to Use Teams (vs Subagents)
Use subagents when: workers only need to report results back; no inter-agent coordination required; lower token budget. Use agent teams when:- Teammates need to challenge each other’s findings (competing hypotheses debugging)
- Parallel research across independent domains
- Cross-layer changes (frontend / backend / tests each owned by a different teammate)
- New module development with non-overlapping file ownership
Starting a Team
Task Management
Tasks have states:pending | in-progress | completed. Tasks can depend on other tasks (blocked until dependency completes). Claiming uses file locking to prevent race conditions.
Lead assigns or teammates self-claim after finishing current task.
Quality Gate Hooks
TeammateIdle: exit 2 to send feedback and keep teammate working.
TaskCompleted: exit 2 to block completion and request more work.
TaskCreated: exit 2 to reject task creation.
Using Subagent Definitions as Teammates
Define roles once in~/.claude/agents/ or .claude/agents/, reuse in both subagent and teammate contexts:
tools allowlist and model. Definition body appended to teammate system prompt. skills and mcpServers frontmatter NOT applied in teammate mode.
Parallel Code Review Pattern (wshobson-derived)
Competing Hypotheses Debugging
Best Practices
- Give teammates context in spawn prompt — they don’t inherit lead’s conversation history. Include: file paths, constraints, what “done” means.
- Avoid file conflicts — each teammate should own a distinct set of files.
- 3–5 teammates — beyond ~5, coordination overhead and token cost outweigh benefits.
- Monitor and steer — don’t let teams run unattended too long; redirect approaches that aren’t working.
- Clean up properly —
Clean up the teamtells the lead to remove shared resources. Always use the lead, not a teammate, to run cleanup.
Display Modes
- In-process (default): teammates run in main terminal. Shift+Down cycles through them.
- Split panes: requires tmux or iTerm2. Each teammate in its own pane. Set
"teammateMode": "tmux"in settings.json.
Known Limitations (experimental)
- No session resumption with in-process teammates
- Task status can lag (may need manual nudge)
- One team per session (lead is fixed for team lifetime)
- No nested teams (teammates can’t spawn their own teams)
- Split panes not supported in VS Code terminal, Windows Terminal, Ghostty
Agent View — Background Sessions UI
claude agents — full-screen TUI (CC v2.1.139+, research preview) listing all background sessions grouped by state. Distinct from agent teams: shows individual background sessions, not coordinated teammates.
Session states: Working (animated), Needs input (yellow), Idle (dimmed), Completed (green), Failed (red), Stopped (grey).
Key operations:
Space(Peek): shows what session needs/produced; type reply and press Enter without attachingEnter/→(Attach): full interactive session;←on empty prompt to detach/bgor/backgroundfrom inside session;claude --bg "<prompt>"from shellclaude attach <id>,claude logs <id>,claude stop <id>,claude respawn <id>
.claude/worktrees/ before editing. Worktree removed on session delete — push/commit first.
Supervisor process: background sessions hosted by a per-user supervisor. Starts automatically; sessions survive terminal close. Sessions stop on machine sleep — resume with claude respawn --all. State at ~/.claude/daemon.log, ~/.claude/daemon/roster.json, ~/.claude/jobs/<id>/state.json.
PR status dots: yellow (checks failing/pending), green (checks passed), purple (merged), grey (draft/closed).
Row summaries: generated by a Haiku-class model; describes what the session is doing without opening the transcript. Refreshes at most every 15 seconds while active.
Related Pages
- Agent Subagents — subagents and when to prefer them over teams
- Agent Harness — harness components; teams as the highest coordination layer
- Context Degradation Patterns — why each teammate needs its own context window
- Worktree Isolation — worktrees as the alternative for long-running parallel tasks (>30 min)
- Shared Task Queue (Cross-Worktree) — filesystem inbox for cross-worktree coordination; pull model alternative to in-process task list