research-driven-planning

Loop 1 of the Three-Loop Integrated Development System. Research-driven requirements analysis with iterative risk mitigation through 5x pre-mortem cycles using multi-agent consensus. Feeds validated, risk-mitigated plans to parallel-swarm-implementation. Use when starting new features or projects requiring comprehensive planning with <3% failure confidence and evidence-based technology selection.

242 stars

Best use case

research-driven-planning 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. Loop 1 of the Three-Loop Integrated Development System. Research-driven requirements analysis with iterative risk mitigation through 5x pre-mortem cycles using multi-agent consensus. Feeds validated, risk-mitigated plans to parallel-swarm-implementation. Use when starting new features or projects requiring comprehensive planning with <3% failure confidence and evidence-based technology selection.

Loop 1 of the Three-Loop Integrated Development System. Research-driven requirements analysis with iterative risk mitigation through 5x pre-mortem cycles using multi-agent consensus. Feeds validated, risk-mitigated plans to parallel-swarm-implementation. Use when starting new features or projects requiring comprehensive planning with <3% failure confidence and evidence-based technology selection.

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 "research-driven-planning" skill to help with this workflow task. Context: Loop 1 of the Three-Loop Integrated Development System. Research-driven requirements analysis with iterative risk mitigation through 5x pre-mortem cycles using multi-agent consensus. Feeds validated, risk-mitigated plans to parallel-swarm-implementation. Use when starting new features or projects requiring comprehensive planning with <3% failure confidence and evidence-based technology selection.

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

$curl -o ~/.claude/skills/research-driven-planning/SKILL.md --create-dirs "https://raw.githubusercontent.com/aiskillstore/marketplace/main/skills/dnyoussef/research-driven-planning/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/research-driven-planning/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How research-driven-planning Compares

Feature / Agentresearch-driven-planningStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Loop 1 of the Three-Loop Integrated Development System. Research-driven requirements analysis with iterative risk mitigation through 5x pre-mortem cycles using multi-agent consensus. Feeds validated, risk-mitigated plans to parallel-swarm-implementation. Use when starting new features or projects requiring comprehensive planning with <3% failure confidence and evidence-based technology selection.

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.

Related Guides

SKILL.md Source

# Research-Driven Planning (Loop 1)

## Purpose

Comprehensive planning with research-backed solutions and iterative risk mitigation that prevents 85-95% of problems before coding begins.

## Specialist Agent Coordination

I coordinate multi-agent research and planning swarms using **explicit agent SOPs** from Claude-Flow's 86-agent ecosystem.

**Methodology** (SOP: Specification → Research → Planning → Execution → Knowledge):
1. **Specification Phase**: Requirements capture with structured SPEC.md
2. **Research Phase**: 6-agent parallel research with self-consistency validation
3. **Planning Phase**: MECE task decomposition with research integration
4. **Execution Phase**: 8-agent Byzantine consensus pre-mortem (5 iterations)
5. **Knowledge Phase**: Planning package generation for Loop 2 integration

**Integration**: Loop 1 of 3. Feeds → `parallel-swarm-implementation` (Loop 2), Receives ← `cicd-intelligent-recovery` (Loop 3) failure patterns.

---

## When to Use This Skill

Activate this skill when:
- Starting a new feature or project requiring comprehensive planning
- Need to prevent problems before coding begins (85-95% failure prevention)
- Want research-backed solutions instead of assumptions (30-60% time savings)
- Require risk analysis with <3% failure confidence
- Building something complex with multiple failure modes
- Need evidence-based planning that feeds into implementation

**DO NOT** use this skill for:
- Quick fixes or trivial changes (use direct implementation)
- Well-understood repetitive tasks (use existing patterns)
- Emergency hotfixes (skip to Loop 2)

---

## Input Contract

```yaml
input:
  project_description: string (required)
    # High-level description of what needs to be built

  requirements:
    functional: array[string] (required)
      # Core features and capabilities
    non_functional: object (optional)
      performance: string
      security: string
      scalability: string

  constraints:
    technical: array[string] (stack, framework, dependencies)
    timeline: string (deadlines, milestones)
    resources: object (team, budget, infrastructure)

  options:
    research_depth: enum[quick, standard, comprehensive] (default: standard)
    premortem_iterations: number (default: 5, range: 3-10)
    failure_threshold: number (default: 3, target: <3%)
```

