> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/obra/superpowers/llms.txt
> Use this file to discover all available pages before exploring further.

# Subagent-Driven Development

> Dispatch fresh subagents per task with two-stage review for fast, high-quality iteration

## Overview

Subagent-Driven Development executes implementation plans by dispatching a fresh subagent for each task, followed by two-stage review: spec compliance first, then code quality.

<Note>
  **Core principle:** Fresh subagent per task + two-stage review (spec then quality) = high quality, fast iteration
</Note>

## When to Use

```mermaid theme={null}
graph TD
    A[Have implementation plan?] -->|Yes| B[Tasks mostly independent?]
    A -->|No| C[Manual execution or brainstorm first]
    B -->|Yes| D[Stay in this session?]
    B -->|No - tightly coupled| C
    D -->|Yes| E[subagent-driven-development]
    D -->|No - parallel session| F[executing-plans]
```

Use when:

* You have an implementation plan from [Writing Plans](/skills/writing-plans)
* Tasks are mostly independent
* You want to stay in the current session (not switch to parallel session)

**vs. Executing Plans (parallel session):**

* Same session (no context switch)
* Fresh subagent per task (no context pollution)
* Two-stage review after each task
* Faster iteration (no human-in-loop between tasks)

## The Process

<Steps>
  <Step title="Read Plan and Create Todos">
    1. Read plan file once: `docs/plans/YYYY-MM-DD-feature.md`
    2. Extract all tasks with full text and context
    3. Create TodoWrite with all tasks

    <Note>
      Read the plan file once upfront. Extract all task details so you can provide them to subagents without making them read the file.
    </Note>
  </Step>

  <Step title="Dispatch Implementer Subagent">
    Use `./implementer-prompt.md` template to dispatch subagent with:

    * Full task text (already extracted)
    * Context about where task fits
    * Scene-setting (what's already built, what this adds)

    **Implementer subagent workflow:**

    1. May ask questions before starting
    2. Implements following TDD
    3. Tests the implementation
    4. Commits the changes
    5. Self-reviews the code

    **If subagent asks questions:**

    * Answer clearly and completely
    * Provide additional context if needed
    * Let them proceed once answered
  </Step>

  <Step title="Dispatch Spec Compliance Reviewer">
    Use `./spec-reviewer-prompt.md` template to dispatch reviewer:

    * Provide task spec
    * Provide what was implemented

    **Spec reviewer confirms:**

    * ✅ All spec requirements met
    * ✅ Nothing extra added (no YAGNI violations)
    * ❌ Lists any missing requirements
    * ❌ Lists any extra features

    <Warning>
      **Do NOT proceed to code quality review until spec compliance is ✅**

      Wrong order wastes effort reviewing code that doesn't match spec.
    </Warning>

    **If reviewer finds issues:**

    1. Implementer (same subagent) fixes them
    2. Spec reviewer reviews again
    3. Repeat until ✅
  </Step>

  <Step title="Dispatch Code Quality Reviewer">
    Use `./code-quality-reviewer-prompt.md` template:

    * Provide git SHAs for the changes
    * Ask for code quality assessment

    **Code reviewer assesses:**

    * Strengths of implementation
    * Issues (Important / Minor / Nitpick)
    * Approval or required changes

    **If reviewer finds issues:**

    1. Implementer fixes them
    2. Code reviewer reviews again
    3. Repeat until approved
  </Step>

  <Step title="Mark Task Complete">
    Once both reviews approved:

    * Mark task completed in TodoWrite
    * Move to next task
  </Step>

  <Step title="After All Tasks">
    1. Dispatch final code reviewer for entire implementation
    2. Use `superpowers:finishing-a-development-branch` skill
  </Step>
</Steps>

## Visual Workflow

```mermaid theme={null}
graph TD
    A[Read plan, extract tasks, create TodoWrite] --> B[Dispatch implementer]
    B --> C{Asks questions?}
    C -->|Yes| D[Answer questions]
    D --> B
    C -->|No| E[Implements, tests, commits, self-reviews]
    E --> F[Dispatch spec reviewer]
    F --> G{Spec compliant?}
    G -->|No| H[Implementer fixes]
    H --> F
    G -->|Yes| I[Dispatch code quality reviewer]
    I --> J{Approved?}
    J -->|No| K[Implementer fixes]
    K --> I
    J -->|Yes| L[Mark complete]
    L --> M{More tasks?}
    M -->|Yes| B
    M -->|No| N[Final review + finishing skill]
```

## Prompt Templates

The skill includes three prompt templates:

<CardGroup cols={3}>
  <Card title="Implementer" icon="code">
    `./implementer-prompt.md`

    Dispatch to implement task with TDD
  </Card>

  <Card title="Spec Reviewer" icon="clipboard-check">
    `./spec-reviewer-prompt.md`

    Verify implementation matches spec
  </Card>

  <Card title="Code Quality Reviewer" icon="sparkles">
    `./code-quality-reviewer-prompt.md`

    Assess code quality and suggest improvements
  </Card>
</CardGroup>

## Example Workflow

<Accordion title="Complete Multi-Task Example">
  ```
  You: I'm using Subagent-Driven Development to execute this plan.

  [Read plan file once: docs/plans/2026-03-09-metrics.md]
  [Extract all 5 tasks with full text and context]
  [Create TodoWrite with all tasks]

  ---

  Task 1: Hook installation script

  [Get Task 1 text and context (already extracted)]
  [Dispatch implementation subagent with full task text + context]

  Implementer: "Before I begin - should the hook be installed at 
                user or system level?"

  You: "User level (~/.config/superpowers/hooks/)"

  Implementer: "Got it. Implementing now..."

  [Later]

  Implementer:
    - Implemented install-hook command
    - Added tests, 5/5 passing
    - Self-review: Found I missed --force flag, added it
    - Committed: abc123f

  [Dispatch spec compliance reviewer]

  Spec reviewer: ✅ Spec compliant
    - All requirements met
    - Nothing extra added

  [Get git SHAs, dispatch code quality reviewer]

  Code reviewer:
    Strengths: Good test coverage, clean implementation
    Issues: None
    ✅ Approved

  [Mark Task 1 complete]

  ---

  Task 2: Recovery modes

  [Get Task 2 text and context (already extracted)]
  [Dispatch implementation subagent with full task text + context]

  Implementer: [No questions, proceeds]

  Implementer:
    - Added verify/repair modes
    - 8/8 tests passing
    - Self-review: All good
    - Committed: def456a

  [Dispatch spec compliance reviewer]

  Spec reviewer: ❌ Issues:
    - Missing: Progress reporting (spec says "report every 100 items")
    - Extra: Added --json flag (not requested)

  [Implementer fixes issues]

  Implementer: 
    - Removed --json flag
    - Added progress reporting
    - Committed: ghi789b

  [Spec reviewer reviews again]

  Spec reviewer: ✅ Spec compliant now

  [Dispatch code quality reviewer]

  Code reviewer:
    Strengths: Solid implementation
    Issues (Important): Magic number (100) should be constant

  [Implementer fixes]

  Implementer:
    - Extracted PROGRESS_INTERVAL constant
    - Committed: jkl012c

  [Code reviewer reviews again]

  Code reviewer: ✅ Approved

  [Mark Task 2 complete]

  ---

  [Tasks 3-5 similar...]

  ---

  All tasks complete!

  [Dispatch final code reviewer]

  Final reviewer: All requirements met, ready to merge

  Using finishing-a-development-branch skill...
  ```
</Accordion>

## Advantages

### vs. Manual Execution

* Subagents follow TDD naturally
* Fresh context per task (no confusion)
* Parallel-safe (subagents don't interfere)
* Subagent can ask questions (before AND during work)

### vs. Executing Plans

* Same session (no handoff)
* Continuous progress (no waiting)
* Review checkpoints automatic

### Efficiency Gains

* No file reading overhead (controller provides full text)
* Controller curates exactly what context is needed
* Subagent gets complete information upfront
* Questions surfaced before work begins (not after)

### Quality Gates

* Self-review catches issues before handoff
* **Two-stage review: spec compliance, then code quality**
* Review loops ensure fixes actually work
* Spec compliance prevents over/under-building
* Code quality ensures implementation is well-built

### Cost

**Higher invocation cost:**

* More subagent invocations (implementer + 2 reviewers per task)
* Controller does more prep work (extracting all tasks upfront)
* Review loops add iterations

**But catches issues early (cheaper than debugging later)**

## Red Flags

**Never:**

* Start implementation on main/master branch without explicit user consent
* Skip reviews (spec compliance OR code quality)
* Proceed with unfixed issues
* Dispatch multiple implementation subagents in parallel (conflicts)
* Make subagent read plan file (provide full text instead)
* Skip scene-setting context (subagent needs to understand where task fits)
* Ignore subagent questions (answer before letting them proceed)
* Accept "close enough" on spec compliance (spec reviewer found issues = not done)
* Skip review loops (reviewer found issues = implementer fixes = review again)
* Let implementer self-review replace actual review (both are needed)
* **Start code quality review before spec compliance is ✅** (wrong order)
* Move to next task while either review has open issues

<Warning>
  **Critical: Review Order**

  Spec compliance MUST be ✅ before code quality review starts.

  Reviewing code quality for code that doesn't match spec wastes effort.
</Warning>

## Handling Issues

### If Subagent Asks Questions

* Answer clearly and completely
* Provide additional context if needed
* Don't rush them into implementation
* Questions are good - they prevent wrong work

### If Reviewer Finds Issues

1. Implementer (same subagent) fixes them
2. Reviewer reviews again
3. Repeat until approved
4. Don't skip the re-review

### If Subagent Fails Task

* Dispatch fix subagent with specific instructions
* Don't try to fix manually (context pollution)
* Provide clear context about what failed and why

## Checklist

Per task:

* [ ] Extracted task text and context upfront
* [ ] Dispatched implementer with complete information
* [ ] Answered any questions before proceeding
* [ ] Implementer completed (implemented, tested, committed, self-reviewed)
* [ ] Dispatched spec compliance reviewer
* [ ] Spec reviewer approved (or issues fixed and re-reviewed)
* [ ] Dispatched code quality reviewer (only after spec ✅)
* [ ] Code reviewer approved (or issues fixed and re-reviewed)
* [ ] Marked task complete in TodoWrite

After all tasks:

* [ ] Dispatched final code reviewer
* [ ] Used finishing-a-development-branch skill

## Related Skills

* **[Writing Plans](/skills/writing-plans)**: Creates the plan this skill executes
* **[Executing Plans](/skills/executing-plans)**: Alternative for parallel session execution
* **[Test-Driven Development](/skills/test-driven-development)**: Subagents use TDD for implementation

<Tip>
  Two-stage review (spec then quality) catches different types of issues. Spec compliance ensures you built the right thing. Code quality ensures you built it right.
</Tip>
