Advanced patterns for Claude Code Agent Teams — topology design, cross-team communication, worktree coordination, failure handling, and cost management
From claude-code-expertnpx claudepluginhub markus41/claude --plugin claude-code-expertThis skill is limited to using the following tools:
examples/pr-review-board.mdtemplate.mdSearches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Enables AI agents to execute x402 payments with per-task budgets, spending controls, and non-custodial wallets via MCP tools. Use when agents pay for APIs, services, or other agents.
Claude Code Agent Teams enable parallel multi-agent coordination within a shared task context. This skill covers production-grade patterns for designing, scaling, and debugging agent team topologies.
Enablement:
CLAUDE_ENABLE_TEAMS=true--enable-teams flag to Claude Code CLIHow teams differ from subagents:
One lead assigns work to teammates and collects results.
┌─────────┐
│ Lead │
└────┬────┘
┌────┴────┬─────────┬─────────┐
│ │ │ │ │ │ │
▼ ▼ ▼ ▼ ▼ ▼ ▼
Team1 Team2 Team3 Team4 Team5 Team6
All teammates can message each other directly. Useful for truly parallel, interdependent work.
┌──────────────────────────┐
│ │
▼ ▼
Team1 ◄──────────────────► Team2
│ │
│ ◄──────────────────► │
│ │
└──────────►Team3◄─────────┘
◄────────┐ │ ┌───────────►
│ │ │
Self-Claim Queue
Work moves through stages. Each stage completes before passing to the next.
Team leads manage sub-teams. Useful for large organizations.
All teammates can view, claim, and complete tasks from a shared queue.
Direct messages between teammates for synchronous coordination.
Teammate1 → "Finished schema, Team2 can now generate tests"
Teammate2 → "Tests running, Team3 estimate for performance review?"
Teammate3 → "Ready when schema is final—what's your ETA?"
Periodic updates visible to entire team (every 5-10 minutes).
When two teammates claim the same task:
Each teammate gets an isolated git worktree, preventing merge conflicts during work.
Worktree naming:
# Automatic naming by team ID and teammate index
.git/worktrees/team-{team_id}-{teammate_index}/
Merge strategy on completion:
Conflict handling:
Branch naming conventions:
feature/{team-id}/{teammate-role}
examples: feature/cce-001/frontend, feature/cce-001/backend
bugfix/{team-id}/{issue-number}
examples: bugfix/cce-002/123, bugfix/cce-002/456
| Size | Characteristics | Best For | Cost |
|---|---|---|---|
| 2 | Minimal coordination overhead. Ideal split: frontend + backend, or analyzer + implementer. | Feature branches, migrations | 2x single-agent cost |
| 3-4 | Sweet spot for most projects. Independent parallel tracks. Light coordination. | Full-stack features, multi-phase analysis | 3-4x single-agent cost |
| 5+ | Coordination overhead grows. Task switching between teammates. Diminishing returns. | Enterprise projects, research teams | 5x+ but not linearly valuable |
Cost scaling:
Cost-benefit formula:
TeamCost = (team_size × hourly_rate_per_agent)
Speedup = 100% / (1 + coordination_overhead)
ROI = (sequential_time - (team_time × speedup)) / TeamCost
→ ROI > 0 when team_time * speedup < sequential_time
When teammate A's failure blocks teammate B (dependency).
All teammates down or unresponsive.
# Check teammate status
claude-code teams status --team-id cce-001
# Output:
# ┌─────────────┬────────────┬──────┬─────────────┐
# │ Teammate │ Status │ Task │ Last Update │
# ├─────────────┼────────────┼──────┼─────────────┤
# │ Frontend │ RUNNING │ 5/12 │ 2m ago │
# │ Backend │ COMPLETED │ 8/8 │ 5m ago │
# │ Tests │ STALLED │ 2/6 │ 10m ago │
# └─────────────┴────────────┴──────┴─────────────┘
Define team compositions beyond built-in templates using a team configuration file.
Example: Custom 3-person migration team
version: 1
name: "Database Migration"
description: "Schema analyzer, data migrator, validator"
team:
- name: "analyzer"
role: "Database schema analysis"
model: "claude-sonnet-4-6"
skills:
- sql-analysis
- schema-design
timeout_seconds: 1800
- name: "migrator"
role: "Data migration execution"
model: "claude-sonnet-4-6"
skills:
- data-migration
- transformation-engine
timeout_seconds: 3600
- name: "validator"
role: "Post-migration verification"
model: "claude-haiku-4-5"
skills:
- data-validation
- integrity-checking
timeout_seconds: 900
communication: "mesh"
task_strategy: "shared_queue"
parallelization: "full"
→ Parallel development with synchronized handoffs
→ High confidence, rapid migrations
→ Fast incident turnaround
→ Cover more ground in parallel research
→ Parallel review perspectives
Base cost = (num_teammates × model_cost_per_hour) × estimated_duration_hours
Example: 3 Sonnet agents × $15/hour × 2 hours = $90
vs.
Sequential cost = 1 Sonnet × $15/hour × 6 hours = $90
Speedup: 3 agents complete in 2 hours vs. 6 sequential → 3x faster, same cost
YES, use teams if:
NO, use sequential if:
See also: teams-architect agent for interactive team design assistance.