SKILL.md--- name: agent-teams description: Coordinate multiple Claude Code sessions as a team — lead + teammates with shared task lists, mailbox messaging, and file-lock claiming. Patterns for team sizing, task decomposition, and when to use teams vs sub-agents vs worktrees. user-invocable: true --- # Agent Teams Coordinate multiple Claude Code sessions working on the same codebase simultaneously. ## Enable ```bash export CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 claude # starts as team lead ``` The first session becomes the team lead. Subsequent sessions in the same repo join as teammates. ## Architecture ```text Team Lead (coordinates, delegates, reviews) ├── Teammate 1 (owns task A, messages lead + peers) ├── Teammate 2 (owns task B, messages lead + peers) └── Teammate 3 (owns task C, messages lead + peers) │ └── Shared: task list + mailbox + file locks ``` **Key difference from subagents:** Teammates are full Claude Code sessions. They have their own context window, can use all tools, and message each other directly — not just report back to a parent. ## Team Sizing | Team Size | Best For | |-----------|----------| | 2 | One builds, one reviews | | 3-5 | Parallel features across layers (API, UI, tests) | | > 5 | Coordination overhead outweighs parallelism | 3-5 teammates is the productive range. Beyond that, the lead spends more time coordinating than the team saves. **Task granularity:** Aim for 5-6 tasks per teammate. Fewer means underutilization; more means excessive context switching. ## Display Modes **In-process navigation:** - `Shift+Down` — cycle through teammates (wraps around) - See each teammate's current task and output **Split-pane (recommended for >2 teammates):** - tmux: `tmux split-window -h` per teammate - iTerm2: Cmd+D for vertical split - Each pane runs its own `claude` session ## Task Management Tasks flow through states: ```text pending → in-progress → completed │ └── blocked (waiting on dependency) ``` ### Task Decomposition Break work into units that: - Touch non-overlapping files - Can be verified independently - Have clear done criteria **Good decomposition:** ```text Task 1: Add rate limiting middleware (src/middleware/rate-limit.ts) Task 2: Add rate limit tests (tests/rate-limit.test.ts) Task 3: Update API docs for rate limit headers (docs/api.md) Task 4: Add Redis config for rate limit store (src/config/redis.ts) ``` **Bad decomposition:** ```text Task 1: Implement rate limiting Task 2: Fix rate limiting bugs Task 3: Improve rate limiting ``` ### Dependencies Tasks can declare dependencies: ```text Task 3 (API docs) → depends on Task 1 (middleware) Task 2 (tests) → depends on Task 1 (middleware) Task 4 (Redis config) → no dependencies ``` Teammates pick up unblocked tasks automatically. ## File-Lock Claiming Teammates claim files before editing to prevent conflicts: 1. Teammate checks if file is locked 2. If free, claims it (fi