Appearance
Architecture Reference โ
Understanding how agent teams work internally.
Fresh ๐ฑSystem Overview โ
Component Details โ
1. Team Lead โ
Role: Orchestrator and coordinator
Capabilities:
- Spawn teammates
- Manage task list
- Synthesize results
- Direct communication with teammates
- File editing and tool execution (unless in delegate mode)
Constraints:
- One team at a time
- Cannot be replaced/promoted to teammate
- In delegate mode: coordination-only
Lifecycle:
- Created when user starts Claude Code
- Creates team (if requested)
- Spawns teammates
- Coordinates work
- Initiates cleanup
2. Teammates โ
Role: Independent workers on assigned tasks
Capabilities:
- Work on assigned tasks
- Communicate with other teammates
- Update shared task list
- Read project context (CLAUDE.md, MCP servers)
Constraints:
- Cannot spawn other teammates
- Cannot run cleanup
- Cannot create new teams
- Own context window only
Lifecycle:
- Spawned by lead
- Load project context
- Receive spawn prompt
- Work independently
- Can be shut down gracefully or forced
3. Shared Task List โ
Storage: ~/.claude/tasks/[team-name]/
Structure:
Each task is a separate file with JSON:
{
"id": 1,
"title": "Implement authentication",
"description": "...",
"status": "in_progress", // pending, in_progress, completed
"owner": "Teammate 1",
"created": "2026-02-12T14:00:00Z",
"updated": "2026-02-12T14:15:00Z",
"dependsOn": [2, 3], // Task IDs this depends on
"blocks": [4, 5] // Task IDs waiting on this
}Features:
- File locking prevents race conditions
- Automatic dependency resolution
- Status tracking (pending โ in_progress โ completed)
- Owner assignment
- Blocking relationships
4. Mailbox System โ
Purpose: Message delivery between agents
Behavior:
- Asynchronous message queue
- Automatic message delivery
- No polling required
- Teammates notified of new messages
- Lead receives all messages automatically
Message Types:
- Direct messages (1:1)
- Broadcast messages (1:many)
- System notifications
- Status updates
Example Flow:
Lead โ "Tell Teammate 1: focus on security"
โ Stored in mailbox
โ Teammate 1 notified
โ Teammate 1 reads message
โ Teammate 1 adjusts work
โ Complete5. Team Configuration โ
File: ~/.claude/teams/[team-name]/config.json
Contents:
json
{
"teamName": "auth-review",
"created": "2026-02-12T14:00:00Z",
"leadId": "lead-uuid",
"members": [
{
"name": "Security Reviewer",
"agentId": "agent-123",
"agentType": "teammate",
"spawned": "2026-02-12T14:01:00Z",
"status": "active"
},
{
"name": "Performance Specialist",
"agentId": "agent-456",
"agentType": "teammate",
"spawned": "2026-02-12T14:01:00Z",
"status": "active"
}
],
"settings": {
"teamMode": "in-process",
"permissions": "default"
}
}Teammate Discovery:
- Teammates can read this file
- They know who else is on team
- They can coordinate through knowledge of team composition
Data Flow โ
Creating a Team โ
User โ "Create agent team"
โ
Lead analyzes request
โ
Lead decides team composition
โ
For each teammate:
- Generate spawn configuration
- Create agent instance
- Load project context
- Send spawn prompt
- Wait for startup
โ
Create shared task list
Create team config file
โ
Team readyTeammate Working on Task โ
Teammate picks up task from list
โ
Teammate reads task details
โ
Teammate updates status: "in_progress"
โ
Teammate works on implementation
โ
Teammate may message other teammates
โ
Teammate finishes work
โ
Teammate updates task status: "completed"
โ
System unblocks dependent tasks
โ
Next teammate can now claim unblocked taskLead Synthesizing Results โ
Lead requests: "Compile findings"
โ
Lead reads all completed tasks
โ
Lead collects teammate messages/results
โ
Lead synthesizes into coherent summary
โ
Lead saves to document
โ
Ready for output/sharingContext Management โ
Project Context (Automatic) โ
Each teammate loads:
- CLAUDE.md - Project instructions
- MCP Servers - Tools and integrations
- Skills - Custom prompts
- Spawn Prompt - Role-specific instructions
Context Isolation โ
- Lead's conversation history NOT shared
- Each teammate has independent context
- No context bleeding between teammates
- Shared task list is the coordination mechanism
Memory Efficiency โ
- Each teammate is independent Claude instance
- Token usage scales with number of teammates
- Can't pass large conversation histories
- Better for focused, well-scoped work
Permission Model โ
Permission Inheritance โ
- Startup: All teammates inherit lead's permissions
- Runtime: Permissions can be changed per teammate
- Spawn: Cannot set per-teammate permissions at creation
- Flag:
--dangerously-skip-permissionsaffects all agents
Permission Types โ
- File operations - Read/write/delete
- Command execution - Run tools and CLI
- Tool usage - Access to specific tools
- Network access - External API calls
Display Modes โ
In-Process Mode โ
Architecture:
Single terminal window
โโ Lead output
โโ Teammate 1 output (when selected)
โโ Teammate 2 output (when selected)
โโ Teammate 3 output (when selected)
Navigation: Shift+Up/Down cycles
Storage: Single processAdvantages:
- Works anywhere
- Lower resource usage
- Simple architecture
Split Panes Mode โ
Architecture:
tmux Session
โโ Window 1: Lead
โโ Window 2: Teammate 1
โโ Window 3: Teammate 2
โโ Window 4: Teammate 3
All visible simultaneously
Navigation: Click or tmux keys
Storage: Multiple tmux panesRequirements:
- tmux or iTerm2 (via it2 CLI)
- Python API (iTerm2)
File Organization โ
~/.claude/ Directory Structure โ
~/.claude/
โโโ settings.json # Global settings
โโโ teams/
โ โโโ auth-review/
โ โโโ config.json # Team configuration
โโโ tasks/
โ โโโ auth-review/
โ โโโ task-1.json # Individual tasks
โ โโโ task-2.json
โ โโโ task-3.json
โโโ logs/
โโโ team-sessions/ # Session transcriptsToken Usage โ
Cost Per Agent โ
Each teammate = separate Claude instance:
- Lead: 1 context window
- 3 teammates: 4 context windows total
- 5 teammates: 6 context windows total
Scaling โ
- Single agent: 1x token cost
- 3-agent team: 3-4x token cost
- 5-agent team: 5-7x token cost
When worthwhile:
- 3x token cost รท 2-3x speedup = 1.5x net cost for 3x faster
- Breakeven when speedup > token cost multiplier
Synchronization โ
File Locking โ
Task list uses file locks to prevent:
- Race conditions when claiming tasks
- Concurrent modifications
- Data corruption
Message Delivery โ
Mailbox ensures:
- No message loss
- Order preservation
- Automatic retries
- Timeout handling
Status Consistency โ
- Each agent updates own status atomically
- Changes visible to all immediately
- No eventual consistency delays
- Synchronous updates
Limitations & Constraints โ
Current Limitations โ
| Limitation | Impact | Workaround |
|---|---|---|
| No session resumption | Can't /resume with teammates | Clean up and create new team |
| One team per lead | Can't manage multiple teams | Sequential team creation |
| No nested teams | Teammates can't spawn teams | Only lead can spawn |
| Lead is fixed | Can't rotate leadership | Plan team lifecycle upfront |
| Split panes needs tmux | Not available in VS Code | Use in-process mode |
| Task status can lag | Teammates don't mark complete | Manual status update if stuck |
Best Practices for Architecture โ
Minimize Context Size โ
- Keep spawn prompts concise
- Don't include entire conversation history
- Use CLAUDE.md for project context
- Reference files by path, not content
Design Task Boundaries โ
- Independent tasks parallelize better
- Shared files create conflicts
- Clear ownership per teammate
- Explicit interfaces between tasks
Plan for Synchronization Points โ
- Identify where integration happens
- Set up explicit check-ins
- Use task dependencies
- Plan synthesis timing
Resource Efficiency โ
- Use Haiku for simple, fast tasks
- Use Sonnet for balanced workloads
- Use Opus for complex reasoning
- Monitor overall token usage