subagent-driven-development

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Subagent-Driven Development

子Agent驱动开发

Overview

概述

This skill orchestrates implementation through dedicated subagents with built-in quality gates. Each task is implemented by an implementer subagent, then reviewed by two specialized reviewer agents (spec compliance and code quality) before acceptance. Failed reviews trigger iterative fix cycles with a maximum of 3 retries before escalation. This ensures consistent quality at scale while maximizing parallel throughput.
Announce at start: "I'm using the subagent-driven-development skill to dispatch implementation tasks with two-stage review gates."
该技能通过配备内置质量门的专属子Agent来编排实现流程。每个任务由实现子Agent完成开发,随后在验收前经过两个专业评审Agent(规范合规和代码质量)的审查。评审未通过会触发迭代修复周期,最多重试3次,仍失败则升级处理。该机制可在规模化场景下保障质量一致性,同时最大化并行吞吐量。
启动时声明: "我正在使用子Agent驱动开发技能来派发实现任务,并配备两阶段评审门。"

Trigger Conditions

触发条件

  • Plan has 3+ tasks that can be implemented independently
  • Tasks have well-specified acceptance criteria suitable for delegation
  • Speed of execution is a priority
  • Tasks have few interdependencies
  • Quality gates are needed for delegated work

  • 计划包含3个及以上可独立实现的任务
  • 任务具备明确的、适合委托的验收标准
  • 执行速度是优先级要求
  • 任务间依赖极少
  • 委托的工作需要设置质量门

Phase 1: Task Preparation

阶段1:任务准备

Goal: Ensure every task is fully specified before dispatching to any subagent.
目标: 确保每个任务在派发给任意子Agent前都已完成完整的规范定义。

Task Specification Requirements (7 Sections)

任务规范要求(7个模块)

Every task dispatched to a subagent MUST include ALL of these:
SectionContentExample
1. Task descriptionClear, unambiguous statement"Implement JWT token generation with RS256 signing"
2. Files to create/modifyExplicit list
src/auth/jwt.ts
,
tests/auth/jwt.test.ts
3. Acceptance criteriaSpecific, testable conditions"Tokens expire after 1 hour", "Invalid keys throw AuthError"
4. TDD requirementsTests to write, behaviors to cover"Test: valid token generation, expired token rejection, invalid key handling"
5. Quality standardsCode style, patterns, conventions"Follow existing service pattern in src/services/, use Result type for errors"
6. ContextRelevant code, interfaces, deps"Logger API: logger.info(msg, meta). Import from ../utils/logger"
7. ConstraintsWhat NOT to do"Do NOT modify existing auth middleware. Do NOT add new dependencies."
派发给子Agent的每个任务必须包含以下所有模块:
模块内容示例
1. 任务描述清晰无歧义的说明"Implement JWT token generation with RS256 signing"
2. 待创建/修改的文件明确的列表
src/auth/jwt.ts
,
tests/auth/jwt.test.ts
3. 验收标准可测试的具体条件"Tokens expire after 1 hour", "Invalid keys throw AuthError"
4. TDD要求需要编写的测试、需要覆盖的行为"Test: valid token generation, expired token rejection, invalid key handling"
5. 质量标准代码风格、模式、约定"Follow existing service pattern in src/services/, use Result type for errors"
6. 上下文相关代码、接口、依赖"Logger API: logger.info(msg, meta). Import from ../utils/logger"
7. 约束禁止执行的操作"Do NOT modify existing auth middleware. Do NOT add new dependencies."

Pre-Dispatch Checklist

派发前检查清单

  • Task spec has all 7 sections filled
  • Task is independent (no unresolved dependencies on in-progress tasks)
  • Acceptance criteria are specific and testable
  • Files to modify are identified and accessible
  • Relevant context has been gathered and included in the spec
  • 任务规范已填写完整7个模块
  • 任务是独立的(对正在进行的任务没有未解决的依赖)
  • 验收标准具体且可测试
  • 待修改的文件已识别且可访问
  • 已收集相关上下文并包含在规范中

