spets 0.1.9 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -121,19 +121,19 @@ function createDefaultSteps(spetsDir) {
121
121
  writeFileSync(join(implementDir, "template.md"), getImplementTemplate());
122
122
  }
123
123
  function getPlanInstruction() {
124
- const fullTemplate = readFileSync(join(__dirname, "..", ".spets", "steps", "01-plan", "instruction.md"), "utf-8");
124
+ const fullTemplate = readFileSync(join(__dirname, "..", "templates", "steps", "01-plan", "instruction.md"), "utf-8");
125
125
  return fullTemplate;
126
126
  }
127
127
  function getPlanTemplate() {
128
- const fullTemplate = readFileSync(join(__dirname, "..", ".spets", "steps", "01-plan", "template.md"), "utf-8");
128
+ const fullTemplate = readFileSync(join(__dirname, "..", "templates", "steps", "01-plan", "template.md"), "utf-8");
129
129
  return fullTemplate;
130
130
  }
131
131
  function getImplementInstruction() {
132
- const fullTemplate = readFileSync(join(__dirname, "..", ".spets", "steps", "02-implement", "instruction.md"), "utf-8");
132
+ const fullTemplate = readFileSync(join(__dirname, "..", "templates", "steps", "02-implement", "instruction.md"), "utf-8");
133
133
  return fullTemplate;
134
134
  }
135
135
  function getImplementTemplate() {
136
- const fullTemplate = readFileSync(join(__dirname, "..", ".spets", "steps", "02-implement", "template.md"), "utf-8");
136
+ const fullTemplate = readFileSync(join(__dirname, "..", "templates", "steps", "02-implement", "template.md"), "utf-8");
137
137
  return fullTemplate;
138
138
  }
