when-using-advanced-swarm-use-swarm-advanced
Advanced swarm patterns with dynamic topology switching and self-organizing behaviors for complex multi-agent coordination
Best use case
when-using-advanced-swarm-use-swarm-advanced is best used when you need a repeatable AI agent workflow instead of a one-off prompt. It is especially useful for teams working in multi. Advanced swarm patterns with dynamic topology switching and self-organizing behaviors for complex multi-agent coordination
Advanced swarm patterns with dynamic topology switching and self-organizing behaviors for complex multi-agent coordination
Users should expect a more consistent workflow output, faster repeated execution, and less time spent rewriting prompts from scratch.
Practical example
Example input
Use the "when-using-advanced-swarm-use-swarm-advanced" skill to help with this workflow task. Context: Advanced swarm patterns with dynamic topology switching and self-organizing behaviors for complex multi-agent coordination
Example output
A structured workflow result with clearer steps, more consistent formatting, and an output that is easier to reuse in the next run.
When to use this skill
- Use this skill when you want a reusable workflow rather than writing the same prompt again and again.
When not to use this skill
- Do not use this when you only need a one-off answer and do not need a reusable workflow.
- Do not use it if you cannot install or maintain the related files, repository context, or supporting tools.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/when-using-advanced-swarm-use-swarm-advanced/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How when-using-advanced-swarm-use-swarm-advanced Compares
| Feature / Agent | when-using-advanced-swarm-use-swarm-advanced | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Advanced swarm patterns with dynamic topology switching and self-organizing behaviors for complex multi-agent coordination
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 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
# Level 2: Task executors
# Level 3: Specialized workers
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:**
```bash
# All agents are peers with direct connections
npx claude-flow@alpha memory store \
--key "swarm/mesh/peers" \
--value '["agent-001","agent-002","agent-003","agent-004"]'
```
### Memory Patterns
```bash
# Store agent roster
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}}'
# Store agent capabilities
npx claude-flow@alpha memory store \
--key "swarm/agents/agent-001/capabilities" \
--value '["analysis","patterns","research","documentation"]'
```
### Validation Criteria
1. Agent count matches requirements
2. All agents responding to health checks
3. Role assignments verified
4. Coordination protocols established
5. Memory state synchronized
## Phase 4: Monitor Performance
### Objective
Track swarm performance metrics, identify bottlenecks, and gather optimization data.
### Evidence-Based Validation
- [ ] Metrics collected continuously
- [ ] Performance baseline established
- [ ] Bottlenecks identified
- [ ] Optimization opportunities logged
### Scripts
```bash
# Monitor swarm status
npx claude-flow@alpha swarm monitor --interval 5 --duration 60
# Get agent metrics
npx claude-flow@alpha agent metrics --all --format json
# Check task performance
npx claude-flow@alpha task status --show-timing
# Analyze bottlenecks
npx claude-flow@alpha performance analyze --detect-bottlenecks
# Export metrics
npx claude-flow@alpha metrics export --output ./swarm-metrics.json
# Generate performance report
npx claude-flow@alpha performance report \
--include-agents \
--include-topology \
--output ./performance-report.md
```
### MCP Integration
```javascript
// Monitor swarm in real-time
mcp__claude-flow__swarm_monitor({
duration: 60,
interval: 5
})
// Get comprehensive metrics
mcp__claude-flow__agent_metrics({
metric: "all"
})
// Check task status
mcp__claude-flow__task_status({
detailed: true
})
// Run performance benchmarks
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
```bash
# Store performance snapshot
npx claude-flow@alpha memory store \
--key "swarm/metrics/snapshot-$(date +%s)" \
--value '{"throughput":145,"latency":38,"utilization":0.82,"errors":2}'
# Store bottleneck analysis
npx claude-flow@alpha memory store \
--key "swarm/analysis/bottlenecks" \
--value '{"coordinator-1":{"type":"high-load","severity":"medium","recommendation":"add-peer"}}'
```
### Validation Criteria
1. Metrics collected every 5 seconds
2. No data loss or gaps
3. Bottlenecks identified and documented
4. Performance trends visible
5. Alerts triggered for anomalies
## Phase 5: Optimize Dynamically
### Objective
Apply dynamic optimizations including topology switching, agent rebalancing, and resource allocation.
### Evidence-Based Validation
- [ ] Optimization strategies applied
- [ ] Performance improvements measured
- [ ] Topology switches successful
- [ ] Resource allocation optimized
- [ ] Final metrics show improvement
### Scripts
```bash
# Analyze optimization opportunities
npx claude-flow@alpha performance analyze --recommend-optimizations
# Switch topology dynamically
npx claude-flow@alpha swarm reconfigure --topology mesh
# Rebalance agents
npx claude-flow@alpha swarm rebalance --strategy adaptive
# Scale swarm
npx claude-flow@alpha swarm scale --target-agents 12
# Apply neural optimizations
npx claude-flow@alpha neural train --pattern convergent
# Validate improvements
npx claude-flow@alpha performance compare \
--baseline ./baseline-metrics.json \
--current ./current-metrics.json
# Generate optimization report
npx claude-flow@alpha performance report \
--show-improvements \
--output ./optimization-report.md
```
### MCP Integration
```javascript
// Get optimization recommendations
mcp__claude-flow__benchmark_run({
type: "swarm",
iterations: 5
})
// Train neural patterns
mcp__claude-flow__neural_train({
agentId: "adaptive-coordinator",
iterations: 10
})
// Check neural patterns
mcp__claude-flow__neural_patterns({
pattern: "all"
})
```
### Optimization Strategies
**Topology Switching:**
```bash
# Switch from hierarchical to mesh if bottleneck detected
if [ "$COORDINATOR_LOAD" -gt 80 ]; then
npx claude-flow@alpha swarm reconfigure --topology mesh
fi
# Switch to ring for sequential processing
if [ "$TASK_TYPE" == "pipeline" ]; then
npx claude-flow@alpha swarm reconfigure --topology ring
fi
```
**Agent Rebalancing:**
```bash
# Identify underutilized agents
npx claude-flow@alpha agent metrics --filter "utilization<0.3"
# Reassign tasks from overloaded agents
npx claude-flow@alpha swarm rebalance --threshold 0.8
# Add agents if all are highly utilized
if [ "$AVG_UTILIZATION" -gt 0.9 ]; then
npx claude-flow@alpha agent spawn --type optimizer --auto-assign
fi
```
**Resource Allocation:**
```bash
# Allocate more memory to high-priority agents
npx claude-flow@alpha agent configure \
--agent-id "agent-001" \
--memory-limit 2048MB
# Adjust coordination intervals
npx claude-flow@alpha swarm configure --sync-interval 3s
```
### Memory Patterns
```bash
# Store optimization actions
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"}'
# Store improvement metrics
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
1. Performance metrics improved by ≥15%
2. Bottlenecks eliminated or reduced
3. Agent utilization balanced (±10%)
4. No errors introduced by optimizations
5. Topology switches completed successfully
## Success Criteria
### Overall Validation
- [ ] Swarm infrastructure stable and operational
- [ ] Optimal topology selected and configured
- [ ] All agents deployed and coordinated
- [ ] Performance monitored and optimized
- [ ] Improvements measured and validated
### 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
1. **Start Simple:** Begin with hierarchical or star topology
2. **Monitor First:** Collect baseline metrics before optimizing
3. **Gradual Scaling:** Add agents incrementally
4. **Test Topology Switches:** Validate in non-production first
5. **Document Patterns:** Record successful configurations
6. **Use Neural Training:** Improve pattern recognition
7. **Enable Auto-Healing:** Configure self-recovery mechanisms
8. **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:
1. Explore specific topology patterns in depth
2. Implement custom coordination protocols
3. Integrate with monitoring systems
4. Create domain-specific swarm templates
5. Experiment with hybrid topologies
## References
- Claude Flow Documentation: https://github.com/ruvnet/claude-flow
- Swarm Intelligence Patterns
- Multi-Agent Coordination Theory
- Dynamic Topology Selection AlgorithmsRelated Skills
using-neon
Guides and best practices for working with Neon Serverless Postgres. Covers getting started, local development with Neon, choosing a connection method, Neon features, authentication (@neondatabase/auth), PostgREST-style data API (@neondatabase/neon-js), Neon CLI, and Neon's Platform API/SDKs. Use for any Neon-related questions.
typescript-advanced-types
Master TypeScript's advanced type system including generics, conditional types, mapped types, template literals, and utility types for building type-safe applications. Use when implementing complex type logic, creating reusable type utilities, or ensuring compile-time type safety in TypeScript projects.
git-advanced-workflows
Master advanced Git workflows including rebasing, cherry-picking, bisect, worktrees, and reflog to maintain clean history and recover from any situation. Use when managing complex Git histories, collaborating on feature branches, or troubleshooting repository issues.
swarm
Autonomous multi-agent workflow system for complex coding tasks. Use when the user requests non-trivial changes that would benefit from autonomous execution with built-in review gates. Ideal for refactoring modules, adding major features, migrating codebases, adding comprehensive test coverage, or any multi-step development task that can run autonomously. NOT for simple fixes, typos, or single-file changes.
when-verifying-quality-use-verification-quality
Comprehensive quality verification and validation through static analysis, dynamic testing, integration validation, and certification gates
when-validating-code-works-use-functionality-audit
Validates that code actually works through sandbox testing, execution verification, and systematic debugging. Use this skill after code generation or modification to ensure functionality is genuine rather than assumed. The skill creates isolated test environments, executes code with realistic inputs, identifies bugs through systematic analysis, and applies best practices to fix issues without breaking existing functionality.
when-using-flow-nexus-platform-use-flow-nexus-platform
Comprehensive Flow Nexus platform management covering authentication, sandboxes, storage, databases, app deployment, payments, and monitoring. This SOP provides end-to-end platform operations.
when-training-neural-networks-use-flow-nexus-neural
This SOP provides a systematic workflow for training and deploying neural networks using Flow Nexus platform with distributed E2B sandboxes. It covers architecture selection, distributed training, ...
when-setting-network-security-use-network-security-setup
Configure Claude Code sandbox network isolation with trusted domains, custom access policies, and environment variables for secure network communication.
when-reviewing-pull-request-orchestrate-comprehensive-code-revie
Use when conducting comprehensive code review for pull requests across multiple quality dimensions. Orchestrates 12-15 specialized reviewer agents across 4 phases using star topology coordination. Covers automated checks, parallel specialized reviews (quality, security, performance, architecture, documentation), integration analysis, and final merge recommendation in a 4-hour workflow.
when-reviewing-github-pr-use-github-code-review
Comprehensive GitHub pull request code review using multi-agent swarm with specialized reviewers for security, performance, style, tests, and documentation. Coordinates security-auditor, perf-analyzer, code-analyzer, tester, and reviewer agents through mesh topology for parallel analysis. Provides detailed feedback with auto-fix suggestions and merge readiness assessment. Use when reviewing PRs, conducting code audits, or ensuring code quality standards before merge.
when-reviewing-code-comprehensively-use-code-review-assistant
Comprehensive PR review with multi-agent swarm specialization for security, performance, style, tests, and documentation