planning-and-task-breakdown
addyosmani/agent-skills
将工作分解为具有明确验收标准的小型、可验证的任务,按依赖关系排序,并进行垂直切分,以确保可靠实施。
...展开全部规划与任务分解
概述
将工作分解为具有明确验收标准的小型、可验证的任务。良好的任务分解是区分能够可靠完成工作的执行者与只会制造一团乱麻的执行者的关键。每个任务都应足够小,以便在一次专注的工作时段内完成实施、测试和验证。
何时使用
- 您已拥有需求规格说明书,并需要将其分解为可实现的单元
- 任务规模过大或定义模糊,难以着手
- 工作需要在多个代理或会话之间并行处理
- 需要向人类传达工作范围
- 实现顺序不明确时
不应使用的情况:范围明确的单文件修改,或者规格说明书已包含定义清晰的任务。
规划流程
步骤 1:进入规划模式
在编写任何代码之前,请先进入只读模式:
- 阅读规格说明书及相关代码库部分
- 识别现有的模式和约定
- 绘制组件之间的依赖关系图
- 记录风险和未知因素
规划阶段切勿编写代码。该阶段的产出应为规划文档,而非实现代码。
步骤 2:识别依赖关系图
绘制依赖关系图:
数据库模式
│
├── API 模型/类型
│ │
│ ├── API 端点
│ │ │
│ │ └── 前端 API 客户端
│ │ │
│ │ └── UI 组件
│ │
│ └── 验证逻辑
│
└── 初始数据 / 迁移
实现顺序遵循依赖关系图的自底向上原则:先构建基础部分。
步骤 3:垂直切分
不要先构建整个数据库,再构建所有 API,最后构建所有 UI——而应一次构建一个完整的功能路径:
错误做法(水平切分):
任务 1:构建整个数据库模式
任务 2:构建所有 API 端点
任务 3:构建所有 UI 组件
任务 4:将所有内容连接起来
正确做法(垂直切片):
任务 1:用户可以创建账户(注册所需的数据库模式 + API + UI)
任务 2:用户可以登录(认证所需的数据库模式 + API + 登录界面)
任务 3:用户可以创建任务(任务模式 + API + 创建界面)
任务 4:用户可以查看任务列表(查询 + API + 列表视图界面)
每个垂直切片都能提供可运行且可测试的功能。
步骤 4:编写任务
每个任务遵循以下结构:
## 任务 [N]:[简短描述性标题]
**描述:** 一段文字说明该任务要实现什么。
**验收标准:**
- [ ] [具体、可测试的条件]
- [ ] [具体、可测试的条件]
**验证:**
- [ ] 测试通过:`npm test -- --grep "功能名称"`
- [ ] 构建成功:`npm run build`
- [ ] 手动检查:[待验证内容的描述]
**依赖项:** [此任务依赖的其他任务编号,或“无”]
**可能涉及的文件:**
- `src/path/to/file.ts`
- `tests/path/to/test.ts`
**预计范围:** [小:1-2 个文件 | 中:3-5 个文件 | 大:5 个及以上文件]
步骤 5:顺序与检查点
安排任务时应确保:
- 满足依赖关系(先构建基础)
- 每个任务完成后,系统均处于可运行状态
- 每完成2-3个任务后进行一次验证检查点
- 高风险任务安排在早期(快速发现问题)
添加明确的检查点:
## 检查点:完成任务1-3后
- [ ] 所有测试均通过
- [ ] 应用程序构建无错误
- [ ] 核心用户流程端到端正常运行
- [ ] 继续之前需经人工审核
任务规模规划指南
| 规模 | 文件 | 范围 | 示例 |
|---|---|---|---|
| XS | 1 | 单个函数或配置变更 | 添加一条验证规则 |
| S | 1-2 | 一个组件或端点 | 添加一个新的API端点 |
| M | 3-5 | 一个功能切片 | 用户注册流程 |
| L | 5-8 | 多组件功能 | 带筛选和分页功能的搜索 |
| XL | 8+ | 过大 — 请进一步细分 | — |
如果任务规模为 L 或更大,应将其拆分为更小的任务。代理在处理 S 和 M 级任务时表现最佳。
何时应进一步拆分任务:
- 该任务需要超过一个专注工作时段才能完成(约2小时以上的代理工作时间)
- 无法用3条或更少的要点描述验收标准
- 该任务涉及两个或更多独立的子系统(例如,身份验证和计费)
- 发现自己在任务标题中使用了“和”(这表明该任务实际上应拆分为两个任务)
计划文档模板
# 实施方案:[功能/项目名称]
## 概述
[用一段话概括我们要构建的内容]
## 架构决策
- [关键决策 1 及其理由]
- [关键决策 2 及其理由]
## 任务列表
### 第一阶段:基础构建
- [ ] 任务 1:...
- [ ] 任务 2:...
### 检查点:基础构建
- [ ] 测试通过,构建成功
### 第二阶段:核心功能
- [ ] 任务 3:...
- [ ] 任务 4:...
### 里程碑:核心功能
- [ ] 端到端流程正常运行
### 第三阶段:完善
- [ ] 任务 5:...
- [ ] 任务 6:...
### 检查点:完成
- [ ] 满足所有验收标准
- [ ] 已准备好接受评审
## 风险与缓解措施
| 风险 | 影响 | 缓解措施 |
|------|--------|------------|
| [风险] | [高/中/低] | [策略] |
## 待解决问题
- [需要人工介入的问题]
并行化机会
当有多个代理或会话可用时:
- 可安全并行处理:独立的功能切片、已实现功能的测试、文档
- 必须顺序执行:数据库迁移、共享状态变更、依赖链
- 需要协调:共享API契约的功能(先定义契约,再进行并行化)
常见的合理化理由
| 理由 | 现实情况 |
|---|---|
| “边做边想吧” | 这样最终只会导致一团乱麻和返工。花10分钟规划能节省数小时。 |
| “这些任务很明显” | 还是把它们写下来吧。明确的任务能揭示隐藏的依赖关系和被遗忘的边界情况。 |
| “规划是额外负担” | 规划本身就是一项任务。没有计划的实施,不过是机械地敲代码罢了。 |
| “我脑子里能记住所有内容” | 上下文窗口是有限的。书面计划能跨越会话边界并经受住数据压缩的考验。 |
警示信号
- 在没有书面任务清单的情况下就开始实施
- 任务描述仅为“实现该功能”,却未包含验收标准
- 计划中没有验证步骤
- 所有任务规模都过大
- 任务之间没有检查点
- 未考虑依赖顺序
验证
在开始实施之前,请确认:
- 每个任务都有验收标准
- 每个任务都有一个验证步骤
- 已正确识别并排序任务依赖关系
- 每个任务涉及的文件数量不超过约5个
- 主要阶段之间设有检查点
- 该计划已由人工审核并批准
另请参阅
验收标准是针对每个任务的,旨在回答“我们是否构建了正确的产品?”。这些标准建立在项目层面的“完成定义”之上,是每个任务在被视为完成之前必须跨越的门槛。参见references/definition-of-done.md。
---
name: planning-and-task-breakdown
description: Decompose work into small, verifiable tasks with explicit acceptance criteria, ordered by dependencies and sliced vertically for reliable implementation.
---
# Planning and Task Breakdown
## Overview
Decompose work into small, verifiable tasks with explicit acceptance criteria. Good task breakdown is the difference between an agent that completes work reliably and one that produces a tangled mess. Every task should be small enough to implement, test, and verify in a single focused session.
## When to Use
- You have a spec and need to break it into implementable units
- A task feels too large or vague to start
- Work needs to be parallelized across multiple agents or sessions
- You need to communicate scope to a human
- The implementation order isn't obvious
**When NOT to use:** Single-file changes with obvious scope, or when the spec already contains well-defined tasks.
## The Planning Process
### Step 1: Enter Plan Mode
Before writing any code, operate in read-only mode:
- Read the spec and relevant codebase sections
- Identify existing patterns and conventions
- Map dependencies between components
- Note risks and unknowns
**Do NOT write code during planning.** The output is a plan document, not implementation.
### Step 2: Identify the Dependency Graph
Map what depends on what:
```
Database schema
│
├── API models/types
│ │
│ ├── API endpoints
│ │ │
│ │ └── Frontend API client
│ │ │
│ │ └── UI components
│ │
│ └── Validation logic
│
└── Seed data / migrations
```
Implementation order follows the dependency graph bottom-up: build foundations first.
### Step 3: Slice Vertically
Instead of building all the database, then all the API, then all the UI — build one complete feature path at a time:
**Bad (horizontal slicing):**
```
Task 1: Build entire database schema
Task 2: Build all API endpoints
Task 3: Build all UI components
Task 4: Connect everything
```
**Good (vertical slicing):**
```
Task 1: User can create an account (schema + API + UI for registration)
Task 2: User can log in (auth schema + API + UI for login)
Task 3: User can create a task (task schema + API + UI for creation)
Task 4: User can view task list (query + API + UI for list view)
```
Each vertical slice delivers working, testable functionality.
### Step 4: Write Tasks
Each task follows this structure:
```markdown
## Task [N]: [Short descriptive title]
**Description:** One paragraph explaining what this task accomplishes.
**Acceptance criteria:**
- [ ] [Specific, testable condition]
- [ ] [Specific, testable condition]
**Verification:**
- [ ] Tests pass: `npm test -- --grep "feature-name"`
- [ ] Build succeeds: `npm run build`
- [ ] Manual check: [description of what to verify]
**Dependencies:** [Task numbers this depends on, or "None"]
**Files likely touched:**
- `src/path/to/file.ts`
- `tests/path/to/test.ts`
**Estimated scope:** [Small: 1-2 files | Medium: 3-5 files | Large: 5+ files]
```
### Step 5: Order and Checkpoint
Arrange tasks so that:
1. Dependencies are satisfied (build foundation first)
2. Each task leaves the system in a working state
3. Verification checkpoints occur after every 2-3 tasks
4. High-risk tasks are early (fail fast)
Add explicit checkpoints:
```markdown
## Checkpoint: After Tasks 1-3
- [ ] All tests pass
- [ ] Application builds without errors
- [ ] Core user flow works end-to-end
- [ ] Review with human before proceeding
```
## Task Sizing Guidelines
| Size | Files | Scope | Example |
|------|-------|-------|---------|
| **XS** | 1 | Single function or config change | Add a validation rule |
| **S** | 1-2 | One component or endpoint | Add a new API endpoint |
| **M** | 3-5 | One feature slice | User registration flow |
| **L** | 5-8 | Multi-component feature | Search with filtering and pagination |
| **XL** | 8+ | **Too large — break it down further** | — |
If a task is L or larger, it should be broken into smaller tasks. An agent performs best on S and M tasks.
**When to break a task down further:**
- It would take more than one focused session (roughly 2+ hours of agent work)
- You cannot describe the acceptance criteria in 3 or fewer bullet points
- It touches two or more independent subsystems (e.g., auth and billing)
- You find yourself writing "and" in the task title (a sign it is two tasks)
## Plan Document Template
```markdown
# Implementation Plan: [Feature/Project Name]
## Overview
[One paragraph summary of what we're building]
## Architecture Decisions
- [Key decision 1 and rationale]
- [Key decision 2 and rationale]
## Task List
### Phase 1: Foundation
- [ ] Task 1: ...
- [ ] Task 2: ...
### Checkpoint: Foundation
- [ ] Tests pass, builds clean
### Phase 2: Core Features
- [ ] Task 3: ...
- [ ] Task 4: ...
### Checkpoint: Core Features
- [ ] End-to-end flow works
### Phase 3: Polish
- [ ] Task 5: ...
- [ ] Task 6: ...
### Checkpoint: Complete
- [ ] All acceptance criteria met
- [ ] Ready for review
## Risks and Mitigations
| Risk | Impact | Mitigation |
|------|--------|------------|
| [Risk] | [High/Med/Low] | [Strategy] |
## Open Questions
- [Question needing human input]
```
## Parallelization Opportunities
When multiple agents or sessions are available:
- **Safe to parallelize:** Independent feature slices, tests for already-implemented features, documentation
- **Must be sequential:** Database migrations, shared state changes, dependency chains
- **Needs coordination:** Features that share an API contract (define the contract first, then parallelize)
## Common Rationalizations
| Rationalization | Reality |
|---|---|
| "I'll figure it out as I go" | That's how you end up with a tangled mess and rework. 10 minutes of planning saves hours. |
| "The tasks are obvious" | Write them down anyway. Explicit tasks surface hidden dependencies and forgotten edge cases. |
| "Planning is overhead" | Planning is the task. Implementation without a plan is just typing. |
| "I can hold it all in my head" | Context windows are finite. Written plans survive session boundaries and compaction. |
## Red Flags
- Starting implementation without a written task list
- Tasks that say "implement the feature" without acceptance criteria
- No verification steps in the plan
- All tasks are XL-sized
- No checkpoints between tasks
- Dependency order isn't considered
## Verification
Before starting implementation, confirm:
- [ ] Every task has acceptance criteria
- [ ] Every task has a verification step
- [ ] Task dependencies are identified and ordered correctly
- [ ] No task touches more than ~5 files
- [ ] Checkpoints exist between major phases
- [ ] The human has reviewed and approved the plan
## See Also
Acceptance criteria are per-task and answer "did we build the right thing?". They sit on top of the project-wide Definition of Done, the standing bar every task clears before it counts as done. See `references/definition-of-done.md`.





首页
