Skip to content

Instantly share code, notes, and snippets.

@h6y3
Created August 15, 2025 18:09
Show Gist options
  • Save h6y3/73c41d5d500746634c199750ec5691e4 to your computer and use it in GitHub Desktop.
Save h6y3/73c41d5d500746634c199750ec5691e4 to your computer and use it in GitHub Desktop.
Multi-Agent Claude Code Command
# Multi-Agent Coordination Command
## Overview
This Claude Code command optimizes multi-agent task delegation based on proven patterns from successful implementations. Use this command when you have complex tasks that can benefit from parallel execution by multiple specialized agents.
## Usage
```bash
/multiagent [task-description] [complexity:1-5] [urgency:low|medium|high]
```
**Examples:**
- `/multiagent "Implement user authentication system" 4 high`
- `/multiagent "Add dark mode to UI components" 2 medium`
- `/multiagent "Optimize database queries and caching" 3 low`
## Command Logic
### 1. Complexity-Based Team Sizing
**Complexity 1-2 (Simple):** 1 Agent
- Single-file modifications
- Straightforward implementations
- Minimal dependencies
**Complexity 3 (Moderate):** 2-3 Agents
- Multi-file changes
- Some interdependencies
- Moderate coordination needed
**Complexity 4-5 (Complex):** 3-5 Agents
- Cross-system integration
- Complex interdependencies
- High coordination requirements
### 2. Urgency-Based Parallelization
**Low Urgency:**
- Sequential execution allowed
- Focus on quality over speed
- Thorough validation at each step
**Medium Urgency:**
- Mixed sequential/parallel approach
- Balance speed and coordination
- Regular sync points
**High Urgency:**
- Maximum parallelization
- Accept some coordination overhead
- Rapid deployment priority
### 3. Agent Specialization Patterns
Based on proven success patterns:
**Backend Specialist Agent:**
- Database schema changes
- API endpoint implementation
- Server-side logic
- Type definitions and validation
**Frontend Specialist Agent:**
- UI component development
- Client-side state management
- User experience optimization
- Component integration
**Integration Specialist Agent:**
- API integrations
- Third-party service connections
- Error handling systems
- Cross-system communication
**DevOps/Tooling Specialist Agent:**
- Build system changes
- Testing infrastructure
- Deployment configuration
- Development tooling
**Universal Scaffold Guardian Agent:**
- Ensures universal principles compliance
- Prevents app-specific implementations
- Maintains namespace isolation
- Validates scaffold integrity
## Agent Priming Template
Each agent receives this standardized context:
```markdown
## AGENT CONTEXT PACKAGE
### Universal Scaffold Principles
- NO app-specific implementations - maintain universal flexibility
- ALL implementations must work across all 5 app slots (app1-app5)
- Use namespace isolation patterns with appId parameters
- Follow existing universal patterns in the codebase
### Your Specialization: [AGENT_TYPE]
[Specialized role description and responsibilities]
### Task Scope: [SPECIFIC_TASKS]
[Clear, measurable tasks with completion criteria]
### Dependencies
- **Requires:** [What you need from other agents]
- **Provides:** [What other agents need from you]
- **Parallel Safe:** [What can be done independently]
### Success Criteria
- [ ] Specific deliverable 1
- [ ] Specific deliverable 2
- [ ] Specific deliverable 3
- [ ] Build validation passes: `npm run build`
- [ ] Type checking passes: `npx tsc --noEmit`
- [ ] No universal scaffold violations
### File Patterns to Follow
[Concrete examples from existing codebase]
### Error Handling Requirements
[Consistent error handling patterns to maintain]
### Coordination Protocol
- **Start Condition:** [What triggers your work to begin]
- **Completion Signal:** [How you signal completion to others]
- **Conflict Resolution:** [How to handle merge conflicts]
## IMPORTANT REMINDERS
- Use TodoWrite tool to track progress throughout your work
- Read existing files before editing to understand patterns
- Validate your work with build tools before marking complete
- Communicate clear status updates for coordination
```
## Coordination Strategies
### Sequential Coordination (Low Risk)
```
Agent 1 → Complete → Agent 2 → Complete → Agent 3 → Complete
```
### Pipeline Coordination (Medium Risk)
```
Agent 1 → 50% Complete → Agent 2 Starts
Agent 2 → 50% Complete → Agent 3 Starts
```
### Parallel Coordination (High Risk, High Speed)
```
Agent 1, 2, 3 → Start Simultaneously → Sync Points → Integration
```
### Hybrid Coordination (Optimal Balance)
```
Foundation Agent → Complete Core
Parallel Agents → Start Dependent Work
Integration Agent → Merge and Validate
```
## Proven Delegation Patterns
### Pattern 1: Foundation-First
**When:** New system implementation
**Approach:** One agent builds foundation, others build on top
**Example:** Database schema → API procedures → Frontend integration
### Pattern 2: Domain Separation
**When:** Cross-cutting concerns
**Approach:** Each agent owns a complete domain
**Example:** Auth system + UI components + Integration testing
### Pattern 3: Layer Separation
**When:** Full-stack features
**Approach:** Each agent owns a complete layer
**Example:** Database + API + Frontend + Testing
### Pattern 4: Component Isolation
**When:** Independent components
**Approach:** Each agent owns complete components
**Example:** User management + File upload + Notifications
## Quality Gates
### Before Agent Deployment
- [ ] Task complexity assessment complete
- [ ] Dependencies mapped and validated
- [ ] Success criteria clearly defined
- [ ] Coordination strategy selected
- [ ] Agent context packages prepared
### During Execution
- [ ] Progress tracked via TodoWrite
- [ ] Regular sync points maintained
- [ ] Conflicts resolved promptly
- [ ] Quality standards maintained
### Before Completion
- [ ] All deliverables validated
- [ ] Build processes successful
- [ ] Integration testing complete
- [ ] Universal scaffold integrity confirmed
- [ ] Documentation updated
## Lessons Learned Integration
### ✅ What Works (Keep Doing)
- Clear task boundaries prevent overlap
- Universal scaffold context prevents violations
- Concrete examples enable consistent patterns
- TodoWrite provides coordination visibility
- Sequential dependencies minimize conflicts
### ❌ What Doesn't Work (Avoid)
- Vague completion criteria lead to inconsistency
- Missing dependency mapping causes bottlenecks
- Insufficient context priming creates violations
- Too many parallel agents increase coordination cost
- Lack of concrete examples reduces quality
### 🔧 Optimizations Applied
- Context packages standardize agent priming
- Success criteria include measurable outcomes
- Coordination protocols prevent conflicts
- Specialization patterns leverage strengths
- Quality gates ensure consistent delivery
## Emergency Protocols
### Agent Failure Recovery
1. **Identify:** Failed agent and completion percentage
2. **Isolate:** Separate completed work from failed work
3. **Redistribute:** Assign failed work to available agents
4. **Validate:** Ensure quality maintained in recovery
### Coordination Breakdown
1. **Stop:** Halt all parallel work immediately
2. **Assess:** Identify conflicts and dependencies
3. **Redesign:** Shift to sequential coordination
4. **Resume:** Restart with simplified approach
### Quality Gate Failure
1. **Rollback:** Return to last successful state
2. **Analyze:** Identify root cause of quality issues
3. **Retrain:** Update agent context packages
4. **Retry:** Restart with improved instructions
## Success Metrics
Track these metrics to optimize future multi-agent deployments:
- **Completion Time:** Total time from start to full delivery
- **Coordination Overhead:** Time spent on agent management vs. work
- **Quality Score:** Build success rate and defect count
- **Efficiency Ratio:** Output delivered vs. agent-hours invested
- **Scaffold Integrity:** Universal principles compliance rate
---
**Command Version:** 1.0
**Last Updated:** 2025-01-15
**Based On:** 4 successful multi-agent deployments with 100% success rate
**Tested With:** Universal tRPC scaffold implementation, error handling systems, API integrations
*This command embodies proven patterns from successful buildathon implementations where multi-agent coordination delivered complex features while maintaining universal scaffold integrity and production-quality code.*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment