Agent Team: Multiple Claude Code instances working on different aspects of a project, coordinated to achieve a larger goal than any single agent could efficiently handle.
Single agents hit limits:
Context window caps
Serial execution
Scope creep
Agent teams solve these:
Separate contexts per agent
Parallel execution
Focused responsibilities
Pattern 1: Parallel Workers
The simplest pattern—multiple agents on independent tasks.
#!/bin/bash
# parallel-agents.sh# Agent 1: Backend workclaude --no-interactive "
Focus: apps/api/src/
Task: Add new endpoint for user preferences
"&# Agent 2: Frontend workclaude --no-interactive "
Focus: apps/web/app/
Task: Add preferences UI component
"&# Agent 3: Testsclaude --no-interactive "
Focus: tests/
Task: Write integration tests for preferences feature
"&# Wait for all to completewaitecho"All agents completed"
When to Use
Independent features
Different modules
Tasks that don’t affect each other’s files
Coordination
Coordinate through git:
Agents work on separate branches
Merge branches when complete
Resolve conflicts manually
Pattern 2: Specialized Roles
Agents with specific expertise handle different concerns.
Role Definitions
1
2
3
4
5
6
# .claude/agents/architect.md
You are the Architect agent. Your responsibilities:
- Review proposed designs
- Ensure consistency with existing patterns
- Flag potential issues with scale or complexity
- You DO NOT write implementation code
1
2
3
4
5
6
# .claude/agents/implementer.md
You are the Implementer agent. Your responsibilities:
- Write code based on approved designs
- Follow existing patterns exactly
- Ask questions if requirements are unclear
- You DO NOT make architectural decisions
1
2
3
4
5
6
# .claude/agents/reviewer.md
You are the Reviewer agent. Your responsibilities:
- Review code for security vulnerabilities
- Check for edge cases and error handling
- Verify tests cover requirements
- You DO NOT write implementation code
Workflow
1
2
3
4
5
6
7
8
9
10
11
12
13
# Step 1: Architect designsclaude --system "$(cat .claude/agents/architect.md)"\
"Design user preferences feature. Output design doc only."# Step 2: Human reviews design# Step 3: Implementer buildsclaude --system "$(cat .claude/agents/implementer.md)"\
"Implement based on design in design.md"# Step 4: Reviewer checksclaude --system "$(cat .claude/agents/reviewer.md)"\
"Review implementation in apps/api/src/preferences/"
#!/bin/bash
# context-handoff.sh# Agent 1: Explore and documentclaude --no-interactive "
Explore the billing module.
Output a context summary document.
" > .claude/handoff/billing-context.md
# Agent 2: Use that contextclaude --no-interactive "
Read .claude/handoff/billing-context.md
Using this context, implement coupon support.
"# Agent 3: Review with contextclaude --no-interactive "
Read .claude/handoff/billing-context.md
Review the coupon implementation for issues.
"
Handoff Documents
Structure for effective handoffs:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Context Handoff: Billing Module
## Current State
- Stripe integration via apps/api/src/billing/stripe.ts
- Subscription model in packages/db/schema.prisma
- Webhook handler at apps/api/src/billing/webhooks.ts
## Key Patterns
- All Stripe calls wrapped in try/catch with logging
- Subscriptions sync on webhook, not API response
- Invoices stored locally for quick access
## Active Concerns
- Proration not yet implemented
- Coupon support pending
- Currency handling is USD-only
## Files Modified This Session
- apps/api/src/billing/routes.ts (added /coupons endpoint stub)
# CI workflowjobs:agent-review:steps:- name:Agent implementsrun:./run-agent.sh- name:Human review requireduses:hmarr/auto-approve-action@v3with:require-approvals:1
FAQ
How many agents should I run in parallel?
Depends on your task. Start with 2-3 for parallel features. More agents = more coordination overhead. The sweet spot is usually 3-5 for complex projects.
Do agents share context automatically?
No. Each agent has independent context. Use handoff documents or explicit file reads to share information between agents.
How do I handle conflicts between agents?
Have agents work on separate files/branches when possible. Use a coordinator agent or human review to resolve conflicts. Git merge is your friend.
Can I use different models for different agents?
Yes. Use Claude Sonnet for complex reasoning, Haiku for simple tasks. Match model capability to task complexity.