Community编程与开发github.com

子代理驱动开发

用于在当前会话中执行具有独立任务的实现计划。

子代理驱动开发 是什么?

子代理驱动开发(Subagent-Driven Development)是一种高效的AI辅助开发方法论,专为需要执行多步骤实现计划的场景设计。其核心思想是将计划中的每个独立任务分配给一个全新的子代理,确保每个子代理拥有隔离的上下文,避免上下文污染,从而让它们专注于单一任务。每次任务完成后,立即进行任务级别的审查(包含规格符合性和代码质量),并在所有任务完成后进行一次全局代码审查。该方法支持Claude Code、Cursor、Codex等主流AI代理平台,通过精确构建子代理指令和上下文来确保执行成功。子代理驱动开发能够显著提高迭代速度和质量,因为它通过“每任务新子代理+任务审查+最终审查”的模式,实现了快速迭代和高质量输出。此外,它强调不间断执行,仅在遇到破坏性操作、安全敏感操作、工作树外副作用或计划严重缺陷时才暂停,并要求将决策记录在台账中。该方法还包含模型选择指南,建议根据任务复杂性选择最经济高效的模型,并通过台账文件恢复会话中断后的进度。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/alfathafp/portofolio-web-design/tree/HEAD/.agents/skills/subagent-driven-development

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

子代理驱动开发 是做什么的?

通过为每个任务分配一个全新的实现子代理、在每次任务后执行任务审查(规格符合性 + 代码质量),并在最后执行一次全面的全分支审查来执行计划。

为什么使用子代理: 你将任务委托给拥有隔离上下文的专门代理。通过精确构造它们的指令和上下文,你确保它们保持专注并成功完成任务。它们绝不应继承你会话的上下文或历史记录——你应精确构造它们所需的内容。这也为你自己的协调工作保留了上下文。

核心原则: 每个任务的新子代理 + 任务审查(规格 + 质量)+ 广泛的最终审查 = 高质量、快速迭代

叙述: 在工具调用之间,最多叙述一行短句——台账和工具结果承载了记录。

持续执行: 不要在任务之间停下来与你的人类伙伴确认。不间断地执行计划中的所有任务。唯一的停顿原因是下面列出的四种情况,或者所有任务完成。“我应该继续吗?”之类的提示和进度总结浪费了他们的时间——他们要求你执行计划,所以执行它。

裁决,而非停滞。 一个正在运行的计划不会等待人类。冲突、歧义、计划缺陷、你本会要求超过的限制——自行决定。规格是权威的约束,计划是其论证,而你的判断解决了两者未能回答的问题。将每个决定记录在台账中,格式为 裁决:<你决定的内容> — <原因> — <如果错误会付出什么代价>,然后继续。错误的裁决会带来你的伙伴可以看到和撤销的重做成本;而会议因一个问题而停滞则会浪费他们整个工作日,且毫无收益。

有四件事会阻止你,且只有这些:不可逆或破坏性操作;安全敏感操作;此工作树之外的副作用,而规范要求你先询问(合并、推送到共享分支、发布);以及一个计划严重缺陷到每条前进路径都是猜测。对于这些,停下来并询问。

何时使用

digraph when_to_use {
    "有实现计划?" [shape=diamond];
    "任务大多独立?" [shape=diamond];
    "合作者选择了内联,或没有子代理工具?" [shape=diamond];
    "子代理驱动开发" [shape=box];
    "执行计划" [shape=box];
    "手动执行或先头脑风暴" [shape=box];

    "有实现计划?" -> "任务大多独立?" [label="是"];
    "有实现计划?" -> "手动执行或先头脑风暴" [label="否"];
    "任务大多独立?" -> "合作者选择了内联,或没有子代理工具?" [label="是"];
    "任务大多独立?" -> "手动执行或先头脑风暴" [label="否 - 紧密耦合"];
    "合作者选择了内联,或没有子代理工具?" -> "执行计划" [label="是"];
    "合作者选择了内联,或没有子代理工具?" -> "子代理驱动开发" [label="否"];
}

与执行计划(内联)的对比:

  • 每个任务使用全新的子代理(无上下文污染),而非一个上下文执行所有任务
  • 每个任务后进行审查(规格符合性 + 代码质量),而非仅在最后
  • 每个任务和每次审查消耗一个全新上下文;内联消耗一个上下文加上一个最终审查者
  • 两者都在此会话中运行,共享相同的计划工作区和台账,且绝不在任务之间暂停

流程