139
139
  function createClaudeCommand(cwd) {
@@ -323,7 +323,13 @@ jobs:
323
323
  - name: Checkout
324
324
  uses: actions/checkout@v4
325
325
  with:
326
- fetch-depth: 0
326
+ fetch-depth: 1
327
+ persist-credentials: false
328
+
329
+ - name: Setup Git
330
+ run: |
331
+ git config user.name "github-actions[bot]"
332
+ git config user.email "github-actions[bot]@users.noreply.github.com"
327
333
 
328
334
  - name: Parse Issue body
329
335
  id: parse
@@ -344,17 +350,33 @@ jobs:
344
350
 
345
351
  - name: Create and checkout branch
346
352
  run: |
353
+ git remote set-url origin https://x-access-token:${gh("secrets.PAT_TOKEN")}@github.com/${gh("github.repository")}.git
347
354
  git checkout -b ${gh("steps.parse.outputs.branch")}
348
355
  git push -u origin ${gh("steps.parse.outputs.branch")}
349
- env:
350
- GH_TOKEN: ${gh("secrets.GITHUB_TOKEN")}
351
356
 
352
357
  - name: Setup Node.js
353
358
  uses: actions/setup-node@v4
354
359
  with:
355
360
  node-version: '20'
361
+ cache: 'npm'
362
+
363
+ - name: Cache global npm packages
364
+ uses: actions/cache@v4
365
+ with:
366
+ path: ~/.npm
367
+ key: ${gh("runner.os")}-npm-global-${gh("hashFiles('package-lock.json')")}
368
+ restore-keys: |
369
+ ${gh("runner.os")}-npm-global-
370
+
371
+ - name: Cache Claude Code
372
+ id: cache-claude
373
+ uses: actions/cache@v4
374
+ with:
375
+ path: /usr/local/lib/node_modules/@anthropic-ai/claude-code
376
+ key: claude-code-${gh("runner.os")}-v1
356
377
 
357
378
  - name: Install Claude Code
379
+ if: steps.cache-claude.outputs.cache-hit != 'true'
358
380
  run: npm install -g @anthropic-ai/claude-code
359
381
 
360
382
  - name: Install dependencies
@@ -370,13 +392,10 @@ jobs:
370
392
 
371
393
  - name: Push changes
372
394
  run: |
373
- git config user.name "github-actions[bot]"
374
- git config user.email "github-actions[bot]@users.noreply.github.com"
395
+ git remote set-url origin https://x-access-token:${gh("secrets.PAT_TOKEN")}@github.com/${gh("github.repository")}.git
375
396
  git add -A
376
397
  git diff --staged --quiet || git commit -m "Spets: Start workflow for #${gh("github.event.issue.number")}"
377
398
  git push
378
- env:
379
- GH_TOKEN: ${gh("secrets.GITHUB_TOKEN")}
380
399
 
381
400
  # Handle commands from Issue/PR comments
382
401
  handle-command:
@@ -389,38 +408,108 @@ jobs:
389
408
  runs-on: ubuntu-latest
390
409
 
391
410
  steps:
392
- - name: Find linked branch
411
+ - name: Find branch from Issue or PR
393
412
  id: branch
413
+ env:
414
+ GH_TOKEN: ${gh("secrets.GITHUB_TOKEN")}
394
415
  run: |
395
- # Try to find branch linked to this issue
396
- BRANCH=$(gh api repos/${gh("github.repository")}/issues/${gh("github.event.issue.number")} --jq '.body' | grep -oP 'spets/\\d+' || echo "")
397
- if [ -z "$BRANCH" ]; then
398
- BRANCH="spets/${gh("github.event.issue.number")}"
416
+ # Check if this is a PR (has pull_request field)
417
+ PR_BRANCH=$(gh api repos/${gh("github.repository")}/issues/${gh("github.event.issue.number")} --jq '.pull_request.url // empty' 2>/dev/null)
418
+
419
+ if [ -n "$PR_BRANCH" ]; then
420
+ # It's a PR - get head branch directly
421
+ BRANCH=$(gh api repos/${gh("github.repository")}/pulls/${gh("github.event.issue.number")} --jq '.head.ref')
422
+ echo "Found PR head branch: $BRANCH"
423
+ else
424
+ # It's an Issue - try to parse branch name from body
425
+ ISSUE_BODY=$(gh api repos/${gh("github.repository")}/issues/${gh("github.event.issue.number")} --jq '.body')
426
+ CUSTOM_BRANCH=$(echo "$ISSUE_BODY" | sed -n '/### Branch Name/,/###/{/###/!p;}' | sed '/^$/d' | head -1)
427
+
428
+ if [ -n "$CUSTOM_BRANCH" ]; then
429
+ BRANCH="$CUSTOM_BRANCH"
430
+ else
431
+ BRANCH="spets/${gh("github.event.issue.number")}"
432
+ fi
433
+ fi
434
+
435
+ echo "Checking for branch: $BRANCH"
436
+
437
+ # Check if branch exists on remote using gh api
438
+ if gh api "repos/${gh("github.repository")}/branches/$BRANCH" --silent 2>/dev/null; then
439
+ echo "name=$BRANCH" >> $GITHUB_OUTPUT
440
+ echo "exists=true" >> $GITHUB_OUTPUT
441
+ echo "Branch $BRANCH found!"
442
+ else
443
+ echo "exists=false" >> $GITHUB_OUTPUT
444
+ echo "expected=$BRANCH" >> $GITHUB_OUTPUT
445
+ echo "::error::Branch $BRANCH not found. Start workflow first by creating an Issue with 'spets' label."
399
446
  fi
400
- echo "name=$BRANCH" >> $GITHUB_OUTPUT
447
+
448
+ - name: Post error comment
449
+ if: steps.branch.outputs.exists == 'false'
450
+ run: |
451
+ gh issue comment ${gh("github.event.issue.number")} \\
452
+ -R "${gh("github.repository")}" \\
453
+ --body "\u274C **Spets Error**: Branch \\\`${gh("steps.branch.outputs.expected")}\\\` not found.
454
+
455
+ Please make sure the workflow was started properly. You can:
456
+ 1. Add the \\\`spets\\\` label to this issue to trigger the start workflow
457
+ 2. Or manually create the branch and run \\\`spets start\\\`"
401
458
  env:
402
459
  GH_TOKEN: ${gh("secrets.GITHUB_TOKEN")}
403
460
 
461
+ - name: Exit if branch not found
462
+ if: steps.branch.outputs.exists == 'false'
463
+ run: exit 1
464
+
404
465
  - name: Checkout
405
466
  uses: actions/checkout@v4
406
467
  with:
407
468
  ref: ${gh("steps.branch.outputs.name")}
408
- fetch-depth: 0
469
+ fetch-depth: 1
470
+ persist-credentials: false
471
+
472
+ - name: Setup Git
473
+ run: |
474
+ git config user.name "github-actions[bot]"
475
+ git config user.email "github-actions[bot]@users.noreply.github.com"
409
476
 
410
477
  - name: Setup Node.js
411
478
  uses: actions/setup-node@v4
412
479
  with:
413
480
  node-version: '20'
481
+ cache: 'npm'
482
+
483
+ - name: Cache global npm packages
484
+ uses: actions/cache@v4
485
+ with:
486
+ path: ~/.npm
487
+ key: ${gh("runner.os")}-npm-global-${gh("hashFiles('package-lock.json')")}
488
+ restore-keys: |
489
+ ${gh("runner.os")}-npm-global-
490
+
491
+ - name: Cache Claude Code
492
+ id: cache-claude
493
+ uses: actions/cache@v4
494
+ with:
495
+ path: /usr/local/lib/node_modules/@anthropic-ai/claude-code
496
+ key: claude-code-${gh("runner.os")}-v1
414
497
 
415
498
  - name: Install Claude Code
499
+ if: steps.cache-claude.outputs.cache-hit != 'true'
416
500
  run: npm install -g @anthropic-ai/claude-code
417
501
 
418
502
  - name: Install dependencies
419
503
  run: npm ci
420
504
 
421
505
  - name: Run Spets command
506
+ id: spets
422
507
  run: |
423
508
  npx spets github --issue ${gh("github.event.issue.number")} --comment "$COMMENT"
509
+ # Check if PR should be created
510
+ if [[ "$COMMENT" == "/approve --pr"* ]]; then
511
+ echo "create_pr=true" >> $GITHUB_OUTPUT
512
+ fi
424
513
  env:
425
514
  COMMENT: ${gh("github.event.comment.body")}
426
515
  CLAUDE_CODE_OAUTH_TOKEN: ${gh("secrets.CLAUDE_CODE_OAUTH_TOKEN")}
@@ -428,13 +517,33 @@ jobs:
428
517
 
429
518
  - name: Push changes
430
519
  run: |
431
- git config user.name "github-actions[bot]"
432
- git config user.email "github-actions[bot]@users.noreply.github.com"
520
+ git remote set-url origin https://x-access-token:${gh("secrets.PAT_TOKEN")}@github.com/${gh("github.repository")}.git
433
521
  git add -A
434
522
  git diff --staged --quiet || git commit -m "Spets: Update from #${gh("github.event.issue.number")}"
435
523
  git push
524
+
525
+ - name: Create PR
526
+ if: steps.spets.outputs.create_pr == 'true'
527
+ run: |
528
+ PR_BODY="Closes #${gh("github.event.issue.number")}
529
+
530
+ ---
531
+
532
+ ## Spets Commands
533
+
534
+ | Command | Description |
535
+ |---------|-------------|
536
+ | \\\`/approve\\\` | Approve current step and continue |
537
+ | \\\`/approve --pr\\\` | Approve and create PR |
538
+ | \\\`/revise <feedback>\\\` | Request changes with feedback |
539
+ | \\\`/reject\\\` | Reject and stop workflow |"
540
+
541
+ gh pr create \\
542
+ --title "Spets: Issue #${gh("github.event.issue.number")}" \\
543
+ --body "$PR_BODY" \\
544
+ --repo ${gh("github.repository")}
436
545
  env:
437
- GH_TOKEN: ${gh("secrets.GITHUB_TOKEN")}
546
+ GH_TOKEN: ${gh("secrets.PAT_TOKEN")}
438
547
  `;
439
548
  }