## Output Contract

```yaml
output:
  specification:
    spec_file: path  # SPEC.md location
    requirements_complete: boolean
    success_criteria: array[string]

  research:
    evidence_sources: number  # Total research sources
    recommendations: array[object]
      solution: string
      confidence: number (0-100)
      evidence: array[url]
    risk_landscape: array[object]
      risk: string
      severity: enum[low, medium, high, critical]
      mitigation: string

  planning:
    enhanced_plan: path  # plan-enhanced.json location
    total_tasks: number
    task_dependencies: object
    estimated_complexity: string

  risk_analysis:
    premortem_iterations: number
    final_failure_confidence: number  # Target: <3%
    critical_risks_mitigated: number
    defense_strategies: array[string]

  integration:
    planning_package: path  # loop1-planning-package.json
    memory_namespace: string  # integration/loop1-to-loop2
    ready_for_loop2: boolean
```

---

## SOP Phase 1: Specification

**Objective**: Define initial requirements with clarity and structure.

### Create SPEC.md

Generate a comprehensive specification document in the project root:

```markdown
# Project Specification

## Overview
[High-level description of what needs to be built]

## Requirements
### Functional Requirements
1. [Core feature 1]
2. [Core feature 2]
...

### Non-Functional Requirements
- Performance: [metrics]
- Security: [requirements]
- Scalability: [targets]
- Compliance: [standards]

## Constraints
- Technical: [language, framework, dependencies]
- Timeline: [deadlines, milestones]
- Resources: [team size, budget, infrastructure]

## Success Criteria
1. [Measurable outcome 1]
2. [Measurable outcome 2]
...

## Out of Scope
- [Explicitly excluded features]
```

### Store Initial Context

```bash
npx claude-flow@alpha memory store \
  "project_spec" \
  "$(cat SPEC.md)" \
  --namespace "loop1/specification"
```

**Output**: Structured SPEC.md file and memory-stored specification

---

## SOP Phase 2: Research (Multi-Agent Evidence Collection)

**Objective**: Comprehensive solution discovery using evidence-based research with **self-consistency validation**.

### Execute 6-Agent Parallel Research SOP

**Agent Coordination Pattern** (Claude Code Task tool - Single Message):

```javascript
// RESEARCH PHASE: 6-Agent Parallel Evidence Collection
// Self-Consistency: Multiple research perspectives + cross-validation

[Single Message - All 6 Research Agents]:
  // Web Research Agents (3 perspectives for self-consistency)
  Task("Web Research Specialist 1",
    "Research [primary_technology] best practices 2024. Focus on: security patterns, industry standards, implementation approaches. Provide evidence with source URLs. Store findings in .claude/.artifacts/web-research-1.json. Use hooks: npx claude-flow@alpha hooks pre-task --description 'web research 1' && npx claude-flow@alpha hooks post-task --task-id 'web-research-1'",
    "researcher")

  Task("Web Research Specialist 2",
    "Research [technology] libraries comparison. Focus on: developer experience, community support, production reliability, security track record. Cross-validate findings from Specialist 1. Store in .claude/.artifacts/web-research-2.json. Use hooks for coordination.",
    "researcher")

  Task("Academic Research Agent",
    "Research [domain] security research papers and compliance requirements. Focus on: recent vulnerabilities, mitigation strategies, industry standards, regulatory requirements. Store in .claude/.artifacts/academic-research.json.",
    "researcher")

  // GitHub Analysis Agents (code quality perspective)
  Task("GitHub Quality Analyst",
    "Analyze top [technology] libraries on GitHub. Focus on: code quality metrics (test coverage, cyclomatic complexity), issue resolution time, commit frequency, maintainer responsiveness. Generate quality rankings. Store in .claude/.artifacts/github-quality.json.",
    "code-analyzer")

  Task("GitHub Security Auditor",
    "Audit [technology] library security. Focus on: vulnerability history, security advisories, patch response time, dependency security. Flag high-risk libraries. Store in .claude/.artifacts/github-security.json.",
    "security-review")

  // Synthesis Coordinator (Plan-and-Solve pattern)
  Task("Research Synthesis Coordinator",
    "Wait for all 5 research agents to complete. Synthesize findings using self-consistency validation: 1) Aggregate all evidence, 2) Cross-validate conflicting recommendations, 3) Calculate confidence scores based on source agreement, 4) Flag any contradictory evidence, 5) Generate ranked recommendations with evidence. Use Byzantine consensus for critical technology decisions (require 3/5 agent agreement). Store final synthesis in .claude/.artifacts/research-synthesis.json. Memory store: npx claude-flow@alpha memory store 'research_findings' \"$(cat .claude/.artifacts/research-synthesis.json)\" --namespace 'loop1/research'",
    "analyst")
```

