选项

writing-plans

obra/superpowers obra/superpowers

根据规格说明或需求,制定详细的分步实施计划,其中包括任务分解、文件结构以及测试驱动开发指南。

...展开全部
8
更新时间 2026-09-03

写作计划

概述

假设工程师对我们的代码库一无所知,且品味堪忧,因此应编写详尽的实施计划。将他们需要了解的一切都记录下来:每项任务需要修改哪些文件、可能需要查阅的代码、测试用例和文档,以及如何进行测试。 将整个计划拆解为易于消化的任务。遵循DRY原则。遵循YAGNI原则。采用TDD。频繁提交。

假设他们是技术娴熟的开发者,但几乎不了解我们的工具集或问题领域。假设他们对良好的测试设计了解不多。

在开始时声明:“我正在使用writing-plans 技能来制定实现计划。”

背景:若在隔离的工作树中工作,该工作树应在执行时通过superpowers:using-git-worktrees技能创建。

将计划保存至: docs/superpowers/plans/YYYY-MM-DD-.md

  • (用户对计划位置的偏好设置将覆盖此默认值)

范围检查

如果规格说明涵盖多个独立的子系统,则应在头脑风暴阶段将其拆分为子项目规格说明。若未拆分,建议将其拆分为独立的计划——每个子系统一个计划。每个计划都应能够独立产出可运行且可测试的软件。

文件结构

在定义任务之前,应规划好将创建或修改哪些文件,以及每个文件负责的内容。这是确定分解方案的关键环节。

  • 设计具有清晰边界和明确接口的单元。每个文件应仅承担一项明确的职责。
  • 当你能一次性把握代码上下文时,思考会更清晰;当文件职责专注时,修改也会更可靠。应优先选择规模较小、职责明确的文件,而非功能过于繁杂的大型文件。
  • 需要协同变更的文件应集中存放。按职责划分,而非按技术层级划分。
  • 在现有代码库中,应遵循既定模式。如果代码库使用的是大型文件,不要单方面进行重构——但如果正在修改的文件已经变得难以管理,将拆分纳入计划是合理的。

这种结构决定了任务的分解方式。每个任务应产生自成体系的变更,这些变更在独立情况下也应有其合理性。

任务规模优化

任务是具有独立测试周期且值得由 新审阅者进行审核的最小单元。在划定任务边界时:将准备、 配置、框架搭建和文档编写步骤整合到 需要这些步骤的任务中;仅在审阅者可能有充分理由 拒绝一个任务而批准其相邻任务的情况下才进行拆分。 每个任务都应以一个 可独立测试的交付物作为结束。

适口大小的任务粒度

每个步骤都是一项操作(2-5分钟):

  • “编写失败的测试”——步骤
  • “运行测试以确保其失败”——步骤
  • “实现最少的代码以使测试通过” — 步骤
  • “运行测试并确保其通过” — 步骤
  • “提交” - 步骤

计划文档标题

每个计划都必须以以下标题开头:

# [功能名称] 实现计划

> **针对主动型工作者:** 必备子技能:使用 superpowers:subagent-driven-development(推荐)或 superpowers:executing-plans,按任务逐一实施本计划。 步骤使用复选框(`- [ ]`)语法进行跟踪。

**目标:** [一句描述此计划将构建什么]

**架构:** [2-3句关于实现方法的说明]

**技术栈:** [关键技术/库]

## 全局约束

[规范中针对整个项目的要求——版本下限、依赖项限制、
命名和文本规则、平台要求——每项各占一行,具体
数值需逐字照搬自规范。每个任务的要求均默认
包含本节内容。]

---

任务结构

### 任务 N:[组件名称]

**文件:**
- 创建:`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`
预期结果:失败,并显示“函数未定义”

- [ ] **步骤 3:编写最简实现**

```python
def function(input):
    return expected
```

- [ ] **步骤 4:运行测试以验证其通过**

运行:`pytest tests/path/test.py::test_name -v`
预期结果:PASS

- [ ] **步骤 5:提交**

```bash
git add tests/path/test.py src/path/file.py
git commit -m "feat: 添加特定功能"
```

不使用占位符

每个步骤都必须包含工程师实际需要的内容。以下情况属于计划失误——切勿写入:

  • “待定(TBD)”、“待办(TODO)”、“稍后实现”、“补充细节”
  • “添加适当的错误处理” / “添加验证” / “处理边界情况”
  • “为上述内容编写测试”(未包含实际测试代码)
  • “类似于任务 N”(重复代码——工程师可能不会按顺序阅读任务)
  • 仅描述“做什么”而未说明“如何做”的步骤(代码步骤必须包含代码块)
  • 引用了在任何任务中均未定义的类型、函数或方法

请注意

  • 始终提供确切的文件路径
  • 每个步骤都应包含完整的代码——如果某一步骤修改了代码,请展示该代码
  • 精确的命令及其预期输出
  • DRY、YAGNI、TDD、频繁提交

自我审查

在编写完完整计划后,以全新的视角审视规格说明书,并对照规格检查计划是否符合要求。这是一份由你自己执行的检查清单——而不是分派给子代理的任务。

1. 规格说明书覆盖率:浏览规格说明书中的每个部分/需求。能否指出一个实现该需求的任务?列出任何遗漏之处。

2. 占位符扫描:在计划中搜索红旗——即上文“无占位符”部分中提到的任何模式。予以修正。

3. 类型一致性:你在后续任务中使用的类型、方法签名和属性名称是否与早期任务中定义的一致?例如,任务 3 中名为clearLayers()的函数在任务 7 中却名为clearFullLayers(),这便是一个错误。

若发现问题,请直接在代码中修复。无需重新审查——修复后即可继续。若发现某项规格要求未对应任何任务,请添加相应任务。

执行交接

保存计划后,提供执行选项:

“计划已完成并保存至docs/superpowers/plans/.md。有两种执行选项:

1. 子代理驱动(推荐)——我为每个任务调度一个新的子代理,在任务之间进行审查,快速迭代

2. 内联执行——使用 executing-plans 在当前会话中执行任务,通过检查点进行批量执行

选择哪种方式?”

若选择“子代理驱动”:

  • 必备子技能:使用 superpowers:subagent-driven-development
  • 每个任务一个新的子代理 + 两阶段审查

若选择“内联执行”:

  • 必备子技能:使用超能力:执行计划
  • 带检查点的批量执行,以便进行审查
在 GitHub 上查看
---
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

复制 复制
快速设置: 将技能文件夹复制到 .claude/skills/ Claude 会自动检测并使用该技能

相关技能

notion-automation
更新时间 2026-06-29
seo-programmatic
更新时间 2026-06-29
airtable-automation
更新时间 2026-06-29
revops
更新时间 2026-06-29
OR