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
- Swarm initialized with confirmed topology
- All agents spawned successfully
- Memory coordination active
- Health checks passing
Scripts
# Initialize hierarchical swarm
npx claude-flow@alpha swarm init --topology hierarchical --max-agents 10
# Initialize mesh swarm
npx claude-flow@alpha swarm init --topology mesh --max-agents 8
# Initialize adaptive swarm
npx claude-flow@alpha swarm init --topology adaptive --max-agents 12 --strategy balanced
# Verify initialization
npx claude-flow@alpha swarm status --verbose
# Setup memory coordination
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
// Initialize swarm with MCP
mcp__claude-flow__swarm_init({
topology: "hierarchical",
maxAgents: 10,
strategy: "balanced"
})
// Alternative: Mesh topology
mcp__claude-flow__swarm_init({
topology: "mesh",
maxAgents: 8,
strategy: "specialized"
})
// Alternative: Adaptive topology
mcp__claude-flow__swarm_init({
topology: "adaptive",
maxAgents: 12,
strategy: "adaptive"
})
Memory Patterns
# Store swarm configuration
npx claude-flow@alpha memory store \
--key "swarm/config" \
--value '{"topology":"hierarchical","maxAgents":10,"strategy":"balanced"}'
# Store agent assignments
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
- Topology selected based on analysis
- Coordinator agents spawned
- Agent connections established
- Topology metrics baseline recorded
Scripts
# Spawn hierarchical coordinator
npx claude-flow@alpha agent spawn \
--type coordinator \
--role "hierarchical-coordinator" \
--capabilities "task-delegation,hierarchy-management"
# Spawn mesh coordinator
npx claude-flow@alpha agent spawn \
--type coordinator \
--role "mesh-coordinator" \
--capabilities "peer-coordination,consensus"
# Spawn adaptive coordinator
npx claude-flow@alpha agent spawn \
--type coordinator \
--role "adaptive-coordinator" \
--capabilities "topology-switching,optimization"
# Configure topology
npx claude-flow@alpha swarm configure \
--topology hierarchical \
--levels 3 \
--branching-factor 3
# Verify topology
npx claude-flow@alpha swarm status --show-topology
MCP Integration
// Spawn coordinator agents
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
# Store topology configuration
npx claude-flow@alpha memory store \
--key "swarm/topology/config" \
--value '{"type":"hierarchical","levels":3,"branchingFactor":3}'
# Store baseline metrics
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
- All required agents spawned
- Agent roles assigned correctly
- Coordination protocols active
- Agent health checks passing
Scripts
# Spawn specialized agents for hierarchical topology
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"
# Assign agents to hierarchy levels
npx claude-flow@alpha swarm assign \
--agent-id "agent-001" \
--level 1 \
--parent "coordinator-1"
# Spawn agents for mesh topology
npx claude-flow@alpha agent spawn --type analyst --peer-mode enabled
npx claude-flow@alpha agent spawn --type optimizer --peer-mode enabled
# Configure peer connections
npx claude-flow@alpha swarm connect-peers --all
# List all agents
npx claude-flow@alpha agent list --show-roles --show-connections
MCP Integration
// Spawn specialized agents
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"]
})
// Check agent status
mcp__claude-flow__agent_list({
filter: "active"
})
mcp__claude-flow__agent_metrics({
metric: "all"
})
Agent Assignment Patterns
Hierarchical Assignment:
# Level 0: Root coordinator
# Level 1: Department coordinators
# Le