skills/dnyoussef/when-orchestrating-swarm-use-swarm-orchestration/SKILL.md
Complex multi-agent swarm orchestration with task decomposition, distributed execution, and result synthesis
npx skillsauth add aiskillstore/marketplace when-orchestrating-swarm-use-swarm-orchestrationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill implements complex multi-agent swarm orchestration with intelligent task decomposition, distributed execution, progress monitoring, and result synthesis. It enables coordinated execution of complex workflows across multiple specialized agents.
Role: Central orchestration and task decomposition Responsibilities:
Role: Hierarchical task delegation and coordination Responsibilities:
Role: Dynamic workload balancing and optimization Responsibilities:
Analyze complex task requirements and create detailed decomposition plan with dependency mapping.
# Analyze task complexity
npx claude-flow@alpha task analyze --task "Build full-stack application" --output task-analysis.json
# Generate decomposition tree
npx claude-flow@alpha task decompose \
--task "Build full-stack application" \
--max-depth 3 \
--output decomposition.json
# Visualize decomposition
npx claude-flow@alpha task visualize --input decomposition.json --output task-tree.png
# Store decomposition in memory
npx claude-flow@alpha memory store \
--key "orchestration/decomposition" \
--file decomposition.json
# Identify dependencies
npx claude-flow@alpha task dependencies \
--input decomposition.json \
--output dependencies.json
# Plan agent assignments
npx claude-flow@alpha task plan \
--decomposition decomposition.json \
--available-agents 12 \
--output execution-plan.json
Level 1: High-Level Goals
{
"task": "Build full-stack application",
"subtasks": [
"Design architecture",
"Implement backend",
"Implement frontend",
"Setup infrastructure",
"Testing and QA"
]
}
Level 2: Component Tasks
{
"task": "Implement backend",
"subtasks": [
"Design API endpoints",
"Implement authentication",
"Setup database",
"Create business logic",
"API documentation"
]
}
Level 3: Atomic Tasks
{
"task": "Implement authentication",
"subtasks": [
"Setup JWT library",
"Create user model",
"Implement login endpoint",
"Implement registration endpoint",
"Add password hashing",
"Create auth middleware"
]
}
# Store orchestration plan
npx claude-flow@alpha memory store \
--key "orchestration/plan" \
--value '{
"totalTasks": 45,
"levels": 3,
"estimatedDuration": "2h 30m",
"requiredAgents": 12
}'
# Store dependency graph
npx claude-flow@alpha memory store \
--key "orchestration/dependencies" \
--value '{
"task-003": ["task-001", "task-002"],
"task-008": ["task-003", "task-004"],
"task-012": ["task-008", "task-009"]
}'
Setup swarm infrastructure with appropriate topology and coordinator agents.
# Determine optimal topology
TASK_COUNT=$(jq '.totalTasks' decomposition.json)
if [ "$TASK_COUNT" -gt 30 ]; then
TOPOLOGY="mesh"
elif [ "$TASK_COUNT" -gt 15 ]; then
TOPOLOGY="hierarchical"
else
TOPOLOGY="star"
fi
# Initialize swarm with optimal topology
npx claude-flow@alpha swarm init \
--topology $TOPOLOGY \
--max-agents 15 \
--strategy adaptive
# Spawn task orchestrator
npx claude-flow@alpha agent spawn \
--type coordinator \
--role "task-orchestrator" \
--capabilities "task-decomposition,assignment,synthesis"
# Spawn hierarchical coordinator
npx claude-flow@alpha agent spawn \
--type coordinator \
--role "hierarchical-coordinator" \
--capabilities "hierarchy-management,delegation"
# Spawn adaptive coordinator
npx claude-flow@alpha agent spawn \
--type coordinator \
--role "adaptive-coordinator" \
--capabilities "workload-balancing,optimization"
# Verify swarm status
npx claude-flow@alpha swarm status --show-agents --show-topology
// Initialize swarm
mcp__claude-flow__swarm_init({
topology: "hierarchical",
maxAgents: 15,
strategy: "adaptive"
})
// Spawn coordinators
mcp__claude-flow__agent_spawn({
type: "coordinator",
name: "task-orchestrator",
capabilities: ["task-decomposition", "assignment", "synthesis"]
})
mcp__claude-flow__agent_spawn({
type: "coordinator",
name: "hierarchical-coordinator",
capabilities: ["hierarchy-management", "delegation"]
})
mcp__claude-flow__agent_spawn({
type: "coordinator",
name: "adaptive-coordinator",
capabilities: ["workload-balancing", "optimization"]
})
# Store swarm configuration
npx claude-flow@alpha memory store \
--key "orchestration/swarm" \
--value '{
"swarmId": "swarm-12345",
"topology": "hierarchical",
"maxAgents": 15,
"coordinators": ["task-orchestrator", "hierarchical-coordinator", "adaptive-coordinator"]
}'
Coordinate distributed task execution across swarm agents with proper dependency handling.
# Spawn specialized agents based on task requirements
npx claude-flow@alpha agent spawn --type researcher --count 2
npx claude-flow@alpha agent spawn --type coder --count 5
npx claude-flow@alpha agent spawn --type reviewer --count 2
npx claude-flow@alpha agent spawn --type tester --count 2
# Orchestrate task execution
npx claude-flow@alpha task orchestrate \
--plan execution-plan.json \
--strategy adaptive \
--max-agents 12 \
--priority high
# Alternative: Orchestrate with MCP
# mcp__claude-flow__task_orchestrate({
# task: "Execute full-stack application build",
# strategy: "adaptive",
# maxAgents: 12,
# priority: "high"
# })
# Monitor orchestration status
npx claude-flow@alpha task status --detailed --json > task-status.json
# Track individual task progress
npx claude-flow@alpha task list --filter "in_progress" --show-timing
# Monitor agent workloads
npx claude-flow@alpha agent metrics --metric tasks --format table
#!/bin/bash
# assign-tasks.sh
# Read decomposition
TASKS=$(jq -r '.tasks[] | @json' decomposition.json)
for TASK in $TASKS; do
TASK_ID=$(echo $TASK | jq -r '.id')
TASK_TYPE=$(echo $TASK | jq -r '.type')
DEPENDENCIES=$(echo $TASK | jq -r '.dependencies[]')
# Check if dependencies completed
DEPS_COMPLETE=true
for DEP in $DEPENDENCIES; do
DEP_STATUS=$(npx claude-flow@alpha task status --task-id $DEP --format json | jq -r '.status')
if [ "$DEP_STATUS" != "completed" ]; then
DEPS_COMPLETE=false
break
fi
done
# Assign task if dependencies complete
if [ "$DEPS_COMPLETE" = true ]; then
# Find least loaded agent of required type
AGENT_ID=$(npx claude-flow@alpha agent list \
--filter "type=$TASK_TYPE" \
--sort-by load \
--format json | jq -r '.[0].id')
# Assign task
npx claude-flow@alpha task assign \
--task-id $TASK_ID \
--agent-id $AGENT_ID
echo "Assigned task $TASK_ID to agent $AGENT_ID"
fi
done
# Store task assignments
npx claude-flow@alpha memory store \
--key "orchestration/assignments" \
--value '{
"task-001": {"agent": "agent-researcher-1", "status": "in_progress", "started": "2025-10-30T10:00:00Z"},
"task-002": {"agent": "agent-coder-1", "status": "in_progress", "started": "2025-10-30T10:01:00Z"}
}'
# Store execution timeline
npx claude-flow@alpha memory store \
--key "orchestration/timeline" \
--value '{
"started": "2025-10-30T10:00:00Z",
"tasksCompleted": 12,
"tasksInProgress": 8,
"tasksPending": 25
}'
Track execution progress, identify blockers, and maintain real-time visibility.
# Start continuous monitoring
npx claude-flow@alpha swarm monitor \
--interval 10 \
--duration 3600 \
--output orchestration-monitor.log &
# Track task completion rate
while true; do
COMPLETED=$(npx claude-flow@alpha task list --filter "completed" | wc -l)
TOTAL=$(npx claude-flow@alpha task list | wc -l)
PROGRESS=$((COMPLETED * 100 / TOTAL))
echo "Progress: $PROGRESS% ($COMPLETED/$TOTAL tasks)"
npx claude-flow@alpha memory store \
--key "orchestration/progress" \
--value "{\"completed\": $COMPLETED, \"total\": $TOTAL, \"percentage\": $PROGRESS}"
sleep 30
done &
# Monitor for blocked tasks
npx claude-flow@alpha task detect-blocked \
--threshold 300 \
--notify-on-block
# Monitor agent health
npx claude-flow@alpha agent health-check --all --interval 60
# Generate progress report
npx claude-flow@alpha orchestration report \
--include-timeline \
--include-agent-metrics \
--output progress-report.md
# Generate Gantt chart
npx claude-flow@alpha task gantt \
--input task-status.json \
--output gantt-chart.png
# Generate network diagram
npx claude-flow@alpha task network \
--show-dependencies \
--show-progress \
--output network-diagram.png
# Store progress snapshots
npx claude-flow@alpha memory store \
--key "orchestration/snapshot-$(date +%s)" \
--value '{
"timestamp": "'$(date -Iseconds)'",
"completed": 18,
"inProgress": 12,
"pending": 15,
"blocked": 0,
"failed": 0
}'
# Store blocker information
npx claude-flow@alpha memory store \
--key "orchestration/blockers" \
--value '{
"task-015": {"reason": "dependency-failed", "since": "2025-10-30T10:15:00Z"},
"task-022": {"reason": "agent-unresponsive", "since": "2025-10-30T10:20:00Z"}
}'
Aggregate and synthesize results from all completed tasks into coherent outputs.
# Collect all task results
npx claude-flow@alpha task results --all --format json > all-results.json
# Synthesize results by category
npx claude-flow@alpha task synthesize \
--input all-results.json \
--group-by category \
--output synthesized-results.json
# Generate final outputs
npx claude-flow@alpha orchestration finalize \
--results synthesized-results.json \
--output final-output/
# Validate outputs
npx claude-flow@alpha orchestration validate \
--output final-output/ \
--criteria validation-criteria.json
# Generate final report
npx claude-flow@alpha orchestration report \
--type final \
--include-metrics \
--include-timeline \
--include-outputs \
--output final-orchestration-report.md
# Archive orchestration data
npx claude-flow@alpha orchestration archive \
--output orchestration-archive-$(date +%Y%m%d-%H%M%S).tar.gz
// Get task results
mcp__claude-flow__task_results({
taskId: "all",
format: "detailed"
})
// Check final status
mcp__claude-flow__task_status({
detailed: true
})
1. Collect Results:
# Get results from each agent type
RESEARCHER_RESULTS=$(npx claude-flow@alpha task results --agent-type researcher --format json)
CODER_RESULTS=$(npx claude-flow@alpha task results --agent-type coder --format json)
REVIEWER_RESULTS=$(npx claude-flow@alpha task results --agent-type reviewer --format json)
2. Aggregate by Phase:
# Architecture phase results
ARCHITECTURE=$(jq '[.[] | select(.phase=="architecture")]' all-results.json)
# Implementation phase results
IMPLEMENTATION=$(jq '[.[] | select(.phase=="implementation")]' all-results.json)
# Testing phase results
TESTING=$(jq '[.[] | select(.phase=="testing")]' all-results.json)
3. Synthesize Final Output:
# Combine all results
jq -s '{
architecture: .[0],
implementation: .[1],
testing: .[2],
metadata: {
totalTasks: (.[0] + .[1] + .[2] | length),
duration: "'$(date -Iseconds)'",
successRate: 0.98
}
}' \
<(echo "$ARCHITECTURE") \
<(echo "$IMPLEMENTATION") \
<(echo "$TESTING") \
> final-synthesis.json
# Store final results
npx claude-flow@alpha memory store \
--key "orchestration/results/final" \
--file final-synthesis.json
# Store performance metrics
npx claude-flow@alpha memory store \
--key "orchestration/metrics/final" \
--value '{
"totalTasks": 45,
"completed": 44,
"failed": 1,
"duration": "2h 18m",
"avgTaskTime": "3m 5s",
"throughput": "0.32 tasks/min"
}'
Symptoms: Tasks blocked waiting for dependencies Solution: Verify dependency graph, check for circular dependencies
Symptoms: Some agents at 100% utilization, others idle Solution: Rebalance task assignments, spawn additional agents
Symptoms: Tasks remain in-progress indefinitely Solution: Implement timeout mechanism, restart stuck agents
Symptoms: Missing results in final output Solution: Verify all tasks completed, check result collection logic
After completing this skill:
development
Apple Human Interface Guidelines for content display components. Use this skill when the user asks about charts component, collection view, image view, web view, color well, image well, activity view, lockup, data visualization, content display, displaying images, rendering web content, color pickers, or presenting collections of items in Apple apps. Also use when the user says how should I display charts, what's the best way to show images, should I use a web view, how do I build a grid of items, what component shows media, or how do I present a share sheet. Cross-references: hig-foundations for color/typography/accessibility, hig-patterns for data visualization patterns, hig-components-layout for structural containers, hig-platforms for platform-specific component behavior.
tools
Automate HelpDesk tasks via Rube MCP (Composio): list tickets, manage views, use canned responses, and configure custom fields. Always search tools first for current schemas.
testing
Expert Haskell engineer specializing in advanced type systems, pure functional design, and high-reliability software. Use PROACTIVELY for type-level programming, concurrency, and architecture guidance.
tools
GraphQL gives clients exactly the data they need - no more, no less. One endpoint, typed schema, introspection. But the flexibility that makes it powerful also makes it dangerous. Without proper controls, clients can craft queries that bring down your server. This skill covers schema design, resolvers, DataLoader for N+1 prevention, federation for microservices, and client integration with Apollo/urql. Key insight: GraphQL is a contract. The schema is the API documentation. Design it carefully.