Task Independence Decision Table

任务独立性决策表

Dependency TypeCan Dispatch?Action
No dependenciesYesDispatch immediately
Depends on completed taskYesInclude completed task's output as context
Depends on in-progress taskNoWait for dependency to complete
Shared file with another taskNoSerialize — one task at a time for that file
Shared interface onlyYesInclude interface definition as context
STOP — Do NOT dispatch until:
  • All 7 spec sections are complete
  • Independence is verified
  • Acceptance criteria are testable

依赖类型是否可以派发?操作
无依赖立即派发
依赖已完成的任务将已完成任务的输出作为上下文包含
依赖进行中的任务等待依赖任务完成
和其他任务共享文件串行执行——该文件同一时间只处理一个任务
仅共享接口将接口定义作为上下文包含
停止——满足以下条件前请勿派发:
  • 所有7个规范模块均已完成
  • 独立性已验证
  • 验收标准可测试

Phase 2: Implementation Dispatch

阶段2:实现任务派发

Goal: Send the task to an implementer subagent with full context.
  1. Prepare the implementer prompt using
    implementer-prompt.md
    template
  2. Include the full task specification (all 7 sections)
  3. Include relevant code context (existing files, interfaces, types)
  4. Dispatch the implementer subagent
  5. Collect the implementation output
Dispatch mechanism: Use the
Agent
tool with
subagent_type="general-purpose"
and include the implementer prompt (from
implementer-prompt.md
) in the
prompt
parameter. Set
description
to a short task label.
目标: 将任务和完整上下文发送给实现子Agent。
  1. 使用
    implementer-prompt.md
    模板准备实现者提示词
  2. 包含完整的任务规范(全部7个模块)
  3. 包含相关代码上下文(现有文件、接口、类型)
  4. 派发实现子Agent
  5. 收集实现输出
派发机制: 使用
Agent
工具,设置
subagent_type="general-purpose"
,并将实现者提示词(来自
implementer-prompt.md
)放入
prompt
参数中。将
description
设置为简短的任务标签。

Implementer Expectations

实现子Agent要求

The implementer subagent MUST:
  • Follow the TDD cycle (RED-GREEN-REFACTOR)
  • Write tests before production code
  • Only modify files listed in the task spec
  • Follow the quality standards specified
  • Report any questions or blockers encountered
  • Document all assumptions made
实现子Agent必须:
  • 遵循TDD周期(红-绿-重构)
  • 在生产代码之前编写测试
  • 仅修改任务规范中列出的文件
  • 遵循指定的质量标准
  • 上报遇到的所有问题或阻塞点
  • 记录所有做出的假设

Question Handling Protocol

问题处理协议

Question TypeDuring ImplementationAction
Non-blockingCan proceed with reasonable assumptionNote assumption, continue, flag in output
BlockingCannot proceed without answerSTOP immediately, escalate to orchestrator
Scope questionAsks about work outside assigned taskReport it, do NOT fix it
STOP — Do NOT proceed to review until:
  • Implementer has returned complete output
  • All listed files have been created/modified
  • Tests exist for every acceptance criterion
  • Any assumptions are documented

问题类型实现阶段状态操作
非阻塞可基于合理假设继续推进记录假设,继续推进,在输出中标记
阻塞无答案无法继续推进立即停止,升级给编排者
范围问题询问分配任务之外的工作上报该问题,不要自行处理
停止——满足以下条件前请勿进入评审阶段:
  • 实现子Agent已返回完整输出
  • 所有列出的文件均已创建/修改
  • 每个验收标准都有对应的测试
  • 所有假设都已记录

Phase 3: Spec Review Gate

阶段3:规范评审门

Goal: Verify the implementation matches the original task specification.
  1. Prepare the spec reviewer prompt using
    spec-reviewer-prompt.md
    template
  2. Provide the original task specification AND the implementer's output
  3. Dispatch the spec-reviewer subagent
  4. Collect the review result
