SuperAPI AI Directory

subagent-driven-development

Coding & development

View repository

Updated 10-15 10:42

About this skill

Subagent-Driven Development

Execute the plan by dispatching a fresh subagent for each task, with a two-stage review after each task is completed: first review spec compliance, then review code quality.

Why use subagents: You delegate tasks to specialized agents with isolated context. By carefully crafting their instructions and context, you ensure they stay focused and complete tasks successfully. They should not inherit your session context or history—you construct exactly what they need. This also preserves your own context for coordination work.

Core principles: One fresh subagent per task + two-stage review (spec first, then quality) = high quality, fast iteration

When to use

digraph when_to_use {
    "有实现计划?" [shape=diamond];
    "任务基本独立?" [shape=diamond];
    "留在当前会话?" [shape=diamond];
    "subagent-driven-development" [shape=box];
    "executing-plans" [shape=box];
    "手动执行或先头脑风暴" [shape=box];
"有实现计划?" -> "任务基本独立?" [label="是"];
"有实现计划?" -> "手动执行或先头脑风暴" [label="否"];
"任务基本独立?" -> "留在当前会话?" [label="是"];
"任务基本独立?" -> "手动执行或先头脑风暴" [label="否 - 紧密耦合"];
"留在当前会话?" -> "subagent-driven-development" [label="是"];
"留在当前会话?" -> "executing-plans" [label="否 - 并行会话"];

}


**与 Executing Plans(并行会话)的对比:**
- 同一会话(无上下文切换)
- 每个任务全新子智能体(无上下文污染)
- 每个任务后两阶段审查:先规格合规性,再代码质量
- 更快的迭代(任务间无需人工介入)

## 流程

