Agent teams advanced

From markus41/claude · View interactive version

Agent teams advanced is an AI agent skill from the GitHub repository markus41/claude. Advanced patterns for Claude Code Agent Teams — topology design, cross-team communication, worktree coordination, failure handling, and cost management

How to use this skill

Skill file

Agent Teams Advanced Patterns

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.

Agent Teams Mechanics

Enablement:

How teams differ from subagents:

Team Topology Patterns

Hub-and-Spoke (Lead-Driven)

One lead assigns work to teammates and collects results.

      ┌─────────┐
      │  Lead   │
      └────┬────┘
      ┌────┴────┬─────────┬─────────┐
      │    │    │    │    │    │    │
      ▼    ▼    ▼    ▼    ▼    ▼    ▼
   Team1 Team2 Team3 Team4 Team5 Team6

Mesh Network (Peer-to-Peer)

All teammates can message each other directly. Useful for truly parallel, interdependent work.

   ┌──────────────────────────┐
   │                          │
   ▼                          ▼
Team1 ◄──────────────────► Team2
   │                          │
   │ ◄──────────────────►     │
   │                          │
   └──────────►Team3◄─────────┘
      ◄────────┐ │ ┌───────────►
               │ │ │
            Self-Claim Queue

Pipeline (Sequential Handoff)

Work moves through stages. Each stage completes before passing to the next.

Hierarchy (Multi-Level Teams)

Team leads manage sub-teams. Useful for large organizations.

Cross-Team Communication

Shared Task List

All teammates can view, claim, and complete tasks from a shared queue.

Peer-to-Peer Messaging

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?"

Status Broadcasting

Periodic updates visible to entire team (every 5-10 minutes).

Conflict Resolution

When two teammates claim the same task:

  1. Task lock: First to claim gets exclusive lock (60 sec default)
  2. Conflict detection: System alerts second claimer
  3. Graceful degradation: Second teammate picks next task or supports first with parallel work

Git Worktree Coordination

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:

  1. Squash and merge: Default. Reduces commit graph noise
  2. Rebase and merge: Preserves linear history, good for pipelines
  3. Three-way merge: Default for independent branches, may have conflicts

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

Team Sizing Guidance

| 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

Failure Handling

Single Teammate Failure

Cascading Failure

When teammate A's failure blocks teammate B (dependency).

Team-Wide Failure

All teammates down or unresponsive.

Monitoring Teammate Health

# 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     │
# └─────────────┴────────────┴──────┴─────────────┘

Custom Team Templates

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"

Real-World Patterns

1. Feature Branch Team (3 agents)

→ Parallel development with synchronized handoffs

2. Migration Team (4 agents)

→ High confidence, rapid migrations

3. Incident Response Team (3 agents)

→ Fast incident turnaround

4. Research Team (4 agents + synthesizer)

→ Cover more ground in parallel research

5. Review Board (3 agents)

→ Parallel review perspectives

Cost Management

Estimating Team Cost

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

Model Assignment Per Teammate

When Teams Are Worth the Cost

Cost Optimization Tips

  1. Use Haiku for validation instead of Sonnet — 75% cheaper, similar quality
  2. Limit team size to 3-4 unless truly independent tracks exist
  3. Batch small tasks instead of assigning individually (reduced coordination overhead)
  4. Set aggressive timeouts (900 seconds) to fail fast on stuck teammates
  5. Monitor actual speedup — if actual duration > 50% of sequential, reduce team size

See also: teams-architect agent for interactive team design assistance.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.