**Evidence-Based Techniques Applied**:
- **Self-Consistency**: 3 web research agents + cross-validation
- **Plan-and-Solve**: Synthesis coordinator waits, then validates systematically
- **Program-of-Thought**: Explicit step-by-step synthesis workflow
- **Byzantine Consensus**: 3/5 agreement required for critical decisions

### Research Output

This produces:
- **Solution Rankings**: Best approaches with evidence and confidence scores
- **Pattern Library**: Proven implementation patterns from real codebases
- **Risk Identification**: Known pitfalls from real implementations
- **Technology Recommendations**: Evidence-based stack selection with justifications

**Validation Checkpoint**: Research synthesis must include ≥3 sources per major decision.

**Output**: Evidence-based solution landscape with ranked options and risk data

---

## SOP Phase 3: Planning

**Objective**: Generate structured implementation plans with comprehensive context.

### Step 1: Convert SPEC.md to Structured Plan

Use the spec-to-plan transformation:

```bash
/spec:plan
```

This auto-generates `plan.json` with:
- **Task Breakdown**: Hierarchical task decomposition (MECE: Mutually Exclusive, Collectively Exhaustive)
- **Dependencies**: Task ordering and prerequisites
- **Resource Estimates**: Time, complexity, agent assignments
- **Risk Flags**: Tasks identified as high-risk

### Step 2: Enhance Plan with Research Context

Enrich the plan with research findings:

```bash
# Integration script
node <<'EOF'
const plan = require('./plan.json');
const research = require('./.claude/.artifacts/research-synthesis.json');

// Merge research recommendations into plan tasks
plan.tasks.forEach(task => {
  const relevantPatterns = research.patterns.filter(p =>
    p.relevance.includes(task.domain)
  );
  task.recommendedApproaches = relevantPatterns;
  task.knownRisks = research.risks.filter(r => r.applies_to.includes(task.type));
  task.evidenceSources = relevantPatterns.flatMap(p => p.sources);
});

require('fs').writeFileSync('plan-enhanced.json', JSON.stringify(plan, null, 2));
console.log('✅ Plan enhanced with research context');
EOF
```

### Step 3: Store Enhanced Plan

```bash
npx claude-flow@alpha memory store \
  "enhanced_plan" \
  "$(cat plan-enhanced.json)" \
  --namespace "loop1/planning"
```

**Validation Checkpoint**: Enhanced plan must cover all SPEC.md requirements with research-backed approaches.

**Output**: Structured, research-backed implementation plan

---

## SOP Phase 4: Execution (5-Iteration Byzantine Consensus Pre-mortem)

**Objective**: Identify and mitigate failure modes until <3% failure confidence is achieved using **multi-agent Byzantine consensus**.

### 8-Agent Pre-mortem SOP (5 Iterations)

**Agent Coordination Pattern** (Iterative with Consensus):

```bash
#!/bin/bash
# PRE-MORTEM EXECUTION: 5 Iterations with Byzantine Consensus

for ITERATION in {1..5}; do
  echo "=== Pre-mortem Iteration $ITERATION/5 ==="

  # PARALLEL 8-AGENT RISK ANALYSIS (Single Message)
  # Byzantine Consensus: Require 2/3 agreement on risk severity

  Task("Failure Mode Analyst (Optimistic)",
    "Identify failure modes assuming best-case scenarios. What could still go wrong? Consider: integration failures, performance issues, security vulnerabilities, user experience problems. Store in .claude/.artifacts/premortem-iter-$ITERATION-optimistic.json",
    "analyst")

  Task("Failure Mode Analyst (Pessimistic)",
    "Identify failure modes assuming worst-case scenarios. What disasters lurk? Consider: cascade failures, data corruption, security breaches, scalability collapse. Store in .claude/.artifacts/premortem-iter-$ITERATION-pessimistic.json",
    "analyst")

  Task("Failure Mode Analyst (Realistic)",
    "Identify failure modes based on historical data from Loop 3 feedback (if available). What actually fails in practice? Load historical failures: npx claude-flow@alpha memory query 'loop3_failure_patterns' --namespace 'integration/loop3-feedback'. Store in .claude/.artifacts/premortem-iter-$ITERATION-realistic.json",
    "analyst")

  Task("Root Cause Detective 1",
    "For each identified failure, trace back to root causes using 5-Whys methodology. Distinguish symptoms from actual causes. Store causal chains in .claude/.artifacts/premortem-iter-$ITERATION-causes-1.json",
    "researcher")

  Task("Root Cause Detective 2",
    "Cross-validate root causes using fishbone analysis. Identify systemic vs isolated causes. Compare with Detective 1 findings. Store in .claude/.artifacts/premortem-iter-$ITERATION-causes-2.json",
    "analyst")

  Task("Defense Architect",
    "Design defense-in-depth mitigation strategies. Multiple layers of protection per risk. Prioritize by impact: 1) Prevent failure, 2) Detect early, 3) Recover gracefully. Store in .claude/.artifacts/premortem-iter-$ITERATION-mitigations.json",
    "system-architect")

  Task("Cost-Benefit Analyzer",
    "Evaluate mitigation strategies by cost/benefit ratio. Consider: implementation cost, maintenance cost, risk reduction, performance impact. Generate ROI rankings. Store in .claude/.artifacts/premortem-iter-$ITERATION-cba.json",
    "analyst")

  # BYZANTINE CONSENSUS COORDINATOR (waits for all 7 agents)
  Task("Byzantine Consensus Coordinator",
    "Wait for all 7 agents. Apply Byzantine fault-tolerant consensus: 1) Aggregate all identified risks, 2) Require 2/3 agreement (5/7 agents) on risk severity classification, 3) Cross-validate root causes (both detectives must agree), 4) Select mitigations with positive ROI, 5) Calculate overall failure confidence score. Generate consolidated risk registry. Store in .claude/.artifacts/premortem-iter-$ITERATION-consensus.json. Memory store: npx claude-flow@alpha memory store 'premortem_iteration_$ITERATION' \"$(cat .claude/.artifacts/premortem-iter-$ITERATION-consensus.json)\" --namespace 'loop1/execution'",
    "byzantine-coordinator")

  # Calculate iteration confidence
  CONFIDENCE=$(jq '.consensus.failure_confidence' .claude/.artifacts/premortem-iter-$ITERATION-consensus.json)
  AGREEMENT=$(jq '.consensus.agreement_rate' .claude/.artifacts/premortem-iter-$ITERATION-consensus.json)

  echo "Iteration $ITERATION: Failure Confidence = $CONFIDENCE%, Agreement Rate = $AGREEMENT%"

  # Convergence criteria
  if (( $(echo "$CONFIDENCE < 3" | bc -l) )) && (( $(echo "$AGREEMENT > 66" | bc -l) )); then
    echo "✅ <3% failure confidence achieved with 2/3+ Byzantine consensus at iteration $ITERATION"
    break
  fi

  if [ $ITERATION -eq 5 ] && (( $(echo "$CONFIDENCE >= 3" | bc -l) )); then
    echo "⚠️ Warning: Failed to reach <3% confidence after 5 iterations"
    echo "Consider: 1) Breaking down tasks further, 2) Adding constraints to SPEC.md, 3) Running additional iterations"
  fi
done

# Generate final pre-mortem report
node <<'EOF'
const fs = require('fs');
const iterations = [];
for (let i = 1; i <= 5; i++) {
  try {
    iterations.push(JSON.parse(fs.readFileSync(`.claude/.artifacts/premortem-iter-${i}-consensus.json`, 'utf8')));
  } catch {}
}

const finalReport = {
  iterations_completed: iterations.length,
  final_failure_confidence: iterations[iterations.length - 1].consensus.failure_confidence,
  final_agreement_rate: iterations[iterations.length - 1].consensus.agreement_rate,
  total_risks_identified: iterations.reduce((sum, iter) => sum + iter.risks.length, 0),
  critical_risks_mitigated: iterations[iterations.length - 1].mitigations.filter(m => m.priority === 'critical').length,
  convergence_achieved: iterations[iterations.length - 1].consensus.failure_confidence < 3
};

fs.writeFileSync('.claude/.artifacts/premortem-final.json', JSON.stringify(finalReport, null, 2));
console.log('✅ Pre-mortem complete:', JSON.stringify(finalReport, null, 2));
EOF
```

**Evidence-Based Techniques Applied**:
- **Self-Consistency**: 3 failure mode analysts with different perspectives (optimistic/pessimistic/realistic)
- **Byzantine Consensus**: Fault-tolerant agreement on risk severity (2/3 required)
- **Program-of-Thought**: Explicit 5-Whys + fishbone analysis methodology
- **Iterative Refinement**: 5 cycles with convergence criteria

**Convergence Criteria**:
- Failure confidence < 3%
- Byzantine consensus agreement > 66% (2/3+ agents agree)
- No new high-severity risks identified
- All critical risks have mitigation strategies with positive ROI

**Validation Checkpoint**: Pre-mortem must achieve <3% failure confidence or explain why not.

**Output**: Risk-mitigated plan with <3% failure confidence and comprehensive defense-in-depth strategies

---

## SOP Phase 5: Knowledge (Planning Package Generation)

**Objective**: Package and persist validated planning data for Loop 2 and future iterations.

### Step 1: Generate Planning Package

Create comprehensive planning artifact for Loop 2 integration:

```bash
node <<'EOF'
const fs = require('fs');

const planningPackage = {
  metadata: {
    loop: 1,
    phase: 'research-driven-planning',
    timestamp: new Date().toISOString(),
    nextLoop: 'parallel-swarm-implementation',
    version: '1.0.0'
  },
  specification: {
    file: 'SPEC.md',
    content: fs.readFileSync('SPEC.md', 'utf8'),
    requirements_count: (fs.readFileSync('SPEC.md', 'utf8').match(/^###/gm) || []).length
  },
  research: {
    synthesis: JSON.parse(fs.readFileSync('.claude/.artifacts/research-synthesis.json', 'utf8')),
    evidence_sources: JSON.parse(fs.readFileSync('.claude/.artifacts/research-synthesis.json', 'utf8')).total_sources,
    confidence_score: JSON.parse(fs.readFileSync('.claude/.artifacts/research-synthesis.json', 'utf8')).overall_confidence
  },
  planning: {
    enhanced_plan: JSON.parse(fs.readFileSync('plan-enhanced.json', 'utf8')),
    total_tasks: JSON.parse(fs.readFileSync('plan-enhanced.json', 'utf8')).tasks.length,
    estimated_complexity: JSON.parse(fs.readFileSync('plan-enhanced.json', 'utf8')).metadata.complexity
  },
  risk_analysis: {
    premortem: JSON.parse(fs.readFileSync('.claude/.artifacts/premortem-final.json', 'utf8')),
    final_failure_confidence: JSON.parse(fs.readFileSync('.claude/.artifacts/premortem-final.json', 'utf8')).final_failure_confidence,
    critical_risks_mitigated: JSON.parse(fs.readFileSync('.claude/.artifacts/premortem-final.json', 'utf8')).critical_risks_mitigated
  },
  integrationPoints: {
    feedsTo: 'parallel-swarm-implementation',
    receivesFrom: 'cicd-intelligent-recovery',
    memoryNamespaces: {
      specification: 'loop1/specification',
      research: 'loop1/research',
      planning: 'loop1/planning',
      execution: 'loop1/execution',
      output: 'integration/loop1-to-loop2',
      feedback: 'integration/loop3-feedback'
    }
  }
};

fs.writeFileSync(
  '.claude/.artifacts/loop1-planning-package.json',
  JSON.stringify(planningPackage, null, 2)
);

console.log('✅ Planning package created for Loop 2 integration');
console.log(`   Location: .claude/.artifacts/loop1-planning-package.json`);
console.log(`   Research sources: ${planningPackage.research.evidence_sources}`);
console.log(`   Tasks: ${planningPackage.planning.total_tasks}`);
console.log(`   Failure confidence: ${planningPackage.risk_analysis.final_failure_confidence}%`);
EOF
```

### Step 2: Store in Cross-Loop Memory

