| name | when-using-advanced-swarm-use-swarm-advanced |
| description | Advanced swarm patterns with dynamic topology switching and self-organizing behaviors for complex multi-agent coordination Use when this capability is needed. |
| metadata | {"author":"dnyoussef"} |
Advanced Swarm Coordination SOP
Overview
This skill implements advanced swarm patterns with dynamic topology switching, self-organizing behaviors, and intelligent coordination for complex multi-agent systems. It enables sophisticated swarm orchestration with adaptive topology selection and performance optimization.
Agents & Responsibilities
hierarchical-coordinator
Role: Tree-based coordination with leader-follower patterns
Responsibilities:
- Manage hierarchical swarm structures
- Coordinate parent-child agent relationships
- Handle task delegation cascades
- Monitor hierarchy performance
mesh-coordinator
Role: Peer-to-peer coordination with full connectivity
Responsibilities:
- Enable direct agent-to-agent communication
- Manage mesh network topology
- Coordinate distributed consensus
- Handle fault tolerance
adaptive-coordinator
Role: Dynamic topology switching based on workload
Responsibilities:
- Analyze task complexity and requirements
- Switch topologies dynamically
- Optimize resource allocation
- Monitor and adapt to performance
Phase 1: Initialize Swarm Infrastructure
Objective
Establish foundation for advanced swarm coordination with proper topology and agent configuration.
Evidence-Based Validation
Scripts
npx claude-flow@alpha swarm init --topology hierarchical --max-agents 10
npx claude-flow@alpha swarm init --topology mesh --max-agents 8
npx claude-flow@alpha swarm init --topology adaptive --max-agents 12 --strategy balanced
npx claude-flow@alpha swarm status --verbose
npx claude-flow@alpha memory store --key "swarm/topology" --value "hierarchical"
npx claude-flow@alpha memory store --key "swarm/max-agents" --value "10"
MCP Integration
mcp__claude-flow__swarm_init({
topology: "hierarchical",
maxAgents: 10,
strategy: "balanced"
})
mcp__claude-flow__swarm_init({
topology: "mesh",
maxAgents: 8,
strategy: "specialized"
})
mcp__claude-flow__swarm_init({
topology: "adaptive",
maxAgents: 12,
strategy: "adaptive"
})
Memory Patterns
npx claude-flow@alpha memory store \
--key "swarm/config" \
--value '{"topology":"hierarchical","maxAgents":10,"strategy":"balanced"}'
npx claude-flow@alpha memory store \
--key "swarm/agents/coordinator-1" \
--value '{"type":"hierarchical-coordinator","status":"active","level":0}'
Validation Criteria
- Swarm ID generated and confirmed
- Topology matches requested configuration
- Agent count within specified limits
- Memory coordination operational
- Health endpoint responding
Phase 2: Configure Topology
Objective
Select and configure optimal topology pattern based on task requirements and complexity.
Evidence-Based Validation
Scripts
npx claude-flow@alpha agent spawn \
--type coordinator \
--role "hierarchical-coordinator" \
--capabilities "task-delegation,hierarchy-management"
npx claude-flow@alpha agent spawn \
--type coordinator \
--role "mesh-coordinator" \
--capabilities "peer-coordination,consensus"
npx claude-flow@alpha agent spawn \
--type coordinator \
--role "adaptive-coordinator" \
--capabilities "topology-switching,optimization"
npx claude-flow@alpha swarm configure \
--topology hierarchical \
--levels 3 \
--branching-factor 3
npx claude-flow@alpha swarm status --show-topology
MCP Integration
mcp__claude-flow__agent_spawn({
type: "coordinator",
name: "hierarchical-coordinator",
capabilities: ["task-delegation", "hierarchy-management"]
})
mcp__claude-flow__agent_spawn({
type: "coordinator",
name: "mesh-coordinator",
capabilities: ["peer-coordination", "consensus"]
})
mcp__claude-flow__agent_spawn({
type: "coordinator",
name: "adaptive-coordinator",
capabilities: ["topology-switching", "optimization"]
})
Topology Selection Guide
Hierarchical:
- Best for: Clear task hierarchies, delegation workflows
- Pros: Efficient delegation, clear authority
- Cons: Single point of failure at root
- Use when: Tasks have natural parent-child relationships
Mesh:
- Best for: Peer collaboration, distributed consensus
- Pros: High fault tolerance, no bottlenecks
- Cons: Higher communication overhead
- Use when: Agents need direct communication
Star:
- Best for: Centralized coordination, simple workflows
- Pros: Simple control, low complexity
- Cons: Central coordinator bottleneck
- Use when: Single coordinator can handle all traffic
Ring:
- Best for: Sequential processing, pipeline workflows
- Pros: Predictable flow, ordered execution
- Cons: Latency accumulation
- Use when: Tasks must be processed in sequence
Adaptive:
- Best for: Dynamic workloads, variable complexity
- Pros: Automatic optimization, flexible
- Cons: Overhead from topology switching
- Use when: Workload patterns vary significantly
Memory Patterns
npx claude-flow@alpha memory store \
--key "swarm/topology/config" \
--value '{"type":"hierarchical","levels":3,"branchingFactor":3}'
npx claude-flow@alpha memory store \
--key "swarm/metrics/baseline" \
--value '{"latency":45,"throughput":120,"agentUtilization":0.75}'
Validation Criteria
- Coordinator agents active and responsive
- Topology structure matches configuration
- Agent connections verified
- Baseline metrics recorded
- No configuration errors
Phase 3: Deploy Agents
Objective
Spawn specialized agents based on topology and assign roles with proper coordination.
Evidence-Based Validation
Scripts
npx claude-flow@alpha agent spawn --type researcher --capabilities "analysis,patterns"
npx claude-flow@alpha agent spawn --type coder --capabilities "implementation,testing"
npx claude-flow@alpha agent spawn --type reviewer --capabilities "quality,security"
npx claude-flow@alpha swarm assign \
--agent-id "agent-001" \
--level 1 \
--parent "coordinator-1"
npx claude-flow@alpha agent spawn --type analyst --peer-mode enabled
npx claude-flow@alpha agent spawn --type optimizer --peer-mode enabled
npx claude-flow@alpha swarm connect-peers --all
npx claude-flow@alpha agent list --show-roles --show-connections
MCP Integration
mcp__claude-flow__agent_spawn({
type: "researcher",
capabilities: ["analysis", "patterns", "research"]
})
mcp__claude-flow__agent_spawn({
type: "coder",
capabilities: ["implementation", "testing", "debugging"]
})
mcp__claude-flow__agent_spawn({
type: "analyst",
capabilities: ["optimization", "performance", "metrics"]
})
mcp__claude-flow__agent_list({
filter: "active"
})
mcp__claude-flow__agent_metrics({
metric: "all"
})
Agent Assignment Patterns
Hierarchical Assignment:
npx claude-flow@alpha memory store \
--key "swarm/hierarchy/level-0" \
--value '{"agent":"coordinator-1","role":"root"}'
npx claude-flow@alpha memory store \
--key "swarm/hierarchy/level-1" \
--value '["agent-001","agent-002","agent-003"]'
Mesh Assignment:
npx claude-flow@alpha memory store \
--key "swarm/mesh/peers" \
--value '["agent-001","agent-002","agent-003","agent-004"]'
Memory Patterns
npx claude-flow@alpha memory store \
--key "swarm/agents/roster" \
--value '{"total":8,"active":8,"idle":0,"roles":{"researcher":2,"coder":3,"reviewer":2,"optimizer":1}}'
npx claude-flow@alpha memory store \
--key "swarm/agents/agent-001/capabilities" \
--value '["analysis","patterns","research","documentation"]'
Validation Criteria
- Agent count matches requirements
- All agents responding to health checks
- Role assignments verified
- Coordination protocols established
- Memory state synchronized
Phase 4: Monitor Performance
Objective
Track swarm performance metrics, identify bottlenecks, and gather optimization data.
Evidence-Based Validation
Scripts
npx claude-flow@alpha swarm monitor --interval 5 --duration 60
npx claude-flow@alpha agent metrics --all --format json
npx claude-flow@alpha task status --show-timing
npx claude-flow@alpha performance analyze --detect-bottlenecks
npx claude-flow@alpha metrics export --output ./swarm-metrics.json
npx claude-flow@alpha performance report \
--include-agents \
--include-topology \
--output ./performance-report.md
MCP Integration
mcp__claude-flow__swarm_monitor({
duration: 60,
interval: 5
})
mcp__claude-flow__agent_metrics({
metric: "all"
})
mcp__claude-flow__task_status({
detailed: true
})
mcp__claude-flow__benchmark_run({
type: "swarm",
iterations: 10
})
Key Metrics to Track
Swarm-Level Metrics:
- Total throughput (tasks/minute)
- Average latency per task
- Agent utilization rate
- Coordination overhead
- Memory usage
- Network latency
Agent-Level Metrics:
- Task completion rate
- Response time
- Error rate
- Resource consumption
- Idle time percentage
Topology-Level Metrics:
- Connection count
- Message passing efficiency
- Fault tolerance score
- Scalability index
Memory Patterns
npx claude-flow@alpha memory store \
--key "swarm/metrics/snapshot-$(date +%s)" \
--value '{"throughput":145,"latency":38,"utilization":0.82,"errors":2}'
npx claude-flow@alpha memory store \
--key "swarm/analysis/bottlenecks" \
--value '{"coordinator-1":{"type":"high-load","severity":"medium","recommendation":"add-peer"}}'
Validation Criteria
- Metrics collected every 5 seconds
- No data loss or gaps
- Bottlenecks identified and documented
- Performance trends visible
- Alerts triggered for anomalies
Phase 5: Optimize Dynamically
Objective
Apply dynamic optimizations including topology switching, agent rebalancing, and resource allocation.
Evidence-Based Validation
Scripts
npx claude-flow@alpha performance analyze --recommend-optimizations
npx claude-flow@alpha swarm reconfigure --topology mesh
npx claude-flow@alpha swarm rebalance --strategy adaptive
npx claude-flow@alpha swarm scale --target-agents 12
npx claude-flow@alpha neural train --pattern convergent
npx claude-flow@alpha performance compare \
--baseline ./baseline-metrics.json \
--current ./current-metrics.json
npx claude-flow@alpha performance report \
--show-improvements \
--output ./optimization-report.md
MCP Integration
mcp__claude-flow__benchmark_run({
type: "swarm",
iterations: 5
})
mcp__claude-flow__neural_train({
agentId: "adaptive-coordinator",
iterations: 10
})
mcp__claude-flow__neural_patterns({
pattern: "all"
})
Optimization Strategies
Topology Switching:
if [ "$COORDINATOR_LOAD" -gt 80 ]; then
npx claude-flow@alpha swarm reconfigure --topology mesh
fi
if [ "$TASK_TYPE" == "pipeline" ]; then
npx claude-flow@alpha swarm reconfigure --topology ring
fi
Agent Rebalancing:
npx claude-flow@alpha agent metrics --filter "utilization<0.3"
npx claude-flow@alpha swarm rebalance --threshold 0.8
if [ "$AVG_UTILIZATION" -gt 0.9 ]; then
npx claude-flow@alpha agent spawn --type optimizer --auto-assign
fi
Resource Allocation:
npx claude-flow@alpha agent configure \
--agent-id "agent-001" \
--memory-limit 2048MB
npx claude-flow@alpha swarm configure --sync-interval 3s
Memory Patterns
npx claude-flow@alpha memory store \
--key "swarm/optimization/actions" \
--value '{"timestamp":"2025-10-30T10:30:00Z","action":"topology-switch","from":"hierarchical","to":"mesh","reason":"coordinator-bottleneck"}'
npx claude-flow@alpha memory store \
--key "swarm/optimization/improvements" \
--value '{"throughput":{"before":120,"after":175,"improvement":45.8},"latency":{"before":45,"after":32,"improvement":28.9}}'
Validation Criteria
- Performance metrics improved by ≥15%
- Bottlenecks eliminated or reduced
- Agent utilization balanced (±10%)
- No errors introduced by optimizations
- Topology switches completed successfully
Success Criteria
Overall Validation
Performance Targets
- Throughput increase: ≥20%
- Latency reduction: ≥15%
- Agent utilization: 70-90%
- Error rate: <2%
- Coordination overhead: <10%
Common Issues & Solutions
Issue: Coordinator Bottleneck
Symptoms: High latency, coordinator CPU >90%
Solution: Switch to mesh topology or add peer coordinators
Issue: Agent Underutilization
Symptoms: Many agents idle, unbalanced load
Solution: Rebalance task assignment, reduce agent count
Issue: Topology Switch Failures
Symptoms: Errors during reconfiguration, lost connections
Solution: Drain tasks before switching, validate agent states
Issue: Memory Synchronization Lag
Symptoms: Agents have inconsistent state
Solution: Increase sync frequency, use distributed consensus
Best Practices
- Start Simple: Begin with hierarchical or star topology
- Monitor First: Collect baseline metrics before optimizing
- Gradual Scaling: Add agents incrementally
- Test Topology Switches: Validate in non-production first
- Document Patterns: Record successful configurations
- Use Neural Training: Improve pattern recognition
- Enable Auto-Healing: Configure self-recovery mechanisms
- Regular Health Checks: Monitor agent health continuously
Integration Points
With Other Skills
- swarm-orchestration: For complex task coordination
- performance-analysis: For deep performance insights
- hive-mind: For collective intelligence patterns
- cascade-orchestrator: For workflow chaining
With External Systems
- GitHub Actions for CI/CD integration
- Prometheus for metrics collection
- Grafana for visualization
- Slack/Discord for alerts
Next Steps
After completing this skill:
- Explore specific topology patterns in depth
- Implement custom coordination protocols
- Integrate with monitoring systems
- Create domain-specific swarm templates
- Experiment with hybrid topologies
References
Converted and distributed by TomeVault — claim your Tome and manage your conversions.