|
| 1 | +# Writing Plans (shared reference) |
| 2 | + |
| 3 | +**Purpose:** Guide for writing comprehensive implementation plans before touching code. Assumes engineer has zero context for the codebase and questionable taste. |
| 4 | + |
| 5 | +**Used by:** Any skill that produces implementation plans for multi-step tasks. |
| 6 | + |
| 7 | +## Overview |
| 8 | + |
| 9 | +Document everything an engineer needs: which files to touch, code, testing, docs to check, how to verify. Give the whole plan as bite-sized tasks. DRY. YAGNI. TDD. Frequent commits. |
| 10 | + |
| 11 | +Assume skilled developer, but knows almost nothing about the toolset or problem domain. Assume weak test design instincts. |
| 12 | + |
| 13 | +**Save plans to:** `docs/plans/YYYY-MM-DD-<feature-name>.md` |
| 14 | +- (User preferences for plan location override this default) |
| 15 | + |
| 16 | +## Scope Check |
| 17 | + |
| 18 | +If spec covers multiple independent subsystems, suggest breaking into separate plans — one per subsystem. Each plan should produce working, testable software on its own. |
| 19 | + |
| 20 | +## File Structure |
| 21 | + |
| 22 | +Before defining tasks, map out which files will be created or modified and what each one is responsible for. |
| 23 | + |
| 24 | +- Design units with clear boundaries and well-defined interfaces. Each file: one clear responsibility. |
| 25 | +- Prefer smaller, focused files over large ones that do too much. |
| 26 | +- Files that change together should live together. Split by responsibility, not by technical layer. |
| 27 | +- In existing codebases, follow established patterns. If a file you're modifying has grown unwieldy, including a split in the plan is reasonable. |
| 28 | + |
| 29 | +This structure informs task decomposition. Each task should produce self-contained changes that make sense independently. |
| 30 | + |
| 31 | +## Bite-Sized Task Granularity |
| 32 | + |
| 33 | +**Each step is one action (2-5 minutes):** |
| 34 | +- "Write the failing test" - step |
| 35 | +- "Run it to make sure it fails" - step |
| 36 | +- "Implement the minimal code to make the test pass" - step |
| 37 | +- "Run the tests and make sure they pass" - step |
| 38 | +- "Commit" - step |
| 39 | + |
| 40 | +## Plan Document Header |
| 41 | + |
| 42 | +**Every plan MUST start with this header:** |
| 43 | + |
| 44 | +```markdown |
| 45 | +# [Feature Name] Implementation Plan |
| 46 | + |
| 47 | +**Goal:** [One sentence describing what this builds] |
| 48 | + |
| 49 | +**Architecture:** [2-3 sentences about approach] |
| 50 | + |
| 51 | +**Tech Stack:** [Key technologies/libraries] |
| 52 | + |
| 53 | +--- |
| 54 | +``` |
| 55 | + |
| 56 | +## Task Structure |
| 57 | + |
| 58 | +````markdown |
| 59 | +### Task N: [Component Name] |
| 60 | + |
| 61 | +**Files:** |
| 62 | +- Create: `exact/path/to/file.rb` |
| 63 | +- Modify: `exact/path/to/existing.rb:123-145` |
| 64 | +- Test: `spec/exact/path/to/file_spec.rb` |
| 65 | + |
| 66 | +- [ ] **Step 1: Write the failing test** |
| 67 | + |
| 68 | +```ruby |
| 69 | +RSpec.describe ClassName do |
| 70 | + describe "#method_name" do |
| 71 | + it "does specific behavior" do |
| 72 | + result = subject.method_name(input) |
| 73 | + expect(result).to eq(expected) |
| 74 | + end |
| 75 | + end |
| 76 | +end |
| 77 | +``` |
| 78 | + |
| 79 | +- [ ] **Step 2: Run test to verify it fails** |
| 80 | + |
| 81 | +Run: `bundle exec rspec spec/path/file_spec.rb` |
| 82 | +Expected: FAIL with "undefined method `method_name'" |
| 83 | + |
| 84 | +- [ ] **Step 3: Write minimal implementation** |
| 85 | + |
| 86 | +```ruby |
| 87 | +def method_name(input) |
| 88 | + expected |
| 89 | +end |
| 90 | +``` |
| 91 | + |
| 92 | +- [ ] **Step 4: Run test to verify it passes** |
| 93 | + |
| 94 | +Run: `bundle exec rspec spec/path/file_spec.rb` |
| 95 | +Expected: PASS |
| 96 | + |
| 97 | +- [ ] **Step 5: Commit** |
| 98 | + |
| 99 | +```bash |
| 100 | +git add spec/path/file_spec.rb app/path/file.rb |
| 101 | +git commit -m "feat: add specific feature" |
| 102 | +``` |
| 103 | +```` |
| 104 | + |
| 105 | +## No Placeholders |
| 106 | + |
| 107 | +Every step must contain the actual content an engineer needs. These are **plan failures** — never write them: |
| 108 | +- "TBD", "TODO", "implement later", "fill in details" |
| 109 | +- "Add appropriate error handling" / "add validation" / "handle edge cases" |
| 110 | +- "Write tests for the above" (without actual test code) |
| 111 | +- "Similar to Task N" (repeat the code — engineer may be reading tasks out of order) |
| 112 | +- Steps that describe what to do without showing how (code blocks required for code steps) |
| 113 | +- References to types, methods, or classes not defined in any task |
| 114 | + |
| 115 | +## Remember |
| 116 | +- Exact file paths always |
| 117 | +- Complete code in every step — if a step changes code, show the code |
| 118 | +- Exact commands with expected output |
| 119 | +- DRY, YAGNI, TDD, frequent commits |
| 120 | + |
| 121 | +## Self-Review |
| 122 | + |
| 123 | +After writing the complete plan, check against spec with fresh eyes. Run yourself — not a subagent dispatch. |
| 124 | + |
| 125 | +**1. Spec coverage:** Skim each section/requirement. Can you point to a task that implements it? List gaps. |
| 126 | + |
| 127 | +**2. Placeholder scan:** Search for red flags — any patterns from "No Placeholders" above. Fix them. |
| 128 | + |
| 129 | +**3. Type consistency:** Do method signatures and property names in later tasks match what you defined in earlier tasks? A method called `clear_layers` in Task 3 but `clear_full_layers` in Task 7 is a bug. |
| 130 | + |
| 131 | +If you find issues, fix them inline. If you find a spec requirement with no task, add the task. |
0 commit comments