writing-plans
obra/superpowers
根據規格說明或需求,制定詳細的、循序漸進的實作計畫,其中包含任務分解、檔案結構以及測試驅動開發的指引。
...展開全部寫作計畫
概述
撰寫詳盡的實作計畫,假設工程師對我們的程式碼庫一無所知,且品味堪憂。將他們需要了解的一切都記錄下來:每項任務需修改哪些檔案、可能需要查閱的程式碼、測試與文件,以及如何進行測試。 將整個計畫拆解為易於消化的任務。遵循 DRY 原則。YAGNI 原則。TDD。頻繁提交。
假設對方是技術嫻熟的開發者,但對我們的工具集或問題領域幾乎一無所知。假設對方對良好的測試設計了解不深。
在開始時宣布:「我正在使用『writing-plans 』技能來制定實作計畫。」
背景:若在隔離的工作樹中作業,該工作樹應已於執行時透過「superpowers:using-git-worktrees」技能建立。
將計畫儲存至: docs/superpowers/plans/YYYY-MM-DD-
- (使用者對計畫位置的偏好設定會覆寫此預設值)
範圍檢查
若規格涵蓋多個獨立子系統,應已在腦力激盪階段將其拆分為子專案規格。若未如此處理,建議將其拆分為獨立計畫——每個子系統各一項。每個計畫應能獨立產出可運作且可測試的軟體。
檔案結構
在定義任務之前,應先規劃將建立或修改哪些檔案,以及每個檔案負責的內容。此處即為釐定分解決策的關鍵階段。
- 設計時應建立邊界清晰且介面明確定義的單元。每個檔案應僅承擔一項明確的職責。
- 當您能將程式碼置於完整上下文中同時掌握時,思考會更為透徹;而當檔案內容專注明確時,您的修改也會更為可靠。與其使用功能過於繁雜的大型檔案,不如選擇較小且專注的檔案。
- 應將會同步變更的檔案集中放置。應依據職責進行拆分,而非依據技術層級。
- 在現有程式碼庫中,應遵循既定模式。若程式碼庫採用大型檔案,切勿單方面進行重組——但若您正在修改的檔案已變得難以掌控,將拆分納入計畫是合理的。
此結構將引導任務的分解。每個任務應產生自成一體的變更,且這些變更在獨立情況下仍具意義。
任務規模適中
任務是具備獨立測試週期,且值得由 新審查者進行審核的最小單位。劃定任務邊界時:將設定、 配置、基礎架構及文件編寫等步驟,整合至 其交付成果需要這些步驟的任務中;僅在審查者可能有充分理由 拒絕某個任務,卻同時批准其相鄰任務的情況下,才進行拆分。 每個任務應以 可獨立測試的交付成果作為結尾。
適口大小的任務粒度
每個步驟皆為單一動作(2–5 分鐘):
- 「撰寫會失敗的測試」——步驟
- 「執行測試以確認其失敗」——步驟
- 「實作最低限度的程式碼,使測試通過」——步驟
- 「執行測試並確認其通過」——步驟
- 「提交」 - 步驟
計畫文件標題
每個計畫都必須以這個標題開頭:
# [功能名稱] 實作計畫
> **致主動型工作者:** 必備子技能:請使用 superpowers:subagent-driven-development(建議)或 superpowers:executing-plans,以任務為單位逐步實作此計畫。 步驟使用核取方塊(`- [ ]`)語法進行追蹤。
**目標:** [一句話描述此計畫將建構什麼]
**架構:** [2-3 句說明方法]
**技術堆疊:** [關鍵技術/函式庫]
## 全局限制
[規格文件中針對整個專案的要求——版本下限、依賴項限制、
命名與內容規則、平台要求——每項各佔一行,並將確切
數值原封不動地複製自規格文件。每個任務的要求皆隱含
包含此部分。]
---
任務結構
### 任務 N:[元件名稱]
**檔案:**
- 建立:`exact/path/to/file.py`
- 修改:`精確/路徑/至/既存.py:123-145`
- 測試:`tests/精確/路徑/至/test.py`
**介面:**
- 消耗:[此任務從先前任務中使用的內容 — 精確的簽名]
- 輸出:[後續任務所依賴的內容 — 確切的函式名稱、參數
及回傳類型。任務的實作者僅能看見自身任務;此
區塊正是他們了解鄰近任務所使用名稱與類型的途徑。]
- [ ] **步驟 1:撰寫會失敗的測試**
```python
def test_specific_behavior():
result = function(input)
assert result == expected
```
- [ ] **步驟 2:執行測試以驗證其會失敗**
執行:`pytest tests/path/test.py::test_name -v`
預期結果:失敗,並顯示「函式未定義」
- [ ] **步驟 3:撰寫最簡實作**
```python
def function(input):
return expected
```
- [ ] **步驟 4:執行測試以驗證其通過**
執行:`pytest tests/path/test.py::test_name -v`
預期結果:PASS
- [ ] **步驟 5:提交**
```bash
git add tests/路徑/test.py src/路徑/file.py
git commit -m "feat: 新增特定功能"
```
無佔位符
每個步驟都必須包含工程師實際需要的內容。以下是規劃失敗的範例— 切勿寫下這些:
- 「待定 (TBD)」、「待辦 (TODO)」、「稍後實作」、「填入詳細資訊」
- 「新增適當的錯誤處理」/「新增驗證」/「處理邊界情況」
- 「為上述內容撰寫測試」(未附實際測試程式碼)
- 「類似於任務 N」(重複代碼——工程師可能不會按順序閱讀任務)
- 僅描述「要做什麼」卻未說明「如何做」的步驟(程式步驟必須包含程式碼區塊)
- 引用任何任務中未定義的類型、函式或方法
請注意
- 務必始終提供確切的檔案路徑
- 每個步驟都應包含完整程式碼 — 若某步驟會變更程式碼,則須顯示該程式碼
- 精確的指令及其預期輸出
- DRY、YAGNI、TDD、頻繁提交
自我審查
撰寫完完整的計畫後,以嶄新的視角審視規格說明書,並對照規格檢查計畫內容。這是您自行執行的檢查清單——而非委派給子代理執行。
1. 規格書涵蓋度:瀏覽規格書中的每個章節/需求。能否指出具體實現該需求的任務?列出任何遺漏之處。
2. 佔位符掃描:在計畫中搜尋警示徵兆——即上文「無佔位符」節中提到的任何模式。予以修正。
3. 類型一致性:您在後續任務中使用的類型、方法簽名及屬性名稱,是否與先前任務中定義的內容一致?例如,任務 3 中名為clearLayers()的函式,在任務 7 中卻改名為clearFullLayers(),這便屬於錯誤。
若發現問題,請直接在程式碼中修正。無需重新審查——修正後即可繼續進行。若發現某項規格要求尚未對應至任何任務,請新增該任務。
執行交接
儲存計畫後,提供執行選項:
「計畫已完成並儲存至docs/superpowers/plans/。有兩種執行選項:
1. 子代理驅動(建議)—— 針對每個任務派遣一個新的子代理,在任務之間進行審查,快速迭代
2. 內嵌執行— 透過 executing-plans 在本次會話中執行任務,採用帶有檢查點的批次執行
請選擇哪種方式?」
若選擇「子代理驅動」:
- 必備子技能:使用 superpowers:subagent-driven-development
- 每個任務一個新的子代理 + 兩階段審查
若選擇「內嵌執行」:
- 必備子技能:使用超能力:執行計畫
- 批次執行並設有供審查的檢查點
---
name: writing-plans
description: Creates detailed, step-by-step implementation plans from specs or requirements, with task decomposition, file structure, and test-driven development instructions.
---
# Writing Plans
## Overview
Write comprehensive implementation plans assuming the engineer has zero context for our codebase and questionable taste. Document everything they need to know: which files to touch for each task, code, testing, docs they might need to check, how to test it. Give them the whole plan as bite-sized tasks. DRY. YAGNI. TDD. Frequent commits.
Assume they are a skilled developer, but know almost nothing about our toolset or problem domain. Assume they don't know good test design very well.
**Announce at start:** "I'm using the writing-plans skill to create the implementation plan."
**Context:** If working in an isolated worktree, it should have been created via the `superpowers:using-git-worktrees` skill at execution time.
**Save plans to:** `docs/superpowers/plans/YYYY-MM-DD-<feature-name>.md`
- (User preferences for plan location override this default)
## Scope Check
If the spec covers multiple independent subsystems, it should have been broken into sub-project specs during brainstorming. If it wasn't, suggest breaking this into separate plans — one per subsystem. Each plan should produce working, testable software on its own.
## File Structure
Before defining tasks, map out which files will be created or modified and what each one is responsible for. This is where decomposition decisions get locked in.
- Design units with clear boundaries and well-defined interfaces. Each file should have one clear responsibility.
- You reason best about code you can hold in context at once, and your edits are more reliable when files are focused. Prefer smaller, focused files over large ones that do too much.
- Files that change together should live together. Split by responsibility, not by technical layer.
- In existing codebases, follow established patterns. If the codebase uses large files, don't unilaterally restructure - but if a file you're modifying has grown unwieldy, including a split in the plan is reasonable.
This structure informs the task decomposition. Each task should produce self-contained changes that make sense independently.
## Task Right-Sizing
A task is the smallest unit that carries its own test cycle and is worth a
fresh reviewer's gate. When drawing task boundaries: fold setup,
configuration, scaffolding, and documentation steps into the task whose
deliverable needs them; split only where a reviewer could meaningfully
reject one task while approving its neighbor. Each task ends with an
independently testable deliverable.
## Bite-Sized Task Granularity
**Each step is one action (2-5 minutes):**
- "Write the failing test" - step
- "Run it to make sure it fails" - step
- "Implement the minimal code to make the test pass" - step
- "Run the tests and make sure they pass" - step
- "Commit" - step
## Plan Document Header
**Every plan MUST start with this header:**
```markdown
# [Feature Name] Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** [One sentence describing what this builds]
**Architecture:** [2-3 sentences about approach]
**Tech Stack:** [Key technologies/libraries]
## Global Constraints
[The spec's project-wide requirements — version floors, dependency limits,
naming and copy rules, platform requirements — one line each, with exact
values copied verbatim from the spec. Every task's requirements implicitly
include this section.]
---
```
## Task Structure
````markdown
### Task N: [Component Name]
**Files:**
- Create: `exact/path/to/file.py`
- Modify: `exact/path/to/existing.py:123-145`
- Test: `tests/exact/path/to/test.py`
**Interfaces:**
- Consumes: [what this task uses from earlier tasks — exact signatures]
- Produces: [what later tasks rely on — exact function names, parameter
and return types. A task's implementer sees only their own task; this
block is how they learn the names and types neighboring tasks use.]
- [ ] **Step 1: Write the failing test**
```python
def test_specific_behavior():
result = function(input)
assert result == expected
```
- [ ] **Step 2: Run test to verify it fails**
Run: `pytest tests/path/test.py::test_name -v`
Expected: FAIL with "function not defined"
- [ ] **Step 3: Write minimal implementation**
```python
def function(input):
return expected
```
- [ ] **Step 4: Run test to verify it passes**
Run: `pytest tests/path/test.py::test_name -v`
Expected: PASS
- [ ] **Step 5: Commit**
```bash
git add tests/path/test.py src/path/file.py
git commit -m "feat: add specific feature"
```
````
## No Placeholders
Every step must contain the actual content an engineer needs. These are **plan failures** — never write them:
- "TBD", "TODO", "implement later", "fill in details"
- "Add appropriate error handling" / "add validation" / "handle edge cases"
- "Write tests for the above" (without actual test code)
- "Similar to Task N" (repeat the code — the engineer may be reading tasks out of order)
- Steps that describe what to do without showing how (code blocks required for code steps)
- References to types, functions, or methods not defined in any task
## Remember
- Exact file paths always
- Complete code in every step — if a step changes code, show the code
- Exact commands with expected output
- DRY, YAGNI, TDD, frequent commits
## Self-Review
After writing the complete plan, look at the spec with fresh eyes and check the plan against it. This is a checklist you run yourself — not a subagent dispatch.
**1. Spec coverage:** Skim each section/requirement in the spec. Can you point to a task that implements it? List any gaps.
**2. Placeholder scan:** Search your plan for red flags — any of the patterns from the "No Placeholders" section above. Fix them.
**3. Type consistency:** Do the types, method signatures, and property names you used in later tasks match what you defined in earlier tasks? A function called `clearLayers()` in Task 3 but `clearFullLayers()` in Task 7 is a bug.
If you find issues, fix them inline. No need to re-review — just fix and move on. If you find a spec requirement with no task, add the task.
## Execution Handoff
After saving the plan, offer execution choice:
**"Plan complete and saved to `docs/superpowers/plans/<filename>.md`. Two execution options:**
**1. Subagent-Driven (recommended)** - I dispatch a fresh subagent per task, review between tasks, fast iteration
**2. Inline Execution** - Execute tasks in this session using executing-plans, batch execution with checkpoints
**Which approach?"**
**If Subagent-Driven chosen:**
- **REQUIRED SUB-SKILL:** Use superpowers:subagent-driven-development
- Fresh subagent per task + two-stage review
**If Inline Execution chosen:**
- **REQUIRED SUB-SKILL:** Use superpowers:executing-plans
- Batch execution with checkpoints for review
所有檔案
0 個檔案安裝 writing-plans
請下載並將技能檔案解壓縮至您的 .claude/skills/ 目錄中。
下載 ZIP複製儲存庫並將技能檔案複製到您的專案中。
git clone https://github.com/obra/superpowers/tree/main/skills/writing-plans # Copy SKILL.md to your .claude/skills/ directory
複製





首頁