```bash
# Store for Loop 2 consumption
npx claude-flow@alpha memory store \
  "loop1_complete" \
  "$(cat .claude/.artifacts/loop1-planning-package.json)" \
  --namespace "integration/loop1-to-loop2"

# Tag for Loop 3 feedback integration
npx claude-flow@alpha memory store \
  "loop1_baseline" \
  "$(cat .claude/.artifacts/loop1-planning-package.json)" \
  --namespace "integration/loop3-feedback"

echo "✅ Planning package stored in cross-loop memory"
echo "   Namespace: integration/loop1-to-loop2"
```

### Step 3: Generate Loop 1 Report

Create human-readable summary:

```bash
cat > docs/loop1-report.md <<'EOF'
# Loop 1: Research-Driven Planning - Complete

## Specification Summary
$(head -20 SPEC.md | tail -15)

## Research Findings
- **Evidence Sources**: $(jq '.research.evidence_sources' .claude/.artifacts/loop1-planning-package.json) sources
- **Top Solution**: $(jq -r '.research.synthesis.recommendations[0].solution' .claude/.artifacts/loop1-planning-package.json)
- **Confidence Score**: $(jq '.research.confidence_score' .claude/.artifacts/loop1-planning-package.json)%

## Enhanced Plan
- **Total Tasks**: $(jq '.planning.total_tasks' .claude/.artifacts/loop1-planning-package.json) tasks
- **Estimated Complexity**: $(jq -r '.planning.estimated_complexity' .claude/.artifacts/loop1-planning-package.json)

## Risk Mitigation
- **Pre-mortem Iterations**: $(jq '.risk_analysis.premortem.iterations_completed' .claude/.artifacts/loop1-planning-package.json)
- **Final Failure Confidence**: $(jq '.risk_analysis.final_failure_confidence' .claude/.artifacts/loop1-planning-package.json)% (Target: <3%)
- **Critical Risks Mitigated**: $(jq '.risk_analysis.critical_risks_mitigated' .claude/.artifacts/loop1-planning-package.json)

## Ready for Loop 2
✅ Planning package: .claude/.artifacts/loop1-planning-package.json
✅ Memory namespace: integration/loop1-to-loop2
✅ Next: Execute parallel-swarm-implementation skill
EOF

echo "✅ Loop 1 report generated: docs/loop1-report.md"
```

**Validation Checkpoint**: Planning package must include all required fields and pass schema validation.

**Output**: Complete planning package ready for Loop 2 integration, stored in both filesystem and persistent memory

---

## Integration with Loop 2 (Development)

After Loop 1 completes, **automatically transition to Loop 2**:

```bash
# Tell Claude Code to proceed to next loop
"Execute parallel-swarm-implementation skill using the planning package from Loop 1.
Load planning data from: .claude/.artifacts/loop1-planning-package.json
Memory namespace: integration/loop1-to-loop2"
```

Loop 2 will:
1. Load Loop 1 planning package from memory
2. Use research findings for MECE task division
3. Apply risk mitigations during implementation
4. Validate theater-free execution against pre-mortem predictions

---

## Integration with Loop 3 (Feedback)

Loop 3 (CI/CD Intelligent Recovery) feeds failure analysis **back to Loop 1** for next iteration:

### Receiving Loop 3 Feedback

When Loop 3 completes, retrieve failure patterns:

```bash
npx claude-flow@alpha memory query "loop3_failure_patterns" \
  --namespace "integration/loop3-feedback"
```

### Incorporate into Next Pre-mortem

Use failure data to enhance future risk analysis:

```bash
# Next project's pre-mortem receives historical data
# The Realistic Failure Mode Analyst will automatically load this data
```

This creates **continuous improvement** where:
- Real failures inform future risk analysis
- Pre-mortem becomes more accurate over time
- Planning improves with each project cycle

---

## Performance Benchmarks

**Time Investment**: 6-11 hours (20-30% of total project time)
**Time Savings**: 30-60% reduction in rework and debugging
**Failure Prevention**: 85-95% of potential issues caught pre-implementation
**ROI**: 2-3x return through prevented failures and reduced rework

**Typical Timeline**:
- Specification: 1-2 hours
- Research (6-agent parallel): 2-4 hours (30-60% faster than manual)
- Planning: 1-2 hours
- Pre-mortem (8-agent × 5 iterations): 2-3 hours
- **Total**: 6-11 hours for comprehensive planning