```dot
digraph process {
    rankdir=TB;

    subgraph cluster_per_task {
        label="每个任务";
        "分派实现子智能体 (./implementer-prompt.md)" [shape=box];
        "实现子智能体有疑问?" [shape=diamond];
        "回答问题,提供上下文" [shape=box];
        "实现子智能体实现、测试、提交、自审" [shape=box];
        "分派规格审查子智能体 (./spec-reviewer-prompt.md)" [shape=box];
        "规格审查子智能体确认代码匹配规格?" [shape=diamond];
        "实现子智能体修复规格差距" [shape=box];
        "分派代码质量审查子智能体 (./code-quality-reviewer-prompt.md)" [shape=box];
        "代码质量审查子智能体通过?" [shape=diamond];
        "实现子智能体修复质量问题" [shape=box];
        "在 TodoWrite 中标记任务完成" [shape=box];
    }

    "读取计划,提取所有任务的完整文本,记录上下文,创建 TodoWrite" [shape=box];
    "还有剩余任务?" [shape=diamond];
    "分派最终代码审查子智能体审查整体实现" [shape=box];
    "使用 superpowers:finishing-a-development-branch" [shape=box style=filled fillcolor=lightgreen];

    "读取计划,提取所有任务的完整文本,记录上下文,创建 TodoWrite" -> "分派实现子智能体 (./implementer-prompt.md)";
    "分派实现子智能体 (./implementer-prompt.md)" -> "实现子智能体有疑问?";
    "实现子智能体有疑问?" -> "回答问题,提供上下文" [label="是"];
    "回答问题,提供上下文" -> "分派实现子智能体 (./implementer-prompt.md)";
    "实现子智能体有疑问?" -> "实现子智能体实现、测试、提交、自审" [label="否"];
    "实现子智能体实现、测试、提交、自审" -> "分派规格审查子智能体 (./spec-reviewer-prompt.md)";
    "分派规格审查子智能体 (./spec-reviewer-prompt.md)" -> "规格审查子智能体确认代码匹配规格?";
    "规格审查子智能体确认代码匹配规格?" -> "实现子智能体修复规格差距" [label="否"];
    "实现子智能体修复规格差距" -> "分派规格审查子智能体 (./spec-reviewer-prompt.md)" [label="重新审查"];
    "规格审查子智能体确认代码匹配规格?" -> "分派代码质量审查子智能体 (./code-quality-reviewer-prompt.md)" [label="是"];
    "分派代码质量审查子智能体 (./code-quality-reviewer-prompt.md)" -> "代码质量审查子智能体通过?";
    "代码质量审查子智能体通过?" -> "实现子智能体修复质量问题" [label="否"];
    "实现子智能体修复质量问题" -> "分派代码质量审查子智能体 (./code-quality-reviewer-prompt.md)" [label="重新审查"];
    "代码质量审查子智能体通过?" -> "在 TodoWrite 中标记任务完成" [label="是"];
    "在 TodoWrite 中标记任务完成" -> "还有剩余任务?";
    "还有剩余任务?" -> "分派实现子智能体 (./implementer-prompt.md)" [label="是"];
    "还有剩余任务?" -> "分派最终代码审查子智能体审查整体实现" [label="否"];
    "分派最终代码审查子智能体审查整体实现" -> "使用 superpowers:finishing-a-development-branch";
}

Model selection

Use the lowest-cost model capable of each role, to save money and improve speed.

Mechanical implementation tasks(isolated functions, clear specs, 1-2 files): use a fast, cheap model. When the plan is written in sufficient detail, most implementation tasks are mechanical.

Integration and judgment tasks(multi-file coordination, pattern matching, debugging): use a standard model.

Architecture, design, and review tasks: use the strongest available model.

Task complexity signals:

  • Involves 1-2 files with complete specs → cheap model
  • Involves multiple files with integration considerations → standard model
  • Requires design judgment or broad codebase understanding → strongest model

Handling implementer status

The implementation subagent reports one of four statuses. Handle each status accordingly:

DONE: Proceed to spec compliance review.

DONE_WITH_CONCERNS: The implementer completed the work but flagged concerns. Read these concerns before continuing. If the concerns relate to correctness or scope, resolve them before review. If they are merely observational notes (such as "this file is getting large"), record them and continue the review.

NEEDS_CONTEXT: The implementer needs information that was not provided. Provide the missing context and re-dispatch.

BLOCKED: The implementer was unable to complete the task. Evaluate the cause of the blockage:

  1. If it is a context problem, provide more context and re-dispatch with the same model
  2. If the task requires stronger reasoning ability, re-dispatch with a stronger model
  3. If the task is too large, split it into smaller parts
  4. If the plan itself is flawed, escalate to a human

Never ignore an escalation or retry with the same model without making any changes. If the implementer says it is stuck, that means something needs to change.

Prompt templates

  • ./implementer-prompt.md - Dispatch implementation subagent
  • ./spec-reviewer-prompt.md - Dispatch spec compliance review subagent
  • ./code-quality-reviewer-prompt.md - Dispatch code quality review subagent

Example workflow

你:我正在使用子智能体驱动开发来执行这个计划。

[一次性读取计划文件:docs/superpowers/plans/feature-plan.md]
[提取全部 5 个任务的完整文本和上下文]
[用所有任务创建 TodoWrite]

任务 1:Hook 安装脚本

[获取任务 1 的文本和上下文(已提取)]
[分派实现子智能体,附带完整任务文本 + 上下文]

实现者:"在我开始之前——hook 应该安装在用户级别还是系统级别?"

你:"用户级别(~/.config/superpowers/hooks/)"

实现者:"明白了。现在开始实现……"
[稍后] 实现者:
  - 实现了 install-hook 命令
  - 添加了测试,5/5 通过
  - 自审:发现遗漏了 --force 参数,已添加
  - 已提交

[分派规格合规审查]
规格审查者:✅ 符合规格 - 所有需求已满足,无多余内容

[获取 git SHA,分派代码质量审查]
代码审查者:优点:测试覆盖好,代码整洁。问题:无。通过。

[标记任务 1 完成]

任务 2:恢复模式

[获取任务 2 的文本和上下文(已提取)]
[分派实现子智能体,附带完整任务文本 + 上下文]

实现者:[无疑问,直接开始]
实现者:
  - 添加了 verify/repair 模式
  - 8/8 测试通过
  - 自审:一切正常
  - 已提交

[分派规格合规审查]
规格审查者:❌ 问题:
  - 缺失:进度报告(规格要求"每 100 项报告一次")
  - 多余:添加了 --json 参数(未被要求)

[实现者修复问题]
实现者:移除了 --json 参数,添加了进度报告

[规格审查者再次审查]
规格审查者:✅ 现在符合规格

[分派代码质量审查]
代码审查者:优点:扎实。问题(重要):魔法数字(100)

[实现者修复]
实现者:提取了 PROGRESS_INTERVAL 常量

[代码审查者再次审查]
代码审查者:✅ 通过

[标记任务 2 完成]

...

[所有任务完成后]
[分派最终代码审查]
最终审查者:所有需求已满足,可以合并

完成!

Advantages

Compared with manual execution:

  • Subagents naturally follow TDD
  • Fresh context for each task (no confusion)
  • Parallel-safe (subagents do not interfere with each other)
  • Subagents can ask questions (both before and during work)

Compared with Executing Plans:

  • Same session (no handoff)
  • Continuous progress (no waiting required)
  • Review checkpoint automation

Efficiency gains:

  • No file reading overhead (the controller provides the complete text)
  • The controller precisely curates the required context
  • Subagents receive complete information in advance
  • Questions are raised before work begins (rather than after work ends)

Quality gates:

  • Self-review catches problems before handoff
  • Two-stage review: spec compliance, then code quality
  • The review loop ensures fixes actually work
  • Spec compliance prevents over/under-building
  • Code quality ensures the implementation is good

Cost:

  • More subagent invocations (each task requires an implementer + 2 reviewers)
  • The controller needs more preparation work (extract all tasks in advance)
  • The review loop increases the number of iterations
  • But problems are found early (more cost-effective than later debugging)

Red lines

Never:

  • Start implementation on the main/master branch without the user's explicit consent
  • Skip review (spec compliance or code quality)
  • Continue with unfixed problems
  • Dispatch multiple implementation subagents in parallel (they will conflict)
  • Have subagents read the plan file (the complete text should be provided)
  • Skip scenario-setting context (subagents need to understand where the task fits)
  • Ignore subagents' questions (answer them before letting them continue)
  • Accept "good enough" on spec compliance (spec reviewer finding problems = not done)
  • Skip the review loop (reviewer finds problems = implementer fixes = review again)
  • Let the implementer's self-review replace formal review (both are needed)
  • Start code quality review before the spec compliance review passes(wrong order)
  • Move on to the next task while either review has unresolved problems

If a subagent asks a question:

  • Answer clearly and completely
  • Provide additional context when necessary
  • Do not rush them into the implementation phase

If a reviewer finds problems:

  • The implementer (the same subagent) fixes them
  • The reviewer reviews again
  • Repeat until it passes
  • Do not skip re-review

If a subagent fails:

  • Dispatch a fix subagent and provide specific instructions
  • Do not attempt to fix it manually (context pollution)

Integration

Required workflow skills:

  • superpowers:using-git-worktrees - Required: establish an isolated workspace before starting
  • superpowers:writing-plans - Create the plan for this skill's execution
  • superpowers:requesting-code-review - Code review template for reviewing subagents
  • superpowers:finishing-a-development-branch - Wrap up after all tasks are complete

Subagents should use:

  • superpowers:test-driven-development - Subagents follow TDD for each task

Alternative workflows:

  • superpowers:executing-plans - For parallel sessions rather than same-session execution