parallel-swarm-implementation
Loop 2 of the Three-Loop Integrated Development System. META-SKILL that dynamically compiles Loop 1 plans into agent+skill execution graphs. Queen Coordinator selects optimal agents from 86-agent registry and assigns skills (when available) or custom instructions. 9-step swarm with theater detection and reality validation. Receives plans from research-driven-planning, feeds to cicd-intelligent-recovery. Use for adaptive, theater-free implementation.
- Category: discovered
- Tags: github, community
- Version: 1.0.0
- Author: walid
- Downloads: 0
- Updated: 2025-11-21
Download the latest version (v1.0.0) from this page.
SKILL.md
---
name: parallel-swarm-implementation
description: Loop 2 of the Three-Loop Integrated Development System. META-SKILL that dynamically compiles Loop 1 plans into agent+skill execution graphs. Queen Coordinator selects optimal agents from 86-agent registry and assigns skills (when available) or custom instructions. 9-step swarm with theater detection and reality validation. Receives plans from research-driven-planning, feeds to cicd-intelligent-recovery. Use for adaptive, theater-free implementation.
---
# Parallel Swarm Implementation (Loop 2) - META-SKILL
## Purpose
**META-SKILL ORCHESTRATOR** that dynamically compiles Loop 1 planning packages into executable agent+skill graphs, then coordinates theater-free parallel implementation.
## Specialist Agent Coordination
I am **Queen Coordinator (Seraphina)** orchestrating the "swarm compiler" pattern.
**Meta-Skill Architecture**:
1. **Analyze** Loop 1 planning package
2. **Select** optimal agents from 86-agent registry per task
3. **Assign** skills to agents (when skills exist) OR generate custom instructions
4. **Create** agent+skill assignment matrix
5. **Execute** dynamically based on matrix with continuous monitoring
6. **Validate** theater-free execution through multi-agent consensus
**Methodology** (9-Step Adaptive SOP):
1. **Initialization**: Queen-led hierarchical topology with dual memory
2. **Analysis**: Queen analyzes Loop 1 plan and creates agent+skill matrix
3. **MECE Validation**: Ensure tasks are Mutually Exclusive, Collectively Exhaustive
4. **Dynamic Deployment**: Spawn agents with skills OR custom instructions per matrix
5. **Theater Detection**: 6-agent consensus validation (0% tolerance)
6. **Integration**: Sandbox testing until 100% working
7. **Documentation**: Auto-sync with implementation
8. **Test Validation**: Reality check all tests
9. **Completion**: Package for Loop 3
**Integration**: Loop 2 of 3. Receives → `research-driven-planning` (Loop 1), Feeds → `cicd-intelligent-recovery` (Loop 3).
---
## When to Use This Skill
Activate this META-SKILL when:
- Have validated plan from Loop 1 with research and risk analysis
- Need production-quality implementation with 0% theater tolerance
- Require adaptive agent+skill selection based on project specifics
- Want parallel multi-agent execution (8.3x speedup)
- Building complex features requiring intelligent coordination
- Need comprehensive audit trails for compliance
**DO NOT** use this skill for:
- Planning phase (use Loop 1: research-driven-planning first)
- Quick prototypes without validated plans
- Trivial single-file changes (direct implementation faster)
**Meta-Skill Nature**: Unlike Loop 1 (fixed 6+8 agent SOPs), Loop 2 is **adaptive**. The Queen Coordinator dynamically selects which agents to use and whether they should follow existing skills or custom instructions based on the specific project.
---
## Input Contract
```yaml
input:
loop1_planning_package: path (required)
# Location: .claude/.artifacts/loop1-planning-package.json
# Must include: specification, research, planning, risk_analysis
execution_options:
max_parallel_agents: number (default: 11, range: 5-20)
# Concurrent agents (more = faster but higher coordination cost)
theater_tolerance: number (default: 0, range: 0-5)
# Percentage of theater allowed (0% recommended)
sandbox_validation: boolean (default: true)
# Execute code in sandbox to prove functionality
integration_threshold: number (default: 100, range: 80-100)
# Required integration test pass rate
agent_preferences:
prefer_skill_based: boolean (default: true)
# Use existing skills when available vs. custom instructions
agent_registry: enum[claude-flow-86, custom] (default: claude-flow-86)
# Which agent ecosystem to use
```
## Output Contract
```yaml
output:
agent_skill_matrix:
total_tasks: number
skill_based_agents: number # Agents using existing skills
custom_instruction_agents: number # Agents with ad-hoc instructions
matrix_file: path # .claude/.artifacts/agent-skill-assignments.json
implementation:
files_created: array[path]
tests_coverage: number # Target: ≥90%
theater_detected: number # Target: 0
sandbox_validation: boolean # Target: true
quality_metrics:
integration_test_pass_rate: number # Target: 100%
functionality_audit_pass: boolean
theater_audit_pass: boolean
code_review_score: number (0-100)
integration:
delivery_package: path # loop2-delivery-package.json
memory_namespace: string # integration/loop2-to-loop3
ready_for_loop3: boolean
```
---
## Prerequisites
Verify Loop 1 completion and load planning context:
```bash
# Validate Loop 1 package exists
test -f .claude/.artifacts/loop1-planning-package.json && echo "✅ Loop 1 Complete" || {
echo "❌ Run research-driven-planning skill first"
exit 1
}
# Load planning data
npx claude-flow@alpha memory query "loop1_complete" \
--namespace "integration/loop1-to-loop2"
# Verify research + risk analysis present
jq '.research.confidence_score, .risk_analysis.final_failure_confidence' \
.claude/.artifacts/loop1-planning-package.json
```
**Expected Output**: Research confidence ≥70%, failure confidence <3%
---
## Step 1: Queen Analyzes & Creates Agent+Skill Matrix (META-ORCHESTRATION)
**Objective**: Queen Coordinator reads Loop 1 plan and dynamically generates agent+skill assignment matrix.
### Execute Queen's Meta-Analysis SOP
**Agent**: Queen Coordinator (Seraphina) - `hierarchical-coordinator`
```javascript
// STEP 1: META-ANALYSIS - Queen Creates Agent+Skill Assignment Matrix
// This is the "swarm compiler" phase
[Single Message - Queen Meta-Orchestration]:
Task("Queen Coordinator (Seraphina)",
`MISSION: Compile Loop 1 planning package into executable agent+skill graph.
PHASE 1: LOAD LOOP 1 CONTEXT
- Load planning package: .claude/.artifacts/loop1-planning-package.json
- Extract: MECE task breakdown, research recommendations, risk mitigations
- Parse: $(jq '.planning.enhanced_plan' .claude/.artifacts/loop1-planning-package.json)
PHASE 2: TASK ANALYSIS
For each task in Loop 1 plan:
1. Identify task type: backend, frontend, database, testing, documentation, infrastructure
2. Determine complexity: simple (1 agent), moderate (2-3 agents), complex (4+ agents)
3. Extract required capabilities from task description
4. Apply Loop 1 research recommendations for technology/library selection
5. Apply Loop 1 risk mitigations as constraints
PHASE 3: AGENT SELECTION (from 86-agent registry)
For each task:
1. Match task type to agent type:
- backend tasks → backend-dev, system-architect
- testing tasks → tester, tdd-london-swarm
- quality tasks → theater-detection-audit, functionality-audit, code-review-assistant
- docs tasks → api-docs, docs-writer
2. Select optimal agent based on:
- Agent capabilities matching task requirements
- Agent availability (workload balancing)
- Agent specialization score
PHASE 4: SKILL ASSIGNMENT (key meta-skill decision)
For each agent assignment:
1. Check if specialized skill exists for this task type:
- Known skills: tdd-london-swarm, theater-detection-audit, functionality-audit,
code-review-assistant, api-docs, database-schema-design, etc.
2. If skill exists:
- useSkill: <skill-name>
- customInstructions: Context-specific parameters for skill
3. If NO skill exists:
- useSkill: null
- customInstructions: Detailed instructions from Loop 1 + Queen's guidance
PHASE 5: GENERATE ASSIGNMENT MATRIX
Create .claude/.artifacts/agent-skill-assignments.json:
{
"project": "<from Loop 1>",
"loop1_package": "integration/loop1-to-loop2",
"tasks": [
{
"taskId": "string",
"description": "string",
"taskType": "enum[backend, frontend, database, test, quality, docs, infrastructure]",
"complexity": "enum[simple, moderate, complex]",
"assignedAgent": "string (from 86-agent registry)",
"useSkill": "string | null",
"customInstructions": "string (detailed if useSkill is null, contextual if using skill)",
"priority": "enum[low, medium, high, critical]",
"dependencies": ["array of taskIds"],
"loop1_research": "relevant research findings",
"loop1_risk_mitigation": "relevant risk mitigations"
}
],
"parallelGroups": [
{
"group": number,
"tasks": ["array of taskIds"],
"reason": "why these can execute in parallel"
}
],
"statistics": {
"totalTasks": number,
"skillBasedAgents": number,
"customInstructionAgents": number,
"uniqueAgents": number,
"estimatedParallelism": "string (e.g., '3 groups, 8.3x speedup')"
}
}
PHASE 6: OPTIMIZATION
1. Identify independent tasks for parallel execution
2. Group dependent tasks into sequential phases
3. Balance agent workload (no agent handles >3 tasks simultaneously)
4. Identify critical path (longest dependency chain)
5. Suggest topology adjustments if needed
VALIDATION CHECKPOINTS:
- All Loop 1 tasks have agent assignments
- No task is assigned to non-existent agent
- Skill-based assignments reference real skills
- Custom instructions are detailed and actionable
- MECE compliance: no overlapping tasks, all requirements covered
- Dependencies are acyclic (no circular deps)
OUTPUT:
1. Store matrix: .claude/.artifacts/agent-skill-assignments.json
2. Memory store: npx claude-flow@alpha memory store 'agent_assignments' "$(cat .claude/.artifacts/agent-skill-assignments.json)" --namespace 'swarm/coordination'
3. Generate execution plan summary
4. Report: skill-based vs custom-instruction breakdown
`,
"hierarchical-coordinator")
```
**Evidence-Based Techniques Applied**:
- **Program-of-Thought**: Explicit 6-phase analysis (load → analyze → select → assign → generate → optimize)
- **Meta-Reasoning**: Queen reasons about which agents should use skills vs. custom instructions
- **Validation Checkpoints**: MECE compliance, dependency validation, assignment completeness
### Queen's Decision: Skill vs. Custom Instructions
**Decision Tree**:
```
For each task:
Does a specialized skill exist?
YES →
useSkill: <skill-name>
customInstructions: Context from Loop 1 (brief)
Benefit: Reusable SOP, proven patterns
NO →
useSkill: null
customInstructions: Detailed instructions from Queen + Loop 1
Benefit: Handles novel tasks, fully adaptive
```
**Example Assignment Matrix** (Authentication System):
```json
{
"project": "User Authentication System",
"tasks": [
{
"taskId": "task-001",
"description": "Implement JWT authentication endpoints",
"taskType": "backend",
"assignedAgent": "backend-dev",
"useSkill": null,
"customInstructions": "Implement JWT auth using jsonwebtoken library per Loop 1 research recommendation. Create endpoints: /auth/login (email+password → JWT), /auth/refresh (refresh token → new JWT), /auth/logout (invalidate refresh token). Apply defense-in-depth token validation per Loop 1 risk mitigation: 1) Validate token signature, 2) Check expiry, 3) Verify user still exists, 4) Check token not in revocation list. Store in src/auth/jwt.ts. Use TypeScript with strict typing.",
"priority": "critical",
"loop1_research": "Library recommendation: jsonwebtoken (10k+ stars, active maintenance)",
"loop1_risk_mitigation": "Defense-in-depth validation (4 layers)"
},
{
"taskId": "task-002",
"description": "Create mock-based unit tests for JWT",
"taskType": "test",
"assignedAgent": "tester",
"useSkill": "tdd-london-swarm",
"customInstructions": "Apply tdd-london-swarm skill (London School TDD) to JWT authentication endpoints. Mock all external dependencies: database, token library, time service. Test scenarios: successful login, invalid credentials, expired token, refresh flow, logout. Target 90% coverage per Loop 1 requirement.",
"priority": "high",
"dependencies": ["task-001"]
},
{
"taskId": "task-003",
"description": "Theater detection scan",
"taskType": "quality",
"assignedAgent": "theater-detection-audit",
"useSkill": "theater-detection-audit",
"customInstructions": "Apply theater-detection-audit skill to scan for: completion theater (TODOs marked done, empty functions), mock theater (100% mocks with no integration validation), test theater (meaningless assertions). Compare against Loop 2 baseline. Zero tolerance - any theater blocks merge.",
"priority": "critical",
"dependencies": ["task-001", "task-002"]
},
{
"taskId": "task-004",
"description": "Sandbox validation",
"taskType": "quality",
"assignedAgent": "functionality-audit",
"useSkill": "functionality-audit",
"customInstructions": "Apply functionality-audit skill. Execute authentication endpoints in isolated sandbox. Test with realistic inputs: valid credentials, SQL injection attempts, XSS payloads. Verify tokens are valid JWTs. Prove functionality is genuine. Generate validation report.",
"priority": "critical",
"dependencies": ["task-001"]
}
],
"parallelGroups": [
{"group": 1, "tasks": ["task-001"], "reason": "Foundation - must complete first"},
{"group": 2, "tasks": ["task-002", "task-004"], "reason": "Independent quality checks"},
{"group": 3, "tasks": ["task-003"], "reason": "Final validation after all implementations"}
],
"statistics": {
"totalTasks": 4,
"skillBasedAgents": 3,
"customInstructionAgents": 1,
"uniqueAgents": 4,
"estimatedParallelism": "3 groups, 2.5x speedup"
}
}
```
**Validation Checkpoint**: Assignment matrix must pass MECE validation and dependency check.
**Output**: `.claude/.artifacts/agent-skill-assignments.json` with complete agent+skill graph
---
## Steps 2-9: Dynamic Execution from Agent+Skill Matrix
**Objective**: Execute implementation using agent+skill assignments from Queen's matrix.
### Step 2-4: Dynamic Agent Deployment (Parallel Execution)
**Agent Coordination Pattern** (Parallel Groups from Matrix):
```bash
#!/bin/bash
# DYNAMIC AGENT DEPLOYMENT - Execute from Agent+Skill Matrix
# Load assignment matrix
MATRIX=".claude/.artifacts/agent-skill-assignments.json"
# For each parallel group in matrix
TOTAL_GROUPS=$(jq '.parallelGroups | length' "$MATRIX")
for GROUP_NUM in $(seq 1 $TOTAL_GROUPS); do
echo "=== Executing Parallel Group $GROUP_NUM/$TOTAL_GROUPS ==="
# Get tasks in this group
TASKS=$(jq -r ".parallelGroups[$((GROUP_NUM-1))].tasks[]" "$MATRIX")
# Spawn all agents in this group in parallel (Single Message)
[Single Message - All Agents in Group $GROUP_NUM]:
for TASK_ID in $TASKS; do
# Extract task details from matrix
AGENT=$(jq -r ".tasks[] | select(.taskId==\"$TASK_ID\") | .assignedAgent" "$MATRIX")
SKILL=$(jq -r ".tasks[] | select(.taskId==\"$TASK_ID\") | .useSkill" "$MATRIX")
INSTRUCTIONS=$(jq -r ".tasks[] | select(.taskId==\"$TASK_ID\") | .customInstructions" "$MATRIX")
PRIORITY=$(jq -r ".tasks[] | select(.taskId==\"$TASK_ID\") | .priority" "$MATRIX")
if [ "$SKILL" != "null" ]; then
# Option A: Agent uses specific skill
echo "Spawning $AGENT with skill: $SKILL"
Task("$AGENT (${TASK_ID})",
"Execute skill: $SKILL
Context from Loop 1:
- Research: $(jq -r ".tasks[] | select(.taskId==\"$TASK_ID\") | .loop1_research" "$MATRIX")
- Risk Mitigation: $(jq -r ".tasks[] | select(.taskId==\"$TASK_ID\") | .loop1_risk_mitigation" "$MATRIX")
Specific Instructions: $INSTRUCTIONS
Coordination:
- Use hooks: npx claude-flow@alpha hooks pre-task --description '$TASK_ID' && npx claude-flow@alpha hooks post-task --task-id '$TASK_ID'
- Store progress: npx claude-flow@alpha memory store '${TASK_ID}_progress' \"<status>\" --namespace 'swarm/realtime'
- Check dependencies complete: $(jq -r ".tasks[] | select(.taskId==\"$TASK_ID\") | .dependencies[]" "$MATRIX" | xargs)
",
"$AGENT",
{ useSkill: "$SKILL", priority: "$PRIORITY", taskId: "$TASK_ID" })
else
# Option B: Agent uses custom instructions
echo "Spawning $AGENT with custom instructions"
Task("$AGENT (${TASK_ID})",
"Task: $(jq -r ".tasks[] | select(.taskId==\"$TASK_ID\") | .description" "$MATRIX")
Detailed Instructions: $INSTRUCTIONS
Context from Loop 1:
- Load planning package: npx claude-flow@alpha memory query 'loop1_complete' --namespace 'integration/loop1-to-loop2'
- Research findings: $(jq -r ".tasks[] | select(.taskId==\"$TASK_ID\") | .loop1_research" "$MATRIX")
- Risk mitigations to apply: $(jq -r ".tasks[] | select(.taskId==\"$TASK_ID\") | .loop1_risk_mitigation" "$MATRIX")
Coordination:
- Use hooks for progress tracking
- Store artifacts in appropriate directories
- Update real-time memory with progress
- Wait for dependencies if any: $(jq -r ".tasks[] | select(.taskId==\"$TASK_ID\") | .dependencies[]" "$MATRIX" | xargs)
",
"$AGENT",
{ priority: "$PRIORITY", taskId: "$TASK_ID" })
fi
done
# Wait for group completion
echo "Waiting for parallel group $GROUP_NUM to complete..."
npx claude-flow@alpha task wait --group "$GROUP_NUM" --namespace "swarm/coordination"
# Queen validates group completion
Task("Queen Coordinator",
"Validate parallel group $GROUP_NUM completion:
1. Check all tasks in group finished successfully
2. Verify no errors or blocks
3. Validate inter-task dependencies satisfied
4. Update overall progress tracking
5. Determine if next group can proceed
If any task failed: pause execution, escalate to user, suggest recovery strategy.
If all tasks passed: proceed to next group.",
"hierarchical-coordinator")
echo "✅ Parallel group $GROUP_NUM complete"
done
echo "✅ All parallel groups executed"
```
**Evidence-Based Techniques Applied**:
- **Dynamic Execution**: Agent spawning driven by matrix (not hardcoded)
- **Skill Polymorphism**: Same framework handles skill-based AND custom-instruction agents
- **Hierarchical Validation**: Queen validates each group before proceeding
### Step 5: Theater Detection (6-Agent Consensus)
**Objective**: Detect and eliminate all forms of theater with multi-agent consensus.
```javascript
// STEP 5: THEATER DETECTION - 6-Agent Consensus Validation
[Single Message - Parallel Theater Detection]:
// Theater Detection Specialists (Multiple Perspectives)
Task("Theater Detector (Code)",
"Scan for completion theater: TODOs marked done, empty functions returning success, mock implementations in production code, hardcoded return values. Check all files created in Steps 2-4. Generate theater-code-report.json.",
"theater-detection-audit",
{ useSkill: "theater-detection-audit" })
Task("Theater Detector (Tests)",
"Scan for test theater: meaningless assertions (assert true === true), tests that don't test (always pass), 100% mocks with no integration validation, missing edge cases. Generate theater-test-report.json.",
"tester")
Task("Theater Detector (Docs)",
"Scan for documentation theater: docs that don't match code, copied templates without customization, placeholder text, outdated examples. Generate theater-docs-report.json.",
"docs-writer")
// Reality Validation Agents
Task("Sandbox Execution Validator",
"Execute all code in i