**Comparison**:
| Metric | Traditional Planning | Loop 1 (Research-Driven) |
|--------|---------------------|--------------------------|
| Time | 2-4 hours | 6-11 hours |
| Research Sources | 0-2 | 10-30+ (6-agent parallel) |
| Risk Analysis | Ad-hoc | 5-iteration Byzantine consensus |
| Failure Prevention | 30-50% | 85-95% |
| ROI | 1x | 2-3x |

---

## Troubleshooting

### Research Returns Low-Quality Results

**Symptom**: Generic or outdated solutions, low confidence scores
**Diagnosis**: Check `.claude/.artifacts/research-synthesis.json` for evidence quality
**Fix**:
```bash
# Refine search queries with specific constraints
# Re-run with more targeted research agents
Task("Web Research Specialist 1",
  "Research [technology] [use-case] 2024 production security best-practices enterprise-grade",
  "researcher")
```

### Pre-mortem Not Converging

**Symptom**: Failure confidence stays >3% after 5 iterations, low Byzantine consensus
**Diagnosis**: Check agreement rates in premortem iteration files
**Fix**:
1. Break down plan into smaller, more manageable tasks
2. Add more specific constraints to SPEC.md
3. Run additional pre-mortem cycles (up to 10):
   ```bash
   # Extend iterations
   for ITERATION in {6..10}; do
     # ... (same 8-agent SOP)
   done
   ```
4. Consult domain experts for known failure modes

### Loop 2 Integration Failure

**Symptom**: Loop 2 can't load planning package
**Diagnosis**: Memory namespace or file access issue
**Fix**:
```bash
# Verify memory storage
npx claude-flow@alpha memory query "loop1_complete" \
  --namespace "integration/loop1-to-loop2"

# Verify file exists
ls -lh .claude/.artifacts/loop1-planning-package.json

# Regenerate package if needed
node scripts/generate-planning-package.js
```

---

## Success Criteria

Loop 1 is successful when:
- ✅ SPEC.md captures all requirements completely
- ✅ Research provides evidence-based recommendations (≥3 sources per major decision)
- ✅ Research confidence score ≥70%
- ✅ Plan covers all SPEC.md requirements with task breakdown
- ✅ Pre-mortem achieves <3% failure confidence
- ✅ Byzantine consensus ≥66% agreement on all critical risks
- ✅ All critical risks have documented mitigation strategies with positive ROI
- ✅ Planning package successfully loads in Loop 2
- ✅ Memory namespaces populated with complete data

**Validation Command**:
```bash
npx claude-flow@alpha memory query "loop1_complete" \
  --namespace "integration/loop1-to-loop2" \
  --validate-schema
```

---

## Memory Namespaces

Loop 1 uses these memory locations:

| Namespace | Purpose | Producers | Consumers |
|-----------|---------|-----------|-----------|
| `loop1/specification` | SPEC.md and requirements | Specification phase | Loop 1, Loop 2 |
| `loop1/research` | Research findings and evidence | 6-agent research swarm | Loop 1, Loop 2 |
| `loop1/planning` | Enhanced plans and task breakdowns | Planning phase | Loop 2 |
| `loop1/execution` | Pre-mortem results and risk analysis | 8-agent pre-mortem swarm | Loop 2, Loop 3 |
| `integration/loop1-to-loop2` | Planning package for Loop 2 | Knowledge phase | Loop 2 |
| `integration/loop3-feedback` | Failure patterns from Loop 3 | Loop 3 | Loop 1 (next iteration) |

---

## Related Skills

- **parallel-swarm-implementation** - Loop 2: Implementation (receives Loop 1 output)
- **cicd-intelligent-recovery** - Loop 3: Quality & Debugging (provides feedback to Loop 1)
- **intent-analyzer** - Deep intent understanding for requirement clarification
- **skill-forge** - Skill creation methodology used to build this skill

---

## Example: Complete Loop 1 Execution

### User Authentication System

