# Subagent-Driven Execution & Review

> The "Page Shape" and "QA Review" phase: dispatching specialized subagents to implement tasks with two-stage automated review for spec compliance and code quality.

- Repository: obra/superpowers
- GitHub: https://github.com/obra/superpowers
- Human wiki: https://grok-wiki.com/public/wiki/obra-superpowers-8ae12eb67e85
- Complete Markdown: https://grok-wiki.com/public/wiki/obra-superpowers-8ae12eb67e85/llms-full.txt

## Source Files

- `skills/subagent-driven-development/SKILL.md`
- `skills/dispatching-parallel-agents/SKILL.md`
- `skills/subagent-driven-development/implementer-prompt.md`
- `skills/subagent-driven-development/spec-reviewer-prompt.md`
- `skills/subagent-driven-development/code-quality-reviewer-prompt.md`

---

<details>
<summary>Relevant source files</summary>
The following files were used as context for generating this wiki page:
- [skills/subagent-driven-development/SKILL.md](skills/subagent-driven-development/SKILL.md)
- [skills/dispatching-parallel-agents/SKILL.md](skills/dispatching-parallel-agents/SKILL.md)
- [skills/subagent-driven-development/implementer-prompt.md](skills/subagent-driven-development/implementer-prompt.md)
- [skills/subagent-driven-development/spec-reviewer-prompt.md](skills/subagent-driven-development/spec-reviewer-prompt.md)
- [skills/subagent-driven-development/code-quality-reviewer-prompt.md](skills/subagent-driven-development/code-quality-reviewer-prompt.md)
</details>

# Subagent-Driven Execution & Review

The execution phase in **superpowers** transitions from a static **Plan** to active implementation through a coordinated swarm of specialized subagents. This process is governed by the **Page Shape** and **QA Review** workflows, ensuring that every code change is not only functional but strictly compliant with the original specification and high-quality standards. By dispatching parallel agents, the system achieves a map-reduce effect for complex features, maintaining a high velocity without compromising the integrity of the codebase.

This multi-stage automation moves beyond simple generation; it enforces a rigorous verification loop where one agent builds, a second verifies spec compliance, and a third audits code quality. This "separation of concerns" among agents mirrors a professional human peer-review process, significantly reducing the "94% PR rejection rate" by catching slop and hallucinations before they ever reach a human maintainer.

## The Three-Stage Implementation Workflow

The implementation follows a strict sequence of handoffs between specialized personas. This workflow ensures that implementation details do not drift from the approved **Blueprint**.

### 1. The Implementer (Execution)
The implementer agent is tasked with the primary coding work. It is instructed to follow the file structure defined in the plan and to prioritize clarity and maintainability. A key feature of this phase is the **Self-Review** requirement, where the agent must verify its own work against completeness, quality, and testing criteria before reporting back.

Sources: [skills/subagent-driven-development/implementer-prompt.md:1-125]()

### 2. Spec Compliance Review (QA Review)
Once an implementer finishes, a separate **Spec Reviewer** is dispatched. This agent operates under the "Do Not Trust the Report" directive. It ignores the implementer's summary and instead performs a line-by-line comparison of the actual code against the task requirements to identify missing pieces or "extra" unrequested work.

Sources: [skills/subagent-driven-development/spec-reviewer-prompt.md:1-50]()

### 3. Code Quality Review (QA Review)
Only after spec compliance is confirmed does the **Code Quality Reviewer** run. This agent focuses on architectural integrity, ensuring units are decomposed, interfaces are well-defined, and the implementation follows established patterns in the codebase.

Sources: [skills/subagent-driven-development/code-quality-reviewer-prompt.md:1-25]()

## Parallel Execution & Dispatch

For multi-file or multi-subsystem tasks, **superpowers** utilizes parallel dispatch to solve independent problems simultaneously. This reduces total wall-clock time and keeps each agent focused on a narrow, manageable context.

```mermaid
sequenceDiagram
    participant C as Controller
    participant I as Implementer
    participant SR as Spec Reviewer
    participant QR as Quality Reviewer

    C->>I: Dispatch Task (Implement)
    I->>I: Code & Self-Review
    I-->>C: DONE (Codebase updated)
    
    C->>SR: Dispatch Review (Spec Compliance)
    Note over SR: Verify Code vs Requirements
    SR-->>C: PASS / FAIL
    
    rect rgb(240, 240, 240)
    Note over C: Only if Spec Pass
    C->>QR: Dispatch Review (Code Quality)
    QR-->>C: Assessment
    end
```
Sources: [skills/dispatching-parallel-agents/SKILL.md:1-20]()

## Review Status and Outcomes

The following table describes the possible states during the subagent-driven execution phase:

| Status | Meaning | Action Required |
| :--- | :--- | :--- |
| `DONE` | Task complete and verified. | Proceed to next task or final review. |
| `DONE_WITH_CONCERNS` | Work finished but agent has doubts. | Human or peer review required. |
| `BLOCKED` | External dependency or ambiguity. | Human intervention or more context. |
| `NEEDS_CONTEXT` | Missing information to start/finish. | Update Plan or provide file access. |

## Verification & Escalation

A critical safety valve in the subagent workflow is the **Escalation Protocol**. Implementers are explicitly instructed to stop and say "this is too hard for me" if they encounter architectural decisions with multiple valid approaches or if the task involves restructuring that the plan didn't anticipate. This prevents "hallucinated fixes" and ensures that complex decisions are bubbled back up to the human partner.

Sources: [skills/subagent-driven-development/implementer-prompt.md:65-80]()

The subagent-driven model transforms the developer experience from manual coding to high-level orchestration, leveraging parallelization and automated QA to build robust, maintainable systems.
Sources: [skills/dispatching-parallel-agents/SKILL.md:25-35]()