digraph process {
    rankdir=TB;

    subgraph cluster_per_task {
        label="每个任务";
        "分派实现子代理 (./implementer-prompt.md)" [shape=box];
        "实现者提问?" [shape=diamond];
        "回答问题,提供上下文" [shape=box];
        "实现者实现、测试、提交、自我审查" [shape=box];
        "生成审查包,分派任务审查者 (./task-reviewer-prompt.md)" [shape=box];
        "规格 ✅ 和质量通过?" [shape=diamond];
        "与计划文本冲突?" [shape=diamond];
        "裁决冲突,记录到台账" [shape=box];
        "修复轮次 R(共5轮):R≤3 恢复实现者;R≥4 新的实现者,更强大的模型" [shape=box];
        "分派限定范围的重新审查 (./re-review-prompt.md)" [shape=box];
        "所有发现已解决?" [shape=diamond];
        "R = 5?" [shape=diamond];
        "对每个未解决的发现进行裁决" [shape=box];
        "存在关键性发现?" [shape=diamond];
        "裁决并继续;仅当每条前进路径都是猜测时才停止" [shape=box];
        "将发现连同裁决暂存在台账中" [shape=box];
        "将完成信息追加到台账,标记待办完成" [shape=box];
    }

    "设置:工作树、台账检查、阅读计划、预检审查" [shape=box];
    "还有更多任务?" [shape=diamond];
    "分派最终代码审查者 (../requesting-code-review/code-reviewer.md)" [shape=box];
    "最终发现?一次修复分派,一次限定范围的重新审查,裁决剩余问题" [shape=box];
    "最终审查干净:删除此计划的工作区" [shape=box];
    "使用超级功能:完成开发分支" [shape=box style=filled fillcolor=lightgreen];

    "设置:工作树、台账检查、阅读计划、预检审查" -> "分派实现子代理 (./implementer-prompt.md)";
    "分派实现子代理 (./implementer-prompt.md)" -> "实现者提问?";
    "实现者提问?" -> "回答问题,提供上下文" [label="是"];
    "回答问题,提供上下文" -> "实现者实现、测试、提交、自我审查";
    "实现者提问?" -> "实现者实现、测试、提交、自我审查" [label="否"];
    "实现者实现、测试、提交、自我审查" -> "生成审查包,分派任务审查者 (./task-reviewer-prompt.md)";
    "生成审查包,分派任务审查者 (./task-reviewer-prompt.md)" -> "规格 ✅ 和质量通过?";
    "规格 ✅ 和质量通过?" -> "将完成信息追加到台账,标记待办完成" [label="是"];
    "规格 ✅ 和质量通过?" -> "与计划文本冲突?" [label="否"];
    "与计划文本冲突?" -> "裁决冲突,记录到台账" [label="是"];
    "裁决冲突,记录到台账" -> "修复轮次 R(共5轮):R≤3 恢复实现者;R≥4 新的实现者,更强大的模型";
    "与计划文本冲突?" -> "修复轮次 R(共5轮):R≤3 恢复实现者;R≥4 新的实现者,更强大的模型" [label="否"];
    "修复轮次 R(共5轮):R≤3 恢复实现者;R≥4 新的实现者,更强大的模型" -> "分派限定范围的重新审查 (./re-review-prompt.md)";
    "分派限定范围的重新审查 (./re-review-prompt.md)" -> "所有发现已解决?";
    "所有发现已解决?" -> "将完成信息追加到台账,标记待办完成" [label="是"];
    "所有发现已解决?" -> "R = 5?" [label="否"];
    "R = 5?" -> "修复轮次 R(共5轮):R≤3 恢复实现者;R≥4 新的实现者,更强大的模型" [label="否 - 下一轮"];
    "R = 5?" -> "对每个未解决的发现进行裁决" [label="是 - 断路器触发"];
    "对每个未解决的发现进行裁决" -> "存在关键性发现?";
    "存在关键性发现?" -> "裁决并继续;仅当每条前进路径都是猜测时才停止" [label="是"];
    "存在关键性发现?" -> "将发现连同裁决暂存在台账中" [label="否"];
    "将发现连同裁决暂存在台账中" -> "将完成信息追加到台账,标记待办完成";
    "将完成信息追加到台账,标记待办完成" -> "还有更多任务?";
    "还有更多任务?" -> "分派实现子代理 (./implementer-prompt.md)" [label="是"];
    "还有更多任务?" -> "分派最终代码审查者 (../requesting-code-review/code-reviewer.md)" [label="否"];
    "分派最终代码审查者 (../requesting-code-review/code-reviewer.md)" -> "最终发现?一次修复分派,一次限定范围的重新审查,裁决剩余问题";
    "最终发现?一次修复分派,一次限定范围的重新审查,裁决剩余问题" -> "最终审查干净:删除此计划的工作区";
    "最终审查干净:删除此计划的工作区" -> "使用超级功能:完成开发分支";
}

设置

确保工作在隔离的工作区中进行:使用 superpowers:using-git-worktrees 创建一个或验证现有工作区。未经人类伙伴明确同意,绝不要在 main/master 分支上开始实现。