```bash
# ===== PHASE 1: SPECIFICATION =====
cat > SPEC.md <<'EOF'
# User Authentication System

## Requirements
### Functional
- JWT-based authentication with refresh tokens
- Role-based access control (RBAC)
- Password reset functionality
- Two-factor authentication (TOTP)

### Non-Functional
- Performance: <100ms auth check
- Security: OWASP Top 10 compliance
- Scalability: 10,000 concurrent users

## Constraints
- Must integrate with existing Express.js API
- PostgreSQL database
- Deploy to AWS Lambda

## Success Criteria
1. 100% auth endpoint coverage
2. Zero critical vulnerabilities
3. <100ms 99th percentile latency
EOF

npx claude-flow@alpha memory store "project_spec" "$(cat SPEC.md)" --namespace "loop1/specification"

# ===== PHASE 2: RESEARCH (6-Agent Parallel) =====
# (Execute 6-agent research SOP as documented above)
# Results in .claude/.artifacts/research-synthesis.json

# ===== PHASE 3: PLANNING =====
/spec:plan
node scripts/enhance-plan-with-research.js

# ===== PHASE 4: EXECUTION (8-Agent × 5 Iterations Pre-mortem) =====
# (Execute 8-agent Byzantine consensus pre-mortem as documented above)
# Results in .claude/.artifacts/premortem-final.json

# ===== PHASE 5: KNOWLEDGE =====
node scripts/generate-planning-package.js

# ===== VERIFY SUCCESS =====
echo "✅ Loop 1 Complete"
echo "📊 Results:"
jq '{
  research_sources: .research.evidence_sources,
  tasks: .planning.total_tasks,
  failure_confidence: .risk_analysis.final_failure_confidence,
  ready: true
}' .claude/.artifacts/loop1-planning-package.json

echo ""
echo "➡️  Next: Execute parallel-swarm-implementation skill"
```

---

**Status**: Production-Ready with Explicit Agent SOPs
**Version**: 2.0.0 (Optimized with Prompt-Architect Principles)
**Loop Position**: 1 of 3 (Planning)
**Integration**: Feeds Loop 2, Receives from Loop 3
**Agent Coordination**: 6-agent research + 8-agent pre-mortem with Byzantine consensus

Related Skills

task-planning

242
from aiskillstore/marketplace

Plan and organize software development tasks effectively. Use when breaking down features, creating user stories, or planning sprints. Handles task breakdown, user stories, acceptance criteria, and backlog management.

wiki-researcher

242
from aiskillstore/marketplace

Conducts multi-turn iterative deep research on specific topics within a codebase with zero tolerance for shallow analysis. Use when the user wants an in-depth investigation, needs to understand how something works across multiple files, or asks for comprehensive analysis of a specific system or pattern.

research-engineer

242
from aiskillstore/marketplace

An uncompromising Academic Research Engineer. Operates with absolute scientific rigor, objective criticism, and zero flair. Focuses on theoretical correctness, formal verification, and optimal implementation across any required technology.

domain-driven-design

242
from aiskillstore/marketplace

Plan and route Domain-Driven Design work from strategic modeling to tactical implementation and evented architecture patterns.

data-engineering-data-driven-feature

242
from aiskillstore/marketplace

Build features guided by data insights, A/B testing, and continuous measurement using specialized agents for analysis, implementation, and experimentation.

context7-auto-research

242
from aiskillstore/marketplace

Automatically fetch latest library/framework documentation for Claude Code via Context7 API

context-driven-development

242
from aiskillstore/marketplace

Use this skill when working with Conductor's context-driven development methodology, managing project context artifacts, or understanding the relationship between product.md, tech-stack.md, and workflow.md files.

concise-planning

242
from aiskillstore/marketplace

Use when a user asks for a plan for a coding task, to generate a clear, actionable, and atomic checklist.

research-merge

242
from aiskillstore/marketplace

Processes research branches from Claude Code Web sessions - merges content, moves docs to docs/research/, and creates GitHub issues. Use when /popkit:next detects research branches or when manually processing research from mobile sessions. Do NOT use for regular feature branches - only for branches matching claude/research-* or containing research documentation.

agile-planning

242
from aiskillstore/marketplace

Generate agile release plans with sprints and roadmaps using unique sprint codes. Use when creating sprint schedules, product roadmaps, release planning, or when user mentions agile planning, sprints, roadmap, or release plans.

type-driven-design-rust

242
from aiskillstore/marketplace

Type-driven design patterns in Rust - typestate, newtype, builder pattern, and compile-time guarantees

planning

242
from aiskillstore/marketplace

Transform ideas into actionable implementation plans. Combines Socratic questioning for requirements discovery with detailed task breakdown for zero-context engineers. Use before any feature development.