Dispatch mechanism: Use the
Agent
tool with the spec-reviewer prompt (from
spec-reviewer-prompt.md
) in the
prompt
parameter.
目标: 验证实现是否符合原始任务规范。
  1. 使用
    spec-reviewer-prompt.md
    模板准备规范评审者提示词
  2. 提供原始任务规范和实现子Agent的输出
  3. 派发规范评审子Agent
  4. 收集评审结果
派发机制: 使用
Agent
工具,将规范评审者提示词(来自
spec-reviewer-prompt.md
)放入
prompt
参数中。

Spec Review Criteria

规范评审标准

CriterionAssessmentWhat to Check
All acceptance criteria metPASS / FAIL per criterionEach criterion individually verified
Tests cover specified behaviorsPASS / FAILTest file contains tests for all behaviors
Files modified match specPASS / FAILNo unauthorized file modifications
No out-of-scope changesPASS / FAILOnly listed files touched
Implementation matches intentPASS / FAILBehavior is correct, not just syntactically valid
All constraints respectedPASS / FAILNone of the "do NOT" items violated
标准评估结果检查项
所有验收标准均满足每个标准分别标注通过/不通过逐一验证每个验收标准
测试覆盖指定行为通过/不通过测试文件包含所有行为的测试用例
修改的文件符合规范通过/不通过无未授权的文件修改
无超出范围的变更通过/不通过仅修改了列出的文件
实现符合预期意图通过/不通过行为正确,而非仅语法有效
所有约束均被遵守通过/不通过没有违反任何“禁止”项

Gate Decision

评审门决策

ResultAction
All PASSProceed to Phase 4 (quality review)
Any FAILReturn to implementer with specific failure details
STOP — Do NOT proceed to quality review if any spec criterion fails.

结果操作
全部通过进入阶段4(质量评审)
任何项不通过将具体的失败详情返回给实现子Agent
停止——如果任何规范标准不通过,请勿进入质量评审阶段。

Phase 4: Quality Review Gate

阶段4:质量评审门

Goal: Verify code meets quality standards independent of spec compliance.
  1. Prepare the quality reviewer prompt using
    code-quality-reviewer-prompt.md
    template
  2. Provide the implementation code, test code, and project quality standards
  3. Dispatch the quality-reviewer subagent
  4. Collect the review result
Dispatch mechanism: Use the
Agent
tool with the quality-reviewer prompt (from
code-quality-reviewer-prompt.md
) in the
prompt
parameter.
目标: 独立于规范合规性,验证代码是否符合质量标准。
  1. 使用
    code-quality-reviewer-prompt.md
    模板准备质量评审者提示词
  2. 提供实现代码、测试代码和项目质量标准
  3. 派发质量评审子Agent
  4. 收集评审结果
派发机制: 使用
Agent
工具,将质量评审者提示词(来自
code-quality-reviewer-prompt.md
)放入
prompt
参数中。

Quality Review Areas

质量评审维度

AreaWhat to Check
Code qualityReadability, naming, structure, complexity
Pattern complianceFollows project patterns and conventions
SecurityNo injection vulnerabilities, proper validation, safe defaults
PerformanceNo unnecessary allocations, efficient algorithms, no N+1 queries
Error handlingAll error paths handled, meaningful error messages
Test qualityTests are meaningful, not testing implementation details
维度检查项
代码质量可读性、命名、结构、复杂度
模式合规性遵循项目模式和约定
安全性无注入漏洞、验证合规、默认配置安全
性能无不必要的内存分配、算法高效、无N+1查询
错误处理所有错误路径都被处理、错误消息有意义
测试质量测试有实际意义,不测试实现细节

Issue Severity Classification

问题严重程度分类

SeverityDefinitionAction Required
CriticalSecurity vulnerability, data loss risk, incorrect behaviorMUST fix before acceptance
ImportantPerformance issue, maintainability concern, missing error handlingSHOULD fix (escalate to user for decision)
SuggestionStyle improvement, alternative approach, documentationMAY fix, at developer's discretion
严重程度定义所需操作
严重安全漏洞、数据丢失风险、行为错误验收前必须修复
重要性能问题、可维护性隐患、缺少错误处理应该修复(升级给用户决策)
建议风格改进、替代实现方案、文档优化可以修复,由开发者自行决定

