sp-writing-plans

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

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)
编写全面的实现计划,假设工程师对我们的代码库完全不了解,且缺乏良好的代码品味。记录他们需要知道的所有信息:每个任务需要修改哪些文件、可能需要查阅的代码、测试和文档,以及如何进行测试。将整个计划拆分为易于处理的小任务。遵循DRY、YAGNI、TDD原则,频繁提交代码。
假设他们是熟练的开发者,但对我们的工具集或问题领域几乎一无所知,且不太了解良好的测试设计方法。
开始时需声明:“我正在使用writing-plans技能创建实现计划。”
**上下文说明:**如果在独立工作树中操作,应在执行阶段通过
superpowers:using-git-worktrees
技能创建该工作树。
计划保存路径:
docs/superpowers/plans/YYYY-MM-DD-<feature-name>.md
-(用户对计划位置的偏好将覆盖此默认设置)

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
每个步骤对应一个操作(2-5分钟):
  • “编写失败的测试用例”——步骤
  • “运行测试以确认其失败”——步骤
  • “编写最小化代码使测试通过”——步骤
  • “运行测试以确认其通过”——步骤
  • “提交代码”——步骤

Plan Document Header

计划文档头部

Every plan MUST start with this header:
markdown
undefined
每个计划必须以以下头部开头:
markdown
undefined

[Feature Name] Implementation Plan

[功能名称] 实现计划

For agentic workers: REQUIRED SUB-SKILL: Use sp-subagent-driven-development (recommended) or sp-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]
Spec: [path to the spec/design doc this plan implements — the plan argues from the spec, so the spec travels with it; executors read both]
面向智能代理工作者: 必备子技能:使用sp-subagent-driven-development(推荐)或sp-executing-plans逐项执行本计划。步骤使用复选框(
- [ ]
)语法进行跟踪。
目标: [一句话描述本计划要构建的内容]
架构: [2-3句话说明实现方法]
技术栈: [关键技术/库]
规格说明: [本计划所实现的规格/设计文档路径——计划基于规格说明制定,因此需附带规格说明;执行者需同时阅读两者]

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.]

undefined
[规格说明中的项目级要求——版本下限、依赖限制、命名和文案规则、平台要求——每项一行,严格复制规格说明中的准确内容。所有任务的要求均隐含包含本节内容。]

undefined

Task Structure

任务结构

markdown
undefined
markdown
undefined

Task N: [Component Name]

任务N:[组件名称]

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"
undefined
文件:
  • 创建:
    exact/path/to/file.py
  • 修改:
    exact/path/to/existing.py:123-145
  • 测试:
    tests/exact/path/to/test.py
接口:
  • 依赖:[本任务从前期任务中使用的内容——准确的签名]
  • 产出:[后续任务依赖的内容——准确的函数名称、参数和返回类型。任务执行者仅能看到自己的任务;此部分告知他们相邻任务使用的名称和类型。]
  • 步骤1:编写失败的测试用例
python
def test_specific_behavior():
    result = function(input)
    assert result == expected
  • 步骤2:运行测试以验证其失败
运行:
pytest tests/path/test.py::test_name -v
预期结果:失败,提示“function not defined”
  • 步骤3:编写最小化实现代码
python
def function(input):
    return expected
  • 步骤4:运行测试以验证其通过
运行:
pytest tests/path/test.py::test_name -v
预期结果:通过
  • 步骤5:提交代码
bash
git add tests/path/test.py src/path/file.py
git commit -m "feat: add specific feature"
undefined

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
每个步骤必须包含工程师所需的实际内容。以下情况属于计划失败——绝对不能出现:
  • “TBD”、“TODO”、“后续实现”、“补充细节”
  • “添加适当的错误处理” / “添加验证” / “处理边缘情况”
  • “为上述内容编写测试”(未提供实际测试代码)
  • “与任务N类似”(需重复代码——工程师可能会无序阅读任务)
  • 仅描述操作内容但未展示实现方式的步骤(代码步骤需附带代码块)
  • 引用未在任何任务中定义的类型、函数或方法

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.
编写完完整计划后,重新审视规格说明,检查计划是否符合要求。这是你自行执行的检查清单——无需调用子代理。
1. 规格覆盖度: 浏览规格说明的每个章节/需求。你能否指出实现该需求的任务?列出所有遗漏的部分。
2. 占位符扫描: 在计划中搜索危险信号——上述“禁止使用占位符”部分中的任何模式。修复这些问题。
3. 类型一致性: 你在后续任务中使用的类型、方法签名和属性名称是否与前期任务中的定义一致?例如任务3中名为
clearLayers()
的函数在任务7中被称为
clearFullLayers()
,这是一个错误。
如果发现问题,直接在计划中修改。无需重新评审——修复后即可继续。如果发现规格说明中的需求未对应任何任务,添加相应任务。

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 sp-executing-plans, batch execution with checkpoints
Which approach?"
If Subagent-Driven chosen:
  • REQUIRED SUB-SKILL: Use sp-subagent-driven-development
  • Fresh subagent per task + two-stage review
If Inline Execution chosen:
  • REQUIRED SUB-SKILL: Use sp-executing-plans
  • Batch execution with checkpoints for review
保存计划后,提供执行选项:
“计划已完成并保存至
docs/superpowers/plans/<filename>.md
。有两种执行选项:
1. 子代理驱动(推荐) - 我为每个任务分配一个全新的子代理,任务间进行评审,迭代速度快
2. 内联执行 - 使用sp-executing-plans在本次会话中执行任务,批量执行并设置检查点
选择哪种方式?
若选择子代理驱动:
  • 必备子技能: 使用sp-subagent-driven-development
  • 每个任务分配全新子代理 + 两阶段评审
若选择内联执行:
  • 必备子技能: 使用sp-executing-plans
  • 批量执行并设置检查点用于评审