planning-and-task-breakdown
addyosmani/agent-skills
將工作分解為具有明確驗收標準的小型、可驗證任務,並依據依賴關係排序,同時進行垂直切分,以確保可靠地執行。
...展開全部規劃與任務分解
概述
將工作分解為具有明確驗收標準的小型、可驗證任務。良好的任務分解,是區分能可靠完成工作的執行者與造成一團亂局的執行者的關鍵。每個任務都應足夠簡短,以便在單次專注的工作時段內完成實作、測試與驗證。
何時使用
- 您已擁有規格說明,並需要將其分解為可實作的單元
- 某項任務感覺過於龐大或模糊,難以著手
- 工作需要跨多個代理或工作階段並行處理
- 您需要向人類溝通工作範圍
- 實作順序不明確時
何時不應使用:範圍明確的單一檔案變更,或當規格書中已包含定義明確的任務時。
規劃流程
步驟 1:進入規劃模式
在撰寫任何程式碼之前,請先以唯讀模式運作:
- 閱讀規格說明書及相關程式碼庫區段
- 識別現有的模式與規範
- 繪製元件之間的依賴關係圖
- 記錄風險與未知因素
規劃階段切勿編寫程式碼。此階段的產出應為規劃文件,而非實作程式碼。
步驟 2:識別依賴關係圖
繪製各元件之間的依賴關係:
資料庫結構
│
├── API 模型/類型
│ │
│ ├── API 端點
│ │ │
│ │ └── 前端 API 客戶端
│ │ │
│ │ └── UI 元件
│ │
│ └── 驗證邏輯
│
└── 初始資料 / 資料遷移
實作順序遵循依賴關係圖的自底向上原則:先建立基礎架構。
步驟 3:垂直切分
與其先建置所有資料庫、接著建置所有 API、最後建置所有 UI,不如一次建置一個完整的功能路徑:
錯誤做法(橫向切分):
任務 1:建置整個資料庫結構
任務 2:建置所有 API 端點
任務 3:建置所有 UI 元件
任務 4:整合所有元件
正確做法(垂直切片):
任務 1:使用者可建立帳號(註冊所需的資料庫結構 + API + 使用者介面)
任務 2:使用者可登入(認證所需的資料庫結構 + API + 登入使用者介面)
任務 3:使用者可建立任務(任務資料結構 + API + 建立任務的 UI)
任務 4:使用者可檢視任務清單(查詢 + API + 清單檢視的 UI)
每個垂直切片皆提供可運作且可測試的功能。
步驟 4:編寫任務
每個任務均遵循以下結構:
## 任務 [N]:[簡短描述性標題]
**描述:** 一段文字說明此任務的目標。
**驗收準則:**
- [ ] [具體且可測試的條件]
- [ ] [具體且可測試的條件]
**驗證:**
- [ ] 測試通過:`npm test -- --grep "功能名稱"`
- [ ] 建置成功:`npm run build`
- [ ] 手動檢查:[待驗證事項的描述]
**依賴項:** [此任務所依賴的任務編號,或「無」]
**可能涉及的檔案:**
- `src/檔案路徑.ts`
- `tests/測試路徑.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 個檔案
- 各主要階段之間設有檢查點
- 該計畫已由人員審閱並核准
參見
驗收標準是針對每個任務的,旨在回答「我們是否建構了正確的成果?」。這些標準建立在全專案層級的「完成定義」(Definition of Done)之上,每個任務都必須跨越這道門檻,才算完成。請參閱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`.





首頁