Gate Decision

评审门决策

ResultAction
No Critical or Important issuesPASS — proceed to acceptance
Any Critical issuesFAIL — must fix and re-review
Only Important issuesConditional — escalate to user for decision

结果操作
无严重或重要问题通过——进入验收阶段
存在任何严重问题不通过——必须修复后重新评审
仅存在重要问题有条件通过——升级给用户决策

Phase 5: Fix and Re-Review Cycle

阶段5:修复和重评审周期

Goal: Iteratively fix review failures with a bounded retry limit.
目标: 在有限的重试次数内迭代修复评审失败项。

Fix Cycle Process

修复周期流程

1. Collect all failure details from the failing review gate
2. Send failures back to implementer subagent with specific instructions
3. Implementer fixes the specific issues (not a full rewrite)
4. Re-run ONLY the failing review gate
5. If still failing: repeat (max 3 cycles)
6. After 3 failed cycles: escalate to user
1. Collect all failure details from the failing review gate
2. Send failures back to implementer subagent with specific instructions
3. Implementer fixes the specific issues (not a full rewrite)
4. Re-run ONLY the failing review gate
5. If still failing: repeat (max 3 cycles)
6. After 3 failed cycles: escalate to user

Retry Decision Table

重试决策表

AttemptSpec ReviewQuality ReviewAction
1FAILReturn to implementer with failure details
2FAILReturn with additional context/examples
3FAILEscalate to user
1PASSFAILReturn to implementer with quality issues
2PASSFAILReturn with project patterns as reference
3PASSFAILEscalate to user
尝试次数规范评审质量评审操作
1不通过将失败详情返回给实现子Agent
2不通过补充上下文/示例后返回
3不通过升级给用户
1通过不通过将质量问题返回给实现子Agent
2通过不通过提供项目模式作为参考后返回
3通过不通过升级给用户

Escalation Report Format

升级报告格式

ESCALATION: REPEATED REVIEW FAILURE
====================================
Task: [task description]
Review Gate: [spec / quality]
Attempts: 3

Failure Pattern:
  Attempt 1: [what failed and why]
  Attempt 2: [what failed and why]
  Attempt 3: [what failed and why]

Root Cause Assessment: [why the implementer cannot resolve this]

Options:
  A. Simplify the task specification
  B. Provide additional context/examples
  C. Break into smaller sub-tasks
  D. Implement manually (skip subagent)

Awaiting direction.

ESCALATION: REPEATED REVIEW FAILURE
====================================
Task: [task description]
Review Gate: [spec / quality]
Attempts: 3

Failure Pattern:
  Attempt 1: [what failed and why]
  Attempt 2: [what failed and why]
  Attempt 3: [what failed and why]

Root Cause Assessment: [why the implementer cannot resolve this]

Options:
  A. Simplify the task specification
  B. Provide additional context/examples
  C. Break into smaller sub-tasks
  D. Implement manually (skip subagent)

Awaiting direction.

Phase 6: Acceptance and Integration

阶段6:验收和集成

Goal: After both gates pass, integrate the work and verify no regressions.
  1. Run the full project test suite (not just the new tests)
  2. Run all verification commands (lint, type-check, build)
  3. Confirm no regressions were introduced
  4. Mark the task as complete
  5. Proceed to next task or report completion
目标: 两个评审门都通过后,集成工作并验证无回归问题。
  1. 运行完整的项目测试套件(不只是新测试)
  2. 运行所有验证命令(lint、类型检查、构建)
  3. 确认没有引入回归问题
  4. 标记任务为已完成
  5. 推进到下一个任务或上报完成

Multi-Task Orchestration

多任务编排

1. Identify independent tasks (no dependencies on each other)
2. For each independent task: run Phases 2-6
3. After all independent tasks complete:
   a. Run full test suite
   b. Run all verification commands
   c. Checkpoint review
