when-using-advanced-swarm-use-swarm-advanced
Advanced swarm patterns with dynamic topology switching and self-organizing behaviors for complex multi-agent coordination
What this skill does
# 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
```bash
# 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
```javascript
// 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
```bash
# 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
1. Swarm ID generated and confirmed
2. Topology matches requested configuration
3. Agent count within specified limits
4. Memory coordination operational
5. 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
```bash
# 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
```javascript
// 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
```bash
# 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
1. Coordinator agents active and responsive
2. Topology structure matches configuration
3. Agent connections verified
4. Baseline metrics recorded
5. 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
```bash
# 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
```javascript
// 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:**
```bash
# Level 0: Root coordinator
# Level 1: Department coordinators
# LRelated in workflow
absolute-work
IncludedEnd-to-end, phase-gated software development lifecycle for AI agents. Turns a ticket, task, plan, or migration into a validated design, a dependency-graphed task board, and verified code. Triggers on "build this end-to-end", "plan and build", "break this into tasks", "pick up this ticket", "grill me on this", "run this migration", "absolute-work this", or any multi-step development task. Relentlessly interviews to a shared design, writes a reviewed spec, decomposes into atomic tasks on a persistent markdown board, then peels tasks one safe wave at a time with test-first verification. Handles features, bugs, refactors, greenfield projects, planning breakdowns, and migrations.
absolute-simplify
IncludedAutonomously simplifies code in your working changes or targeted files. Detects staged or unstaged git changes, analyzes for simplification opportunities following clean code and clean architecture principles, applies improvements directly, runs tests to verify nothing broke, and shows a structured summary with reasoning. Triggers on "simplify this", "refactor this", "clean up my changes", "absolute-simplify", "simplify my code", "make this cleaner", "tidy this up", "reduce complexity", "flatten this", "remove dead code", or when code needs clarity improvements, nesting reduction, or redundancy removal. Language-agnostic at base with deep opinions for JS/TS/React, Python, and Go.
sentry-sdk-upgrade
IncludedUpgrade the Sentry JavaScript SDK across major versions. Use when asked to upgrade Sentry, migrate to a newer version, fix deprecated Sentry APIs, or resolve breaking changes after a Sentry version bump.
development-workflow
IncludedDetailed development workflow with modular patterns for git, review, testing, and deployment.
project-execution
IncludedExecutes implementation plans with progress tracking, checkpoint validation, and quality gates. Use after planning is complete and tasks are ready to implement.
when-orchestrating-swarm-use-swarm-orchestration
IncludedComplex multi-agent swarm orchestration with task decomposition, distributed execution, and result synthesis