subagent-driven-development
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSubagent-Driven Development
Subagent 驱动开发
Part of Agent Skills™ by googleadsagent.ai™
属于 Agent Skills™,由 googleadsagent.ai™ 提供
Description
描述
Subagent-Driven Development dispatches each discrete task to a fresh subagent with a clean context window, then subjects the output to a two-stage review before merging. The orchestrating agent decomposes work into atomic units, writes precise specifications for each, and spawns isolated subagents that cannot pollute each other's context or carry forward stale assumptions.
Context window contamination is the silent killer of agent code quality. As a conversation grows, early instructions fade, variable names blur, and the agent begins referencing code that has since been refactored. By giving each task a fresh subagent, every implementation starts from a clean slate with only the relevant specification and referenced files. The result is consistently high-quality output regardless of session length.
The two-stage review process catches defects at different abstraction levels. Stage 1 verifies spec compliance: does the output do what was asked? Stage 2 evaluates code quality: is it well-structured, tested, and maintainable? Only code that passes both gates is accepted into the codebase.
Subagent 驱动开发会将每个离散任务分派给一个拥有全新上下文窗口的独立 Subagent,并在合并前对输出进行两阶段审查。编排 Agent 负责将工作分解为原子化单元,为每个单元编写精确的规格说明,并启动相互隔离的 Subagent,避免它们污染彼此的上下文或沿用过时假设。
上下文窗口污染是悄无声息摧毁 Agent 代码质量的杀手。随着对话不断增长,早期的指令逐渐淡化,变量名变得模糊,Agent 开始引用已经被重构的代码。通过为每项任务启用全新的 Subagent,每次实现都从干净的起点开始,仅掌握相关规格说明和引用的文件。无论会话长度如何,都能持续获得高质量输出。
两阶段审查流程可以在不同的抽象层级捕获缺陷。第一阶段验证规格符合度:输出是否完成了要求?第二阶段评估代码质量:结构是否良好、是否经过测试并且易于维护?只有通过这两道关卡的代码才会被纳入代码库。
Use When
使用场景
- A task can be decomposed into 3+ independent subtasks
- The conversation context has grown large enough to risk coherence loss
- Multiple files or modules must be modified in parallel
- You need best-of-N attempts for a complex implementation
- Quality gates must be enforced consistently across all outputs
- The user requests parallel or isolated task execution
- 一项任务可以分解为 3 个或更多独立子任务
- 对话上下文已经增长到可能丧失连贯性的程度
- 需要并行修改多个文件或模块
- 需要为复杂实现尝试多种方案并选出最佳结果
- 需要对所有输出统一执行质量关卡
- 用户要求并行或隔离执行任务
How It Works
工作原理
mermaid
graph TD
A[Orchestrator: Decompose Task] --> B[Write Spec for Subtask 1]
A --> C[Write Spec for Subtask 2]
A --> D[Write Spec for Subtask N]
B --> E[Spawn Subagent 1]
C --> F[Spawn Subagent 2]
D --> G[Spawn Subagent N]
E --> H[Stage 1: Spec Compliance Review]
F --> H
G --> H
H --> I{Passes?}
I -->|No| J[Return to Subagent with Feedback]
J --> H
I -->|Yes| K[Stage 2: Code Quality Review]
K --> L{Passes?}
L -->|No| J
L -->|Yes| M[Merge to Main Branch]The orchestrator never writes implementation code directly. Its role is to decompose, specify, dispatch, and review. Each subagent operates in an isolated git worktree, preventing conflicts between parallel implementations.
mermaid
graph TD
A[Orchestrator: Decompose Task] --> B[Write Spec for Subtask 1]
A --> C[Write Spec for Subtask 2]
A --> D[Write Spec for Subtask N]
B --> E[Spawn Subagent 1]
C --> F[Spawn Subagent 2]
D --> G[Spawn Subagent N]
E --> H[Stage 1: Spec Compliance Review]
F --> H
G --> H
H --> I{Passes?}
I -->|No| J[Return to Subagent with Feedback]
J --> H
I -->|Yes| K[Stage 2: Code Quality Review]
K --> L{Passes?}
L -->|No| J
L -->|Yes| M[Merge to Main Branch]编排 Agent 绝不会直接编写实现代码。它的职责是分解、定义、调度和审查。每个 Subagent 都在独立的 git worktree 中运行,从而避免并行实现之间产生冲突。
Implementation
实现
yaml
orchestrator:
decompose:
- analyze_task_for_independent_subtasks
- ensure_each_subtask_has: [clear_input, clear_output, testable_criteria]
- max_subtask_size: "completable_in_one_session"
spec_template: |
## Subtask: {name}
**Input**: {files_to_read}
**Output**: {files_to_create_or_modify}
**Acceptance Criteria**:
- {criterion_1}
- {criterion_2}
**Constraints**: {architectural_boundaries}
**Tests**: {required_test_cases}
dispatch:
method: "fresh_subagent_per_task"
isolation: "git_worktree"
context: "spec_only" # No conversation history
review_stage_1_spec_compliance:
checks:
- all_acceptance_criteria_met
- all_required_tests_present_and_passing
- output_files_match_specification
- no_unspecified_side_effects
review_stage_2_code_quality:
checks:
- no_linter_errors
- no_type_errors
- naming_conventions_followed
- no_dead_code_or_debug_artifacts
- error_handling_present
- documentation_for_public_apis
merge:
strategy: "squash_per_subtask"
commit_message: "feat({subtask_name}): {one_line_summary}"yaml
orchestrator:
decompose:
- analyze_task_for_independent_subtasks
- ensure_each_subtask_has: [clear_input, clear_output, testable_criteria]
- max_subtask_size: "completable_in_one_session"
spec_template: |
## Subtask: {name}
**Input**: {files_to_read}
**Output**: {files_to_create_or_modify}
**Acceptance Criteria**:
- {criterion_1}
- {criterion_2}
**Constraints**: {architectural_boundaries}
**Tests**: {required_test_cases}
dispatch:
method: "fresh_subagent_per_task"
isolation: "git_worktree"
context: "spec_only" # No conversation history
review_stage_1_spec_compliance:
checks:
- all_acceptance_criteria_met
- all_required_tests_present_and_passing
- output_files_match_specification
- no_unspecified_side_effects
review_stage_2_code_quality:
checks:
- no_linter_errors
- no_type_errors
- naming_conventions_followed
- no_dead_code_or_debug_artifacts
- error_handling_present
- documentation_for_public_apis
merge:
strategy: "squash_per_subtask"
commit_message: "feat({subtask_name}): {one_line_summary}"Best Practices
最佳实践
- Keep subtask specs self-contained—a subagent should need no context beyond the spec
- Include file paths and relevant type signatures in every spec
- Run both review stages even if the code "looks correct" at first glance
- Limit subagent retry attempts to 2 before escalating to the orchestrator
- Use git worktrees for true filesystem isolation between parallel subagents
- Squash-merge each subtask to maintain a clean commit history
- 确保子任务规格自包含——Subagent 除规格说明外不应需要任何其他上下文
- 在每份规格说明中包含文件路径和相关类型签名
- 即使代码乍看之下“正确”,也要运行两个审查阶段
- 将 Subagent 重试次数限制为 2 次,之后升级处理并交由编排 Agent 接管
- 使用 git worktree 在并行 Subagent 之间实现真正的文件系统隔离
- 对每个子任务使用 squash-merge,以保持整洁的提交历史
Platform Compatibility
平台兼容性
| Platform | Support | Notes |
|---|---|---|
| Cursor | Full | Native Task tool for subagent dispatch |
| VS Code | Partial | Requires manual subprocess management |
| Windsurf | Full | Cascade supports subagent spawning |
| Claude Code | Full | Built-in subagent support |
| Cline | Partial | Plugin-based subagent support |
| aider | Limited | No native subagent capability |
| 平台 | 支持情况 | 备注 |
|---|---|---|
| Cursor | 完全支持 | 原生 Task 工具支持 Subagent 分派 |
| VS Code | 部分支持 | 需要手动管理子进程 |
| Windsurf | 完全支持 | Cascade 支持启动 Subagent |
| Claude Code | 完全支持 | 内置 Subagent 支持 |
| Cline | 部分支持 | 基于插件的 Subagent 支持 |
| aider | 有限支持 | 无原生 Subagent 能力 |
Related Skills
相关 Skill
- Git Worktrees - Isolated filesystem workspaces that prevent subagents from clobbering each other's changes
- Writing Plans - Plan authoring that produces the subtask specifications subagents execute against
- Code Review - Two-stage review process that validates subagent outputs before merge
- Sandbox Hardening - Execution isolation that constrains subagent permissions and resource usage
- Git Worktrees - 隔离的文件系统工作区,防止 Subagent 相互覆盖更改
- Writing Plans - 编写计划并生成供 Subagent 执行的子任务规格
- Code Review - 在合并前验证 Subagent 输出的两阶段审查流程
- Sandbox Hardening - 限制 Subagent 权限和资源使用的执行隔离机制
Keywords
关键词
subagenttask-decompositionparallel-developmenttwo-stage-reviewcontext-isolationorchestratorspec-drivenfresh-context© 2026 googleadsagent.ai™ | Agent Skills™ | MIT License
subagenttask-decompositionparallel-developmenttwo-stage-reviewcontext-isolationorchestratorspec-drivenfresh-context© 2026 googleadsagent.ai™ | Agent Skills™ | MIT License