4. Identify next set of tasks (now that dependencies are met)
5. Repeat until all tasks complete

1. Identify independent tasks (no dependencies on each other)
2. For each independent task: run Phases 2-6
3. After all independent tasks complete:
   a. Run full test suite
   b. Run all verification commands
   c. Checkpoint review
4. Identify next set of tasks (now that dependencies are met)
5. Repeat until all tasks complete

Anti-Patterns / Common Mistakes

反模式/常见错误

Anti-PatternWhy It FailsCorrect Approach
Dispatching without complete task specImplementer makes wrong assumptionsFill out all 7 spec sections first
Skipping spec review ("code looks right")Spec deviations accumulateAlways run both review gates
Accepting despite Critical issuesSecurity/correctness compromisedCritical issues must be fixed
Letting implementer review its own codeBias, blind spotsSeparate agents for implementation and review
Dispatching dependent tasks in parallelRace conditions, integration failuresOnly parallelize independent tasks
Ignoring questions from implementerWrong assumptions baked into codeAddress all questions before proceeding
More than 3 fix cycles without escalatingDiminishing returns, same mistakesEscalate to user for direction
Skipping verification after acceptanceRegressions go unnoticedAlways run full verification
Vague acceptance criteriaReviewer cannot assess objectivelySpecific, testable criteria only
Not including constraintsImplementer touches files it should notExplicit "do NOT" list in every spec

反模式失败原因正确做法
未完成任务规范就派发实现者做出错误假设先填写完整7个规范模块
跳过规范评审(“代码看起来没问题”)规范偏差累积始终运行两个评审门
存在严重问题仍验收安全性/正确性受损严重问题必须修复
让实现者评审自己的代码存在偏见、盲点实现和评审使用不同的Agent
并行派发有依赖的任务竞态条件、集成失败仅并行派发独立任务
忽略实现者的问题错误假设被固化到代码中推进前解决所有问题
超过3次修复周期仍不升级收益递减、重复犯相同错误升级给用户获取指示
验收后跳过验证回归问题未被发现始终运行完整验证
验收标准模糊评审者无法客观评估仅使用具体、可测试的标准
不包含约束实现者修改了不应触碰的文件每个规范中明确列出“禁止”项

Anti-Rationalization Guards

反合理化防护

<HARD-GATE> Do NOT skip either review gate. Do NOT accept implementations with Critical issues. Do NOT dispatch tasks without complete specifications. Both review gates must PASS before any task is marked complete. </HARD-GATE>
If you catch yourself thinking:
  • "The implementation looks good enough..." — Run both review gates. Always.
  • "The spec review is just a formality..." — Spec deviations cause integration failures. Run it.
  • "Three retries is too many, just accept it..." — If it fails 3 times, escalate. Do not lower the bar.

<HARD-GATE> 请勿跳过任何一个评审门。请勿接受存在严重问题的实现。请勿派发规范不完整的任务。任何任务标记为完成前,两个评审门都必须通过。 </HARD-GATE>
如果你发现自己有以下想法:
  • “这个实现看起来已经够好了…” —— 始终运行两个评审门。
  • “规范评审只是走个流程…” —— 规范偏差会导致集成失败。必须运行。
  • “三次重试太多了,直接接受吧…” —— 如果失败3次,升级处理。不要降低标准。

Integration Points

集成点

SkillRelationshipWhen
planning
Upstream — provides approved plan with tasksTask source
executing-plans
Upstream — may delegate to this skillFor independent tasks in plan
test-driven-development
Per-task — implementer follows TDDPhase 2 implementation
verification-before-completion
Post-acceptance — final verificationPhase 6 integration
code-review
Complementary — quality review gatePhase 4 quality review
dispatching-parallel-agents
Complementary — parallelization strategyWhen dispatching independent tasks
resilient-execution
On failure — retry strategiesWhen fix cycles exhaust
task-management
Tracking — task status managementProgress tracking
Agent
tool
Dispatch mechanism for all subagent phases

技能关系触发时机
planning
上游——提供已批准的任务计划任务来源
executing-plans
上游——可委托给该技能处理计划中的独立任务时
test-driven-development
单任务级——实现者遵循TDD阶段2实现阶段
verification-before-completion
验收后——最终验证阶段6集成阶段
code-review
互补——质量评审门阶段4质量评审
dispatching-parallel-agents
互补——并行策略派发独立任务时
resilient-execution
失败时——重试策略修复周期耗尽时
task-management
跟踪——任务状态管理进度跟踪
Agent
工具
所有子Agent阶段的派发机制

Concrete Examples

具体示例

Example: Task Spec for Subagent

示例:子Agent的任务规范

TASK SPECIFICATION
==================
1. Description: Implement user registration endpoint with email validation

2. Files:
   - Create: src/routes/auth/register.ts
   - Create: tests/routes/auth/register.test.ts
   - Modify: src/routes/index.ts (add route import)

3. Acceptance Criteria:
   - POST /api/auth/register accepts { email, password, name }
   - Returns 201 with user object (no password) on success
   - Returns 400 if email format is invalid
   - Returns 409 if email already exists
   - Password is hashed before storage

4. TDD Requirements:
   - Test: valid registration returns 201
   - Test: invalid email returns 400
   - Test: duplicate email returns 409
   - Test: password is not in response body
   - Test: password is hashed in database

5. Quality Standards:
   - Follow route pattern in src/routes/auth/login.ts
   - Use Zod for input validation (existing pattern)
   - Use Result<T, E> type for service errors

6. Context:
   - Auth service: src/services/auth.ts (has hashPassword method)
   - Route pattern: see src/routes/auth/login.ts
   - Zod schemas: see src/schemas/auth.ts

7. Constraints:
   - Do NOT modify auth service
   - Do NOT add new dependencies
   - Do NOT create migration files

TASK SPECIFICATION
==================
1. Description: Implement user registration endpoint with email validation

2. Files:
   - Create: src/routes/auth/register.ts
   - Create: tests/routes/auth/register.test.ts
   - Modify: src/routes/index.ts (add route import)

3. Acceptance Criteria:
   - POST /api/auth/register accepts { email, password, name }
   - Returns 201 with user object (no password) on success
   - Returns 400 if email format is invalid
   - Returns 409 if email already exists
   - Password is hashed before storage

4. TDD Requirements:
   - Test: valid registration returns 201
   - Test: invalid email returns 400
   - Test: duplicate email returns 409
   - Test: password is not in response body
   - Test: password is hashed in database

5. Quality Standards:
   - Follow route pattern in src/routes/auth/login.ts
   - Use Zod for input validation (existing pattern)
   - Use Result<T, E> type for service errors

6. Context:
   - Auth service: src/services/auth.ts (has hashPassword method)
   - Route pattern: see src/routes/auth/login.ts
   - Zod schemas: see src/schemas/auth.ts

7. Constraints:
   - Do NOT modify auth service
   - Do NOT add new dependencies
   - Do NOT create migration files

Prompt Templates

提示词模板

This skill uses three prompt templates:
TemplatePurposeFile
Implementer PromptDispatches implementation work
implementer-prompt.md
Spec Reviewer PromptReviews against task specification
spec-reviewer-prompt.md
Quality Reviewer PromptReviews code quality
code-quality-reviewer-prompt.md
Each template provides a structured format for the subagent interaction. See the individual files for details.

该技能使用三个提示词模板:
模板用途文件
实现者提示词派发实现工作
implementer-prompt.md
规范评审者提示词对照任务规范评审
spec-reviewer-prompt.md
质量评审者提示词评审代码质量
code-quality-reviewer-prompt.md
每个模板都提供了子Agent交互的结构化格式。详情请查看对应文件。

Skill Type

技能类型

RIGID — Follow this process exactly. All 7 spec sections are mandatory. Both review gates are mandatory. The 3-retry escalation limit is mandatory. No shortcuts.
刚性 —— 严格遵循该流程。所有7个规范模块都是必填项。两个评审门都是必填项。3次重试升级限制是必填项。不允许走捷径。