440
549
 
@@ -1514,28 +1623,28 @@ function installClaudePlugin() {
1514
1623
  const claudeDir = join3(homedir(), ".claude");
1515
1624
  const commandsDir = join3(claudeDir, "commands");
1516
1625
  mkdirSync2(commandsDir, { recursive: true });
1517
- const skillPath = join3(commandsDir, "sdd-do.md");
1626
+ const skillPath = join3(commandsDir, "spets.md");
1518
1627
  writeFileSync2(skillPath, getClaudeSkillContent());
1519
1628
  console.log("Installed Claude Code plugin.");
1520
1629
  console.log(`Location: ${skillPath}`);
1521
1630
  console.log("");
1522
1631
  console.log("Usage in Claude Code:");
1523
- console.log(' /sdd-do "your task description"');
1632
+ console.log(' /spets "your task description"');
1524
1633
  console.log("");
1525
1634
  console.log("This skill runs deterministically within your Claude Code session.");
1526
1635
  console.log("No additional Claude processes are spawned.");
1527
1636
  }
1528
1637
  async function uninstallPlugin(name) {
1529
1638
  if (name === "claude") {
1530
- const oldSkillPath = join3(homedir(), ".claude", "commands", "spets.md");
1531
- const newSkillPath = join3(homedir(), ".claude", "commands", "sdd-do.md");
1639
+ const skillPath = join3(homedir(), ".claude", "commands", "spets.md");
1640
+ const legacySkillPath = join3(homedir(), ".claude", "commands", "sdd-do.md");
1532
1641
  let uninstalled = false;
1533
- if (existsSync3(oldSkillPath)) {
1534
- rmSync(oldSkillPath);
1642
+ if (existsSync3(skillPath)) {
1643
+ rmSync(skillPath);
1535
1644
  uninstalled = true;
1536
1645
  }
1537
- if (existsSync3(newSkillPath)) {
1538
- rmSync(newSkillPath);
1646
+ if (existsSync3(legacySkillPath)) {
1647
+ rmSync(legacySkillPath);
1539
1648
  uninstalled = true;
1540
1649
  }
1541
1650
  if (uninstalled) {
@@ -1551,11 +1660,11 @@ async function uninstallPlugin(name) {
1551
1660
  async function listPlugins() {
1552
1661
  console.log("Available plugins:");
1553
1662
  console.log("");
1554
- console.log(" claude - Claude Code /sdd-do skill");
1663
+ console.log(" claude - Claude Code /spets skill");
1555
1664
  console.log("");
1556
- const oldSkillPath = join3(homedir(), ".claude", "commands", "spets.md");
1557
- const newSkillPath = join3(homedir(), ".claude", "commands", "sdd-do.md");
1558
- const claudeInstalled = existsSync3(oldSkillPath) || existsSync3(newSkillPath);
1665
+ const skillPath = join3(homedir(), ".claude", "commands", "spets.md");
1666
+ const legacySkillPath = join3(homedir(), ".claude", "commands", "sdd-do.md");
1667
+ const claudeInstalled = existsSync3(skillPath) || existsSync3(legacySkillPath);
1559
1668
  console.log("Installed:");
1560
1669
  if (claudeInstalled) {
1561
1670
  console.log(" - claude");
@@ -1564,7 +1673,7 @@ async function listPlugins() {
1564
1673
  }
1565
1674
  }
1566
1675
  function getClaudeSkillContent() {
1567
- return `# SDD-Do Skill
1676
+ return `# Spets - Spec Driven Development
1568
1677
 
1569
1678
  Spec-Driven Development workflow execution skill for Claude Code.
1570
1679
 
@@ -1573,7 +1682,7 @@ Spec-Driven Development workflow execution skill for Claude Code.
1573
1682
  ## When to Use This Skill
1574
1683
 
1575
1684
  Automatically invoked when user uses:
1576
- - \`/sdd-do\` - Run SDD workflow
1685
+ - \`/spets\` - Run Spets workflow
1577
1686
 
1578
1687
  ---
1579
1688
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spets",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Spec Driven Development Execution Framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -8,7 +8,8 @@
8
8
  "spets": "./dist/index.js"
9
9
  },
10
10
  "files": [
11
- "dist"
11
+ "dist",
12
+ "templates"
12
13
  ],
13
14
  "scripts": {
14
15
  "dev": "tsx src/index.ts",
@@ -0,0 +1,327 @@
1
+ # Plan Step
2
+
3
+ You are creating a technical implementation plan for the given task. This is a **read-only exploration phase** - do not modify any files except the plan document itself.
4
+
5
+ ## Your Goal
6
+
7
+ Thoroughly explore the codebase, understand existing patterns, and create a detailed, actionable implementation plan that can be executed with confidence by someone with zero context about the codebase.
8
+
9
+ ## Planning Principles
10
+
11
+ ### Systematic Over Ad-Hoc
12
+ - Be methodical and thorough in exploration
13
+ - Document your findings with evidence (file:line references)
14
+ - Create repeatable patterns
15
+
16
+ ### Test-Driven Development
17
+ - Plan tests BEFORE implementation
18
+ - Every task must have concrete verification criteria
19
+ - Follow existing testing patterns exactly
20
+
21
+ ### Complexity Reduction (YAGNI)
22
+ - Keep tasks small and focused (2-5 minutes each)
23
+ - Avoid premature abstraction
24
+ - Only add what's explicitly needed
25
+ - Ruthlessly remove unnecessary features
26
+
27
+ ### Evidence Over Assumptions
28
+ - Base ALL decisions on actual codebase patterns
29
+ - Quote specific files and lines when referencing patterns
30
+ - NEVER assume - always verify by reading code
31
+
32
+ ## Process
33
+
34
+ ### 1. Understand the Request (2-3 minutes / 5%)
35
+
36
+ **Identify:**
37
+ - Core requirements and constraints
38
+ - Whether this is a new feature, bug fix, refactor, or enhancement
39
+ - Scope and boundaries of the change
40
+ - Success criteria
41
+
42
+ **Detect Intent:**
43
+ - Trivial/Simple: Fast turnaround needed
44
+ - Refactoring: Safety and behavior preservation critical
45
+ - Build from Scratch: Need to discover patterns first
46
+ - Architecture: Long-term impact requires careful consideration
47
+
48
+ **If requirements are unclear:**
49
+ - List specific questions in the YAML frontmatter `open_questions` section
50
+ - Questions should be actionable (not "Should I do X?", but "Which approach: A or B?")
51
+ - Present 2-3 approaches with trade-offs, lead with recommended option
52
+
53
+ **Clearance Check (Run Before Moving to Phase 2):**
54
+ - [ ] Core objective clearly defined?
55
+ - [ ] Scope boundaries established (what's IN, what's OUT)?
56
+ - [ ] No critical ambiguities blocking design?
57
+ - [ ] Technical constraints identified?
58
+
59
+ **If ANY checkbox is unchecked:** List questions in frontmatter and wait for user response.
60
+ **If ALL checked:** Proceed to exploration.
61
+
62
+ ### 2. Explore the Codebase (10-20 minutes / 50%)
63
+
64
+ **CRITICAL: This is the MOST IMPORTANT phase. Spend 50% of planning time here.**
65
+
66
+ **Before exploring, launch background research if needed:**
67
+ - For architecture decisions: Research best practices, existing implementations
68
+ - For new patterns: Find similar implementations in the codebase first
69
+
70
+ **Systematic Exploration Process:**
71
+
72
+ #### A. Find Relevant Files (Use Glob)
73
+ ```bash
74
+ # Examples:
75
+ - Auth-related: **/*auth*.ts, **/*login*.ts
76
+ - Tests: **/*.test.ts, **/*.spec.ts
77
+ - Config: **/*config*.ts, **/config/**
78
+ - Components: src/components/**/*.tsx
79
+ ```
80
+
81
+ #### B. Search for Patterns (Use Grep)
82
+ ```bash
83
+ # Examples:
84
+ - How are API endpoints structured?
85
+ - How are errors handled?
86
+ - How are configs loaded?
87
+ - What testing patterns exist?
88
+ - How are similar features implemented?
89
+ ```
90
+
91
+ #### C. Read Key Files
92
+ - Files that will be modified
93
+ - Similar implementations to use as examples
94
+ - Type definitions and interfaces
95
+ - Test files to understand testing patterns
96
+
97
+ #### D. Document Findings with Evidence
98
+
99
+ **Pattern References (existing code to follow):**
100
+ - `src/services/auth.ts:45-78` - Authentication flow pattern (JWT creation, refresh handling)
101
+ - WHY this matters: Shows how to structure token generation
102
+
103
+ **API/Type References (contracts to implement):**
104
+ - `src/types/user.ts:UserDTO` - Response shape for user endpoints
105
+ - WHY this matters: Ensures type consistency
106
+
107
+ **Test References (testing patterns):**
108
+ - `src/__tests__/auth.test.ts:describe("login")` - Test structure and mocking patterns
109
+ - WHY this matters: Follow same test organization
110
+
111
+ **DON'T just list files - explain WHAT PATTERN to extract and WHY it matters.**
112
+
113
+ **Exploration Checklist (ALL must be checked):**
114
+ - [ ] Found all files that need modification (with exact paths)
115
+ - [ ] Identified similar existing features with file:line references
116
+ - [ ] Understood testing approach (library, location, patterns with examples)
117
+ - [ ] Reviewed type definitions and interfaces (list relevant ones)
118
+ - [ ] Identified integration points and dependencies
119
+ - [ ] Understood error handling patterns (with example reference)
120
+ - [ ] Noted existing utilities to reuse (with references)
121
+ - [ ] Checked for existing TODO/FIXME comments in related code
122
+
123
+ ### 3. Design the Approach (5-10 minutes / 15%)
124
+
125
+ **Consider Multiple Approaches:**
126
+ Present 2-3 approaches if applicable:
127
+
128
+ **Approach 1: [Name]** (Recommended)
129
+ - Description: [How it works]
130
+ - Pros: [Advantages]
131
+ - Cons: [Disadvantages]
132
+ - Why recommended: [Reasoning with evidence from codebase]
133
+
134
+ **Approach 2: [Name]**
135
+ - Description: [How it works]
136
+ - Pros: [Advantages]
137
+ - Cons: [Disadvantages]
138
+ - Why not chosen: [Reasoning]
139
+
140
+ **Architectural Principles:**
141
+ - Follow existing patterns in the codebase (quote specific examples)
142
+ - Avoid over-engineering - only add what's necessary (YAGNI)
143
+ - Prefer simple solutions over complex abstractions
144
+ - Don't create new patterns unless existing ones don't fit
145
+ - Reuse existing utilities and helpers
146
+
147
+ **Test Strategy Decision (MUST decide now):**
148
+ - [ ] TDD (tests first, red-green-refactor) ← Preferred for new functionality
149
+ - [ ] Tests after implementation ← Only if TDD not practical
150
+ - [ ] Manual QA only ← Only if no test infrastructure exists
151
+
152
+ This decision affects ALL task acceptance criteria.
153
+
154
+ ### 4. Break Down Into Tasks (5-10 minutes / 20%)
155
+
156
+ **CRITICAL RULES:**
157
+ - Each task: 2-5 minutes MAXIMUM
158
+ - One discrete action per task
159
+ - Frequent commits after each task
160
+ - Zero-context assumption: Write as if implementer knows nothing
161
+
162
+ **Task Structure (MANDATORY):**
163
+
164
+ ```markdown
165
+ #### Task N: [Verb] [What] in [Specific File]
166
+
167
+ **File:** `src/exact/path/file.ts`
168
+
169
+ **Changes:**
170
+ - Add/Modify: [Specific function, interface, or logic]
171
+ - Code location: [Function name or line reference]
172
+ - Code sample: [If helpful, show expected structure]
173
+
174
+ **Steps:**
175
+ 1. [Granular step 1 with exact details]
176
+ 2. [Granular step 2 with exact details]
177
+ 3. [Granular step 3 with exact details]
178
+
179
+ **Verification:**
180
+ - [ ] Run: `[exact command]`
181
+ - [ ] Expected: [Specific expected output]
182
+ - [ ] Verify: [Specific outcome to check]
183
+
184
+ **Dependencies:** [None / Requires Task X to be completed first]
185
+
186
+ **Parallelizable:** [YES (with Task Y, Z) / NO]
187
+
188
+ **Commit:** `[Descriptive commit message]`
189
+ ```
190
+
191
+ **Good Task Examples:**
192
+ - "Add `GitHubConfig` interface to `src/core/types.ts` with owner/repo/token fields"
193
+ - "Create `getGitHubConfig()` helper in `src/core/config.ts` to read from env vars"
194
+ - "Write unit test for `getGitHubConfig()` in `src/core/config.test.ts`"
195
+
196
+ **Bad Task Examples:**
197
+ - "Implement the feature" (too vague)
198
+ - "Update all files" (too broad, no verification)
199
+ - "Add auth and tests" (multiple discrete actions)
200
+ - "Make it work" (no verification criteria)
201
+
202
+ **Phase Organization:**
203
+ Group tasks into logical phases:
204
+ - Phase 1: Shared infrastructure / type definitions
205
+ - Phase 2: Core implementation
206
+ - Phase 3: Tests
207
+ - Phase 4: Integration
208
+ - Phase 5: Documentation and final verification
209
+
210
+ ### 5. Plan Testing & Verification (3-5 minutes / 10%)
211
+
212
+ **For EVERY task, specify verification:**
213
+
214
+ **Verification Pattern:**
215
+ ```markdown
216
+ **Verification:**
217
+ - [ ] Command: `npm test src/path/test.ts`
218
+ - [ ] Expected: All tests pass (not "should work")
219
+ - [ ] Check: No console errors
220
+ - [ ] Evidence: [How to prove it works]
221
+ ```
222
+
223
+ **Testing Strategy:**
224
+
225
+ **Unit Tests:**
226
+ - Test file: `src/**/*.test.ts` (follow existing naming)
227
+ - Testing library: [Jest/Vitest based on existing patterns]
228
+ - Test cases:
229
+ - [ ] Happy path: [Specific case]
230
+ - [ ] Edge case 1: [Specific case]
231
+ - [ ] Edge case 2: [Specific case]
232
+ - [ ] Error case 1: [Specific case]
233
+
234
+ **Integration Tests:**
235
+ - [ ] [Specific integration test 1]
236
+ - [ ] [Specific integration test 2]
237
+
238
+ **Manual Verification:**
239
+ - [ ] [Specific manual check 1]
240
+ - [ ] [Specific manual check 2]
241
+
242
+ **Anti-Patterns to Avoid:**
243
+ - ❌ Testing mock behavior instead of actual functionality
244
+ - ❌ Adding test-only methods to production code
245
+ - ❌ Mocking without understanding dependencies
246
+ - ❌ Partial mock responses with only known fields
247
+ - ❌ Treating tests as optional
248
+
249
+ ## Anti-Patterns to Avoid
250
+
251
+ ❌ **Don't plan without exploring** - Never create a plan based on assumptions
252
+ ❌ **Don't over-engineer** - Don't add features, abstractions, or "improvements" not requested
253
+ ❌ **Don't ignore existing patterns** - Always follow established conventions
254
+ ❌ **Don't create large tasks** - Break work into 2-5 minute chunks with verification
255
+ ❌ **Don't skip test planning** - Every task needs concrete verification criteria with exact commands
256
+ ❌ **Don't guess file paths** - Use Glob/Grep to find actual files
257
+ ❌ **Don't split into multiple plans** - One plan for entire feature (can have 50+ tasks)
258
+ ❌ **Don't list files without context** - Explain WHAT pattern and WHY it matters
259
+
260
+ ## Pre-Finalization Review (Metis Check)
261
+
262
+ Before finalizing your plan, ask yourself:
263
+
264
+ **Questions Not Asked:**
265
+ - What questions should I have asked but didn't?
266
+ - What user intentions might not be explicitly stated?
267
+ - What ambiguities could derail implementation?
268
+
269
+ **Scope Creep Check:**
270
+ - Am I adding "nice-to-have" features not requested?
271
+ - Am I over-engineering the solution?
272
+ - Are all planned tasks essential?
273
+
274
+ **Completeness Check:**
275
+ - Do ALL tasks have concrete acceptance criteria?
276
+ - Are ≥80% of tasks backed by specific file:line references?
277
+ - Do I have zero assumptions about business logic?
278
+ - Are all edge cases addressed?
279
+
280
+ **If ANY concerns found:** Revise plan before finalizing.
281
+
282
+ ## Output Format
283
+
284
+ Follow the template provided. Your plan should include:
285
+
286
+ 1. **Summary**: 2-3 sentences describing what will be built
287
+ 2. **Codebase Analysis**:
288
+ - Current State: What exists now (with file:line references)
289
+ - Key Findings: Important discoveries from exploration
290
+ 3. **Architecture Decisions**:
291
+ - Chosen Approach with justification
292
+ - Alternatives Considered and why not chosen
293
+ - Pattern References (file:line with WHY each matters)
294
+ 4. **Task Breakdown**:
295
+ - Grouped by phases
296
+ - Each task 2-5 minutes with complete details
297
+ - Verification criteria with exact commands
298
+ - Dependencies and parallelization marked
299
+ 5. **Testing Strategy**:
300
+ - Unit tests (specific test cases)
301
+ - Integration tests
302
+ - Manual verification checklist
303
+ 6. **Acceptance Criteria**: Concrete, verifiable checklist
304
+ 7. **Risks & Considerations**: Edge cases, dependencies, gotchas
305
+ 8. **Implementation Notes**: Code patterns, gotchas, performance considerations
306
+
307
+ ## Time Allocation
308
+
309
+ - Understanding request: 5%
310
+ - **Codebase exploration: 50%** ← This is the most critical phase
311
+ - Approach design: 15%
312
+ - Task breakdown: 20%
313
+ - Testing planning: 10%
314
+
315
+ ## Success Criteria for Your Plan
316
+
317
+ A great plan has:
318
+ - ✅ ALL tasks are 2-5 minutes with exact file paths
319
+ - ✅ ≥80% of tasks reference specific existing code patterns
320
+ - ✅ EVERY task has concrete verification (command + expected output)
321
+ - ✅ Zero assumptions about business logic or patterns
322
+ - ✅ Test strategy decided (TDD / after / manual QA)
323
+ - ✅ Phase-based organization with dependencies marked
324
+ - ✅ Parallelization opportunities identified
325
+ - ✅ One complete plan (not "Phase 1, we'll plan Phase 2 later")
326
+
327
+ **Remember: A great plan is based on deep codebase understanding, not assumptions. The implementer should be able to execute it without any codebase knowledge.**