会话记忆在压缩后不会保留。在实际会话中,丢失位置的控制器已重新分派了整个已完成的任务序列——这是观察到的最昂贵的失败。在台账文件中跟踪进度,而不仅仅是待办事项。

  • 每个计划拥有一个工作区:在技能启动时,运行此技能的 bash scripts/sdd-workspace PLAN_FILE——它会输出计划的 git-忽略目录(在 <repo-root>/.superpowers/sdd/ 下),此计划的所有产物(台账、简报、报告、审查包)都存放在这里。另一个计划的目录绝不应被读取或写入。
  • 在 <workspace>/progress.md 检查此计划的台账。如果其第一行命名了你的计划文件,那么带有 任务 <N>:完成 行的任务就已完成——不要重新分派它们;在第一个没有该标记的任务处继续。某任务的最后一行是修复轮次,则它处于循环中:在下一轮继续循环。第一行命名了不同计划文件的台账——或位于旧平面路径 .superpowers/sdd/progress.md 的无关台账——是另一个计划的进度:将其留在原位,并开始你自己的新台账。
  • 创建台账,其第一行作为身份标识:# SDD 台账 — 计划:<计划文件路径>。
  • 台账是你的恢复地图:其中命名的提交在 git 中存在,即使你的上下文不再记得创建了它们。压缩后,信任台账和 git log 而非你自己的记忆。
  • git clean -fdx 会销毁工作区(它是 git-忽略的临时文件);如果发生这种情况,从 git log 恢复。

阅读计划一次,记下其上下文和全局约束,并为每个任务创建一个待办事项。如果计划命名了规格,也阅读它:规格是计划所依据的权威,计划内的冲突应以规格为准。没有可访问规格的计划应在台账中注明——没有规格时做出的裁决是临时性的。

在分派任务 1 之前,扫描计划一次以查找冲突,边检查边写下你检查的内容:

  • 相互矛盾或与计划全局约束矛盾的任务
  • 计划明确要求而审查规则视为缺陷的任何内容(不进行断言的测试、逻辑块的逐字复制)

扫描的输出是一个表格,而非结论。对于每对共享文件或接口的任务,有一行:这两个任务、一个产生什么而另一个消费什么,以及你发现了什么。对于每个任务,有一行:其自身文本是否一致——其指定的测试与其指定的代码、其创建的文件与其之后触发的文件。“扫描干净”但没有这些行,意味着你没有进行扫描。

将表格写入台账。在执行开始前对你发现的所有内容进行裁决——每个发现都针对要求它的计划文本——并将每个裁决记录在台账中。如果扫描干净,则直接继续。对你发现的每个冲突进行裁决——规格是权威的约束,计划是其论证——将裁决记录在其行旁边,然后分派任务 1。审查循环仍然是捕获仅从实现中浮现的冲突的网络。

模型选择

使用能够处理每个角色的最弱模型,以节省成本并提高速度。

机械性实现任务(孤立函数、清晰规格、1-2 个文件):使用快速、廉价的模型。当计划指定良好时,大多数实现任务是机械性的。

集成和判断任务(多文件协调、模式匹配、调试):使用标准模型。

架构和设计任务:使用最强大的可用模型。最终的全分支审查属于此类——使用最强大的可用模型来分派,而不是会话默认模型。

审查任务:选择具有相同判断力的模型,根据差异的大小、复杂性和风险进行调整。小型的机械性差异不需要最强大的模型;微妙的并发更改则需要。对小修复差异的限定范围重新审查使用廉价到中端模型。

修复循环升级(第 4-5 轮):使用比卡住的实现者模型至少高一个层级的模型。

分派子代理时始终明确指定模型。 省略模型会继承你会话的模型——通常是最强大且最昂贵的——这会悄然违背此部分。

轮次数量胜过 Token 价格。 挂钟时间和上下文成本与子代理所需的轮次数量成正比,而最廉价的模型在多步骤工作中常规需要 2-3 倍的轮次,因此总体成本更高。对于审查者以及从散文描述工作的实现者,使用中端模型作为下限。当任务的计划文本包含要编写的完整代码时,实现是转录加测试:对该实现者使用最廉价的层级。单文件机械性修复也使用最廉价的层级。

任务复杂性信号(实现任务):

  • 涉及 1-2 个文件且规格完整 → 廉价模型
  • 涉及多个文件且有集成问题 → 标准模型
  • 需要设计判断或广泛代码库理解 → 最强大的模型

任务循环

批量处理同形小型任务。 当计划列出多个任务,每个都是同类的独立小型编辑——跨文件重复的相同一行修复、常量更改或字段添加——不要为每个任务分派一个子代理。编写一份分派简报列出每个文件及其更改,将整个批次发送给一个子代理,并将其差异作为一个单元进行审查。仅对需要自己判断、自己测试或自己审查范围的工作保留“每任务一分派”的方式。

你粘贴到分派提示中的一切——以及子代理返回的一切——都会保留在你的上下文中,直到此会话结束。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

alfathafp/portofolio-web-design

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).

alfathafp/portofolio-web-design

Tests in real browsers via Chrome DevTools MCP. Use when building or debugging anything that runs in a browser. Use when you need to inspect the DOM, capture console errors, analyze network requests, profile performance, or verify visual output with real runtime data. Requires the chrome-devtools MCP server to be configured.

alfathafp/portofolio-web-design

Automates CI/CD pipeline setup. Use when setting up or modifying build and deployment pipelines. Use when you need to automate quality gates, configure test runners in CI, or establish deployment strategies.

alfathafp/portofolio-web-design

Conducts multi-axis code review. Use before merging any change. Use when reviewing code written by yourself, another agent, or a human. Use when you need to assess code quality across multiple dimensions before it enters the main branch. Use when asked to review a diff or a pull request, even when the diff is pasted inline.

alfathafp/portofolio-web-design

Simplifies code for clarity. Use when refactoring code for clarity without changing behavior. Use when code works but is harder to read, maintain, or extend than it should be. Use when reviewing code that has accumulated unnecessary complexity.

alfathafp/portofolio-web-design

Establishes a project's quality bar as a written contract and stops agents quietly lowering it. Interviews the user on which dimensions matter, supplies sane default thresholds when they have no number in mind, records everything in CONSTRAINTS.md, and watches the diff for a weakened bar — new @ts-ignore or eslint-disable suppressions, skipped or deleted tests, assertions stripped out, unimplemented stubs, thresholds edited down. Use when no quality bar is written down, when the user says "set up constraints" or "define our standards", when the user wants dimensions they care about — accessibility, web performance, coverage — set up as enforced constraints, when an agent keeps silencing checks or skipping tests to get to green, when you need a coverage or performance threshold and don't know what number to pick, or when an agent writes more code than anyone will read.

alfathafp/portofolio-web-design

Optimizes agent context setup. Use when starting a new session, when agent output quality degrades, when switching between tasks, or when you need to configure rules files and context for a project.

alfathafp/portofolio-web-design

Guides systematic root-cause debugging. Use when tests fail, builds break, something that worked yesterday broke, behavior doesn't match expectations, or you encounter any unexpected error. Use when you need to figure out what broke and why — a systematic approach to finding and fixing the root cause rather than guessing.

alfathafp/portofolio-web-design

Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".

alfathafp/portofolio-web-design

Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.

alfathafp/portofolio-web-design

Use when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.

alfathafp/portofolio-web-design

Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies

alfathafp/portofolio-web-design

Records decisions and documentation. Use when you need to document an architecture decision (ADR) or the reasoning behind a design choice, when changing public APIs, shipping features, or when you need to record context that future engineers and agents will need to understand the codebase.

alfathafp/portofolio-web-design

Subjects every non-trivial decision to a fresh-context adversarial review before it stands. Use when you want every assumption cross-examined before proceeding, when stress-testing a plan for hidden failure modes, when correctness matters more than speed, when working in unfamiliar code, when stakes are high (production auth, security-sensitive logic, a high-stakes migration, irreversible operations), or any time a confident output would be cheaper to verify now than to debug later.

alfathafp/portofolio-web-design

Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available

alfathafp/portofolio-web-design

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work

alfathafp/portofolio-web-design

Builds production-quality, accessible, responsive user-facing UIs. Use when building or modifying interfaces and pages, creating components, implementing layouts, meeting WCAG accessibility requirements, managing state, or when the output needs to look and feel production-quality rather than AI-generated.

alfathafp/portofolio-web-design

Structures git workflow practices. Use when making any code change. Use when committing, branching, resolving conflicts, splitting uncommitted work in a messy working tree into clean atomic commits, opening or reviewing a pull request (PR), pushing to a remote, or when you need to organize work across multiple parallel streams. Use when cutting a release, choosing a semantic version bump, tagging, or writing a changelog.

alfathafp/portofolio-web-design

Refines raw ideas into sharp, actionable concepts through structured divergent and convergent thinking. Use when an idea is still vague, when you need to stress-test assumptions before committing to a plan, or when you want to expand options before converging on one. Triggers on "ideate", "refine this idea", or "stress-test my plan".

alfathafp/portofolio-web-design

Guides stable API and interface design. Use when designing APIs, module boundaries, or any public interface. Use when creating REST or GraphQL endpoints, defining type contracts between modules, or establishing boundaries between frontend and backend.

相关技能