pan-wizard 2.8.1
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/LICENSE +21 -0
- package/README.md +772 -0
- package/agents/pan-debugger.md +1246 -0
- package/agents/pan-document_code.md +965 -0
- package/agents/pan-executor.md +469 -0
- package/agents/pan-integration-checker.md +443 -0
- package/agents/pan-phase-researcher.md +572 -0
- package/agents/pan-plan-checker.md +763 -0
- package/agents/pan-planner.md +1297 -0
- package/agents/pan-project-researcher.md +647 -0
- package/agents/pan-research-synthesizer.md +239 -0
- package/agents/pan-reviewer.md +112 -0
- package/agents/pan-roadmapper.md +642 -0
- package/agents/pan-verifier.md +672 -0
- package/assets/pan-logo-2000-transparent.svg +30 -0
- package/assets/pan-logo-2000.svg +43 -0
- package/assets/terminal.svg +119 -0
- package/bin/install-lib.cjs +616 -0
- package/bin/install.js +1936 -0
- package/commands/pan/add-phase.md +44 -0
- package/commands/pan/assumptions.md +47 -0
- package/commands/pan/audit-deployment.md +378 -0
- package/commands/pan/debug.md +168 -0
- package/commands/pan/discord.md +19 -0
- package/commands/pan/discuss-phase.md +84 -0
- package/commands/pan/exec-phase.md +45 -0
- package/commands/pan/focus-auto.md +323 -0
- package/commands/pan/focus-design.md +816 -0
- package/commands/pan/focus-exec.md +316 -0
- package/commands/pan/focus-plan.md +101 -0
- package/commands/pan/focus-scan.md +272 -0
- package/commands/pan/focus-sync.md +104 -0
- package/commands/pan/health.md +23 -0
- package/commands/pan/help.md +23 -0
- package/commands/pan/insert-phase.md +33 -0
- package/commands/pan/map-codebase.md +72 -0
- package/commands/pan/milestone-audit.md +37 -0
- package/commands/pan/milestone-cleanup.md +19 -0
- package/commands/pan/milestone-done.md +137 -0
- package/commands/pan/milestone-gaps.md +35 -0
- package/commands/pan/milestone-new.md +45 -0
- package/commands/pan/new-project.md +43 -0
- package/commands/pan/patches.md +110 -0
- package/commands/pan/pause.md +39 -0
- package/commands/pan/phase-budget.md +23 -0
- package/commands/pan/phase-tests.md +42 -0
- package/commands/pan/plan-phase.md +46 -0
- package/commands/pan/profile.md +36 -0
- package/commands/pan/progress.md +25 -0
- package/commands/pan/quick.md +42 -0
- package/commands/pan/remove-phase.md +32 -0
- package/commands/pan/research-phase.md +190 -0
- package/commands/pan/resume.md +41 -0
- package/commands/pan/retro.md +33 -0
- package/commands/pan/settings.md +37 -0
- package/commands/pan/todo-add.md +48 -0
- package/commands/pan/todo-check.md +46 -0
- package/commands/pan/update.md +38 -0
- package/commands/pan/verify-phase.md +39 -0
- package/hooks/dist/pan-check-update.js +62 -0
- package/hooks/dist/pan-context-monitor.js +122 -0
- package/hooks/dist/pan-statusline.js +108 -0
- package/package.json +66 -0
- package/pan-wizard-core/bin/lib/codebase.cjs +746 -0
- package/pan-wizard-core/bin/lib/commands.cjs +1435 -0
- package/pan-wizard-core/bin/lib/config.cjs +611 -0
- package/pan-wizard-core/bin/lib/constants.cjs +696 -0
- package/pan-wizard-core/bin/lib/context-budget.cjs +150 -0
- package/pan-wizard-core/bin/lib/core.cjs +650 -0
- package/pan-wizard-core/bin/lib/focus.cjs +900 -0
- package/pan-wizard-core/bin/lib/frontmatter.cjs +442 -0
- package/pan-wizard-core/bin/lib/init.cjs +881 -0
- package/pan-wizard-core/bin/lib/milestone.cjs +276 -0
- package/pan-wizard-core/bin/lib/phase.cjs +1212 -0
- package/pan-wizard-core/bin/lib/roadmap.cjs +470 -0
- package/pan-wizard-core/bin/lib/state.cjs +1029 -0
- package/pan-wizard-core/bin/lib/template.cjs +314 -0
- package/pan-wizard-core/bin/lib/utils.cjs +171 -0
- package/pan-wizard-core/bin/lib/verify.cjs +1808 -0
- package/pan-wizard-core/bin/pan-tools.cjs +773 -0
- package/pan-wizard-core/references/checkpoints.md +776 -0
- package/pan-wizard-core/references/continuation-format.md +249 -0
- package/pan-wizard-core/references/decimal-phase-calculation.md +65 -0
- package/pan-wizard-core/references/git-integration.md +248 -0
- package/pan-wizard-core/references/git-planning-commit.md +38 -0
- package/pan-wizard-core/references/model-profile-resolution.md +34 -0
- package/pan-wizard-core/references/model-profiles.md +111 -0
- package/pan-wizard-core/references/phase-argument-parsing.md +61 -0
- package/pan-wizard-core/references/planning-config.md +196 -0
- package/pan-wizard-core/references/questioning.md +145 -0
- package/pan-wizard-core/references/tdd.md +263 -0
- package/pan-wizard-core/references/ui-brand.md +160 -0
- package/pan-wizard-core/references/verification-patterns.md +612 -0
- package/pan-wizard-core/templates/codebase/architecture.md +283 -0
- package/pan-wizard-core/templates/codebase/best-practices.md +133 -0
- package/pan-wizard-core/templates/codebase/concerns.md +325 -0
- package/pan-wizard-core/templates/codebase/conventions.md +307 -0
- package/pan-wizard-core/templates/codebase/integrations.md +305 -0
- package/pan-wizard-core/templates/codebase/relationships.md +124 -0
- package/pan-wizard-core/templates/codebase/stack.md +199 -0
- package/pan-wizard-core/templates/codebase/structure.md +298 -0
- package/pan-wizard-core/templates/codebase/testing.md +480 -0
- package/pan-wizard-core/templates/config.json +37 -0
- package/pan-wizard-core/templates/context.md +283 -0
- package/pan-wizard-core/templates/continue-here.md +78 -0
- package/pan-wizard-core/templates/debug-subagent-prompt.md +91 -0
- package/pan-wizard-core/templates/debug.md +164 -0
- package/pan-wizard-core/templates/discovery.md +146 -0
- package/pan-wizard-core/templates/milestone-archive.md +123 -0
- package/pan-wizard-core/templates/milestone.md +115 -0
- package/pan-wizard-core/templates/phase-prompt.md +593 -0
- package/pan-wizard-core/templates/planner-subagent-prompt.md +117 -0
- package/pan-wizard-core/templates/project.md +184 -0
- package/pan-wizard-core/templates/requirements.md +231 -0
- package/pan-wizard-core/templates/research-project/architecture.md +204 -0
- package/pan-wizard-core/templates/research-project/features.md +147 -0
- package/pan-wizard-core/templates/research-project/pitfalls.md +200 -0
- package/pan-wizard-core/templates/research-project/stack.md +120 -0
- package/pan-wizard-core/templates/research-project/summary.md +170 -0
- package/pan-wizard-core/templates/research.md +552 -0
- package/pan-wizard-core/templates/retrospective.md +54 -0
- package/pan-wizard-core/templates/roadmap.md +202 -0
- package/pan-wizard-core/templates/standards.md +24 -0
- package/pan-wizard-core/templates/state.md +176 -0
- package/pan-wizard-core/templates/summary-complex.md +59 -0
- package/pan-wizard-core/templates/summary-minimal.md +41 -0
- package/pan-wizard-core/templates/summary-standard.md +49 -0
- package/pan-wizard-core/templates/summary.md +249 -0
- package/pan-wizard-core/templates/uat.md +247 -0
- package/pan-wizard-core/templates/user-setup.md +311 -0
- package/pan-wizard-core/templates/validation.md +76 -0
- package/pan-wizard-core/templates/verification-report.md +322 -0
- package/pan-wizard-core/workflows/add-phase.md +111 -0
- package/pan-wizard-core/workflows/assumptions.md +178 -0
- package/pan-wizard-core/workflows/diagnose-issues.md +219 -0
- package/pan-wizard-core/workflows/discuss-phase.md +542 -0
- package/pan-wizard-core/workflows/exec-phase.md +572 -0
- package/pan-wizard-core/workflows/execute-plan.md +448 -0
- package/pan-wizard-core/workflows/health.md +156 -0
- package/pan-wizard-core/workflows/help.md +431 -0
- package/pan-wizard-core/workflows/insert-phase.md +129 -0
- package/pan-wizard-core/workflows/map-codebase.md +401 -0
- package/pan-wizard-core/workflows/milestone-audit.md +297 -0
- package/pan-wizard-core/workflows/milestone-cleanup.md +152 -0
- package/pan-wizard-core/workflows/milestone-gaps.md +274 -0
- package/pan-wizard-core/workflows/milestone-new.md +382 -0
- package/pan-wizard-core/workflows/new-project.md +1178 -0
- package/pan-wizard-core/workflows/pause.md +122 -0
- package/pan-wizard-core/workflows/phase-tests.md +388 -0
- package/pan-wizard-core/workflows/plan-phase.md +569 -0
- package/pan-wizard-core/workflows/profile.md +115 -0
- package/pan-wizard-core/workflows/progress.md +381 -0
- package/pan-wizard-core/workflows/quick.md +453 -0
- package/pan-wizard-core/workflows/remove-phase.md +154 -0
- package/pan-wizard-core/workflows/research-phase.md +73 -0
- package/pan-wizard-core/workflows/resume-project.md +306 -0
- package/pan-wizard-core/workflows/retro.md +121 -0
- package/pan-wizard-core/workflows/settings.md +213 -0
- package/pan-wizard-core/workflows/todo-add.md +157 -0
- package/pan-wizard-core/workflows/todo-check.md +176 -0
- package/pan-wizard-core/workflows/transition.md +544 -0
- package/pan-wizard-core/workflows/update.md +219 -0
- package/pan-wizard-core/workflows/verify-phase.md +301 -0
- package/scripts/build-hooks.js +43 -0
|
@@ -0,0 +1,816 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: focus-design
|
|
3
|
+
group: Focus
|
|
4
|
+
description: Strategic 10-phase feature investigation, design, and specification pipeline
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Edit
|
|
9
|
+
- Bash
|
|
10
|
+
- Grep
|
|
11
|
+
- Glob
|
|
12
|
+
- Agent
|
|
13
|
+
- WebSearch
|
|
14
|
+
- WebFetch
|
|
15
|
+
- mcp__context7__resolve-library-id
|
|
16
|
+
- mcp__context7__get-library-docs
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# /pan:focus-design — Strategic Feature Investigation, Design & Specification
|
|
20
|
+
|
|
21
|
+
Research, design, and specify a new feature with strategic analysis. $ARGUMENTS
|
|
22
|
+
|
|
23
|
+
**Goal:** Produce a best-of-breed feature specification that (a) validates the problem with evidence, (b) maps the competitive landscape, (c) identifies strategic differentiation, (d) designs an architecturally sound implementation, (e) plans for error handling, security, and testability from day one, (f) defines an incremental delivery ladder, and (g) outputs a ready-to-implement spec with ADR, test plan, and implementation tasks.
|
|
24
|
+
|
|
25
|
+
**Methodology:** Synthesizes Spec-Driven Development, Blue Ocean Strategy, Wardley Mapping, STRIDE-lite threat modeling, Architecture Decision Records, and structured workflow methodology into a single investigative pipeline.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## CRITICAL: Project Scope Boundary
|
|
30
|
+
|
|
31
|
+
This command investigates and designs features for the **host project** — NOT for PAN Wizard itself.
|
|
32
|
+
|
|
33
|
+
**NEVER investigate, design for, or reference these PAN infrastructure directories as part of the project:**
|
|
34
|
+
- `.claude/`, `.github/copilot-instructions.md`, `.opencode/`, `.gemini/`, `.codex/` — PAN runtime directories
|
|
35
|
+
- `.planning/` — PAN planning state (read for context, but don't treat as project source code)
|
|
36
|
+
- Any `pan-wizard-core/`, `pan-tools`, agent `.md`, or command `.md` files within those directories
|
|
37
|
+
|
|
38
|
+
**These directories are PAN's own tooling installed into the project.** They are not part of the project's source code, not part of its feature set, and not something to fix, improve, or design features for.
|
|
39
|
+
|
|
40
|
+
If you find yourself analyzing PAN command files, agent definitions, or `pan-tools` dispatcher code as "project code" — STOP. You have crossed the scope boundary. Refocus on the project's actual source code.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## MANDATORY: Complete All Phases For Selected Mode
|
|
45
|
+
|
|
46
|
+
When `/pan:focus-design` is invoked, execute ALL phases for the selected mode automatically. Do NOT stop to ask questions between phases. Do NOT skip phases beyond what the mode specifies. Complete the FULL investigation and produce all output artifacts. The only permitted pause is the Strategy Gate in Phase 3 (if the user passed `--gate`).
|
|
47
|
+
|
|
48
|
+
**Modes (mutually exclusive — pick one, default `--full`):**
|
|
49
|
+
|
|
50
|
+
### `--full` — Complete 10-Phase Investigation (DEFAULT)
|
|
51
|
+
Run ALL phases. Nothing skipped. This is the gold standard.
|
|
52
|
+
```
|
|
53
|
+
Phases: 0 -> 0.8 -> 1 -> 1.5 -> 2 -> 2.5(if --audit) -> 3 -> 3.5 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 10
|
|
54
|
+
Use case: New features, public-facing commands, anything that ships to users
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### `--internal` — Internal Development Focus
|
|
58
|
+
Skip competitive research (Phase 2) and reality check (Phase 2.5). Focus on architecture, implementation, hardening, and testing. For internal tooling where there are no competitors to analyze.
|
|
59
|
+
```
|
|
60
|
+
Phases: 0 -> 0.8 -> 1 -> 3 -> 3.5 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 10
|
|
61
|
+
Skips: Phase 1.5 (Informed Clarification), Phase 2 (Competitive Intelligence), Phase 2.5 (Reality Check)
|
|
62
|
+
Use case: Internal APIs, dev tooling, refactoring, infrastructure work
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### `--outward` — Strategic & Market Analysis Focus
|
|
66
|
+
Emphasize competitive intelligence and strategic positioning. Skip error handling and security hardening (Phases 6, 7) and produce a lighter implementation roadmap. For market research, strategic decisions, and feature evaluation.
|
|
67
|
+
```
|
|
68
|
+
Phases: 0 -> 0.8 -> 1 -> 2 -> 2.5(if --audit) -> 3 -> 3.5 -> 4 -> 5 -> 8(tasks only) -> 10
|
|
69
|
+
Skips: Phase 1.5 (Informed Clarification), Phase 6 (Error Handling), Phase 7 (Security), Phase 9 (Test Plan)
|
|
70
|
+
Lighter: Phase 8 (tasks list only — no dependency graph, no risk register)
|
|
71
|
+
Use case: Evaluating whether to build, competitive positioning, strategic ADRs
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### `--spike` — Fast Proof-of-Concept
|
|
75
|
+
Minimal 4-phase pass: validate the problem, scan the codebase, synthesize a design, output implementation tasks. No competitive research, no strategic analysis, no hardening.
|
|
76
|
+
```
|
|
77
|
+
Phases: 0(lite) -> 1(lite) -> 4 -> 8
|
|
78
|
+
Lite Phase 0: Problem statement + scope only (skip demand evidence, user stories, cannibalization)
|
|
79
|
+
Lite Phase 1: Codebase search + conventions only (skip architecture scan, dependency map)
|
|
80
|
+
Skips: Phases 0.8, 1.5, 2, 2.5, 3, 3.5, 5, 6, 7, 9, 10(spec saved, no ADR)
|
|
81
|
+
Use case: Quick prototyping, time-boxed exploration, "should we even try this?"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Modifiers (layer on top of any mode):**
|
|
85
|
+
- `--gate` — Pause after Phase 3 (Strategy) for user review before proceeding to design
|
|
86
|
+
- `--audit` — Add Phase 2.5 reality check of existing implementation (not available with `--spike`)
|
|
87
|
+
- `--mvp` — Stop after generating the v0 (MVP) task list — skip v1/v2 layers
|
|
88
|
+
|
|
89
|
+
### Scope Calibration (Auto-Detection)
|
|
90
|
+
If the user doesn't specify a mode, assess scope before starting:
|
|
91
|
+
|
|
92
|
+
| Signal | Suggested Mode | Rationale |
|
|
93
|
+
|--------|---------------|-----------|
|
|
94
|
+
| Bug fix or single-function change | `--spike` | Minimal investigation needed |
|
|
95
|
+
| New internal module, service, or utility | `--internal` | No competitive research needed |
|
|
96
|
+
| New API endpoint, component, or contained feature | `--internal` | Architecture-focused |
|
|
97
|
+
| User-facing feature with competitive alternatives | `--full` | Need competitive intelligence |
|
|
98
|
+
| "Should we build X?" strategic question | `--outward` | Focus on market analysis |
|
|
99
|
+
| Enhancement to existing feature (small blast radius) | `--internal` | Architecture-focused |
|
|
100
|
+
| Enhancement to existing feature (large blast radius) | `--full` | Full investigation warranted |
|
|
101
|
+
|
|
102
|
+
Present the suggested mode and rationale. If the user hasn't specified, use the suggestion.
|
|
103
|
+
|
|
104
|
+
**Mode + Phase Matrix:**
|
|
105
|
+
|
|
106
|
+
| Phase | `--full` | `--internal` | `--outward` | `--spike` |
|
|
107
|
+
|-------|----------|-------------|-------------|-----------|
|
|
108
|
+
| 0: Problem Framing | Full | Full | Full | Lite (statement + scope only) |
|
|
109
|
+
| 0.8: Codebase Investigation | Full | Full | Full | **SKIP** |
|
|
110
|
+
| 1: Internal Recon | Full | Full | Full | Lite (codebase + conventions only) |
|
|
111
|
+
| 1.5: Informed Clarification | Full | **SKIP** | **SKIP** | **SKIP** |
|
|
112
|
+
| 2: Competitive Intel | Full | **SKIP** | Full | **SKIP** |
|
|
113
|
+
| 2.5: Reality Check | With --audit | **SKIP** | With --audit | **SKIP** |
|
|
114
|
+
| 3: Strategic Analysis | Full | Full | Full | **SKIP** |
|
|
115
|
+
| 3.5: Architecture | Full | Full | Full | **SKIP** |
|
|
116
|
+
| 4: Design Synthesis | Full | Full | Full | Full |
|
|
117
|
+
| 5: ADR | Full | Full | Full | **SKIP** |
|
|
118
|
+
| 6: Error Handling | Full | Full | **SKIP** | **SKIP** |
|
|
119
|
+
| 7: Security | Full | Full | **SKIP** | **SKIP** |
|
|
120
|
+
| 8: Implementation | Full | Full | Tasks only | Full |
|
|
121
|
+
| 9: Test Plan | Full | Full | **SKIP** | **SKIP** |
|
|
122
|
+
| 10: Output Artifacts | Full | Full | Spec + ADR | Spec only |
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Phase 0: Problem Framing & Demand Validation
|
|
127
|
+
|
|
128
|
+
> *Before designing anything, prove the problem exists and users care.*
|
|
129
|
+
|
|
130
|
+
### 0.1 Problem Statement
|
|
131
|
+
Write a crisp, one-paragraph problem statement answering:
|
|
132
|
+
- What user pain or limitation does this address?
|
|
133
|
+
- Why does it matter NOW for the target users (developers using AI coding assistants)?
|
|
134
|
+
- What is the cost of NOT doing this?
|
|
135
|
+
|
|
136
|
+
### 0.2 Demand Evidence (MANDATORY)
|
|
137
|
+
Gather at least 2 evidence signals that real users want this:
|
|
138
|
+
|
|
139
|
+
| Evidence Type | Source | Finding |
|
|
140
|
+
|--------------|--------|---------|
|
|
141
|
+
| GitHub issue / feature request | repo issues | [link or "none found"] |
|
|
142
|
+
| Discord / community request | community channels | [quote or "none found"] |
|
|
143
|
+
| Competitor feature parity | [tool name] ships this | [description] |
|
|
144
|
+
| Personal pain (user-stated) | This conversation | [user's words] |
|
|
145
|
+
|
|
146
|
+
**If zero evidence found:** Flag this as speculative. The strategic recommendation in Phase 3.4 must justify building without demand evidence.
|
|
147
|
+
|
|
148
|
+
### 0.2.5 Before/After State (for feature enhancements)
|
|
149
|
+
If enhancing an existing feature (not greenfield), document explicitly:
|
|
150
|
+
|
|
151
|
+
**Current behavior (before):**
|
|
152
|
+
- [What the feature does now — be specific, reference actual output or UX]
|
|
153
|
+
|
|
154
|
+
**Desired behavior (after):**
|
|
155
|
+
- [What the feature should do — concrete, testable differences]
|
|
156
|
+
|
|
157
|
+
**Delta:**
|
|
158
|
+
- [What changes between before and after — this becomes the scope]
|
|
159
|
+
|
|
160
|
+
Skip this section for entirely new features with no predecessor.
|
|
161
|
+
|
|
162
|
+
### 0.3 Scope Definition
|
|
163
|
+
| In Scope | Out of Scope (and why) |
|
|
164
|
+
|----------|------------------------|
|
|
165
|
+
| ... | ... |
|
|
166
|
+
|
|
167
|
+
### 0.4 Success Criteria (Machine-Checkable)
|
|
168
|
+
Define 3-5 concrete, testable success criteria in structured format:
|
|
169
|
+
|
|
170
|
+
| ID | Criterion | Verification Method | Pass Condition |
|
|
171
|
+
|----|-----------|-------------------|----------------|
|
|
172
|
+
| SC-1 | [description] | test / grep / manual | [exact condition] |
|
|
173
|
+
| SC-2 | [description] | test / grep / manual | [exact condition] |
|
|
174
|
+
| SC-3 | No regression in existing tests | project test command | All tests pass, count >= baseline |
|
|
175
|
+
| SC-4 | Cross-platform compatibility (if applicable) | platform test | No platform-specific failures |
|
|
176
|
+
| SC-5 | [description] | test / grep / manual | [exact condition] |
|
|
177
|
+
|
|
178
|
+
At least 2 criteria must be verifiable by automated tests (not manual inspection only).
|
|
179
|
+
|
|
180
|
+
### 0.5 User Stories (3 minimum)
|
|
181
|
+
```
|
|
182
|
+
As a [target user persona discovered from project context], I want [feature],
|
|
183
|
+
so that [benefit], instead of [current workaround].
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### 0.6 Cannibalization Check
|
|
187
|
+
Check ALL existing commands and agents for overlap:
|
|
188
|
+
|
|
189
|
+
| Existing Command/Agent | Overlap? | Impact |
|
|
190
|
+
|-----------------------|----------|--------|
|
|
191
|
+
| [closest match 1] | None / Partial / Full | [migration path if partial/full] |
|
|
192
|
+
| [closest match 2] | None / Partial / Full | [migration path if partial/full] |
|
|
193
|
+
| [closest match 3] | None / Partial / Full | [migration path if partial/full] |
|
|
194
|
+
|
|
195
|
+
**If Full overlap found:** STOP — enhance the existing command instead of creating a new one.
|
|
196
|
+
|
|
197
|
+
### 0.7 Cognitive Load Assessment
|
|
198
|
+
| Metric | Before | After | Delta |
|
|
199
|
+
|--------|--------|-------|-------|
|
|
200
|
+
| Commands a new user must learn | N | ? | +N |
|
|
201
|
+
| New concepts introduced | 0 | ? | +N |
|
|
202
|
+
| Score | — | — | simplifies (-1) / neutral (0) / adds complexity (+1) / significant (+2) |
|
|
203
|
+
|
|
204
|
+
**If score = +2:** Must provide explicit justification in Phase 3.4.
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Phase 0.8: Autonomous Codebase Investigation
|
|
209
|
+
|
|
210
|
+
> *Investigate the codebase BEFORE designing anything. Discover, don't assume.*
|
|
211
|
+
|
|
212
|
+
### 0.8.1 Silent Discovery (MANDATORY — skip only in `--spike` mode)
|
|
213
|
+
Before Phase 1's structured reconnaissance, perform autonomous investigation:
|
|
214
|
+
|
|
215
|
+
1. **Dependency scan**: Grep for imports/requires of modules related to the feature area
|
|
216
|
+
2. **Pattern discovery**: Search for similar functionality already implemented — find 2-3 existing implementations of the same type (command, agent, module, hook) and extract their patterns
|
|
217
|
+
3. **Convention extraction**: Read the implementations found above to learn naming, error handling, output format, and testing patterns actually used (not just documented)
|
|
218
|
+
4. **Test pattern discovery**: Read test files for similar features to understand assertion patterns, helper usage, and test structure conventions
|
|
219
|
+
5. **Integration points**: Identify which existing modules, commands, and agents this feature will touch or depend on
|
|
220
|
+
|
|
221
|
+
Record all findings as structured notes — these ground every subsequent phase.
|
|
222
|
+
|
|
223
|
+
### 0.8.2 Impact Analysis (MANDATORY — skip only in `--spike` mode)
|
|
224
|
+
Before any design work, surface the blast radius:
|
|
225
|
+
|
|
226
|
+
| Affected Area | Specific Item | How Affected | Risk Level |
|
|
227
|
+
|--------------|---------------|-------------|------------|
|
|
228
|
+
| Core module | [discover from 0.8.1] | New function added / existing modified | Low / Medium / High |
|
|
229
|
+
| Entry point / router | [discover from 0.8.1] | New routing or dispatch | Low / Medium |
|
|
230
|
+
| Interface / API | [discover from 0.8.1] | New or updated | Low / Medium |
|
|
231
|
+
| Configuration | [discover from 0.8.1] | New settings or schema changes | Low / Medium |
|
|
232
|
+
| Test file | [discover from 0.8.1] | New tests needed / existing updated | Low / Medium |
|
|
233
|
+
| Build / deploy | [discover from 0.8.1] | Updated if new artifacts | Medium |
|
|
234
|
+
| Documentation | [discover from 0.8.1] | Updated counts, references | Low |
|
|
235
|
+
|
|
236
|
+
If the impact table has 0 "High" entries: proceed with confidence.
|
|
237
|
+
If 1+ "High" entries: flag for extra design scrutiny in Phase 3.5.
|
|
238
|
+
|
|
239
|
+
### 0.8.3 Informed Context
|
|
240
|
+
Use discoveries from 0.8.1 and 0.8.2 to improve ALL subsequent phases:
|
|
241
|
+
- Phase 1 reconnaissance should focus on GAPS the investigation revealed, not re-read what was already found
|
|
242
|
+
- Phase 1.5 clarification questions should reference actual discovered patterns
|
|
243
|
+
- Phase 3 strategic analysis should assess discovered patterns, not assumed ones
|
|
244
|
+
- Phase 4 design should follow conventions extracted from real implementations
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Phase 1: Internal Reconnaissance
|
|
249
|
+
|
|
250
|
+
**Understand what the project already has before looking outward.**
|
|
251
|
+
|
|
252
|
+
### 1.1 Architecture Scan
|
|
253
|
+
Read and extract relevant context from:
|
|
254
|
+
- `README.md` — Public documentation and architecture
|
|
255
|
+
- User guide — User workflows
|
|
256
|
+
- Architecture docs — System design
|
|
257
|
+
- Project conventions — Known patterns and stability work
|
|
258
|
+
|
|
259
|
+
Create an **existing capabilities inventory:**
|
|
260
|
+
```
|
|
261
|
+
| Capability | Status | Location | Relevance |
|
|
262
|
+
|------------|--------|----------|-----------|
|
|
263
|
+
| ... | ... | ... | ... |
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### 1.2 Codebase Search
|
|
267
|
+
Discover the project's actual structure from Phase 0.8 findings, then search systematically:
|
|
268
|
+
|
|
269
|
+
| Search Target | Where to Look | What to Extract |
|
|
270
|
+
|---------------|---------------|------------------|
|
|
271
|
+
| Entry points | Main files, routers, dispatchers | Request/command routing, arg parsing |
|
|
272
|
+
| Core logic | Business logic / domain modules | Existing patterns, helpers, shared utilities |
|
|
273
|
+
| API surface | Controllers, handlers, routes, commands | Public interface patterns |
|
|
274
|
+
| Data layer | Models, repositories, schemas, migrations | Data access patterns, ORM usage |
|
|
275
|
+
| Configuration | Config files, env templates, feature flags | Environment handling, feature toggling |
|
|
276
|
+
| Test patterns | Test files + helpers + fixtures | Testing conventions, assertion patterns |
|
|
277
|
+
| Build / deploy | Build scripts, CI config, Dockerfiles | Build pipeline, deployment flow |
|
|
278
|
+
|
|
279
|
+
### 1.3 Convention Enforcement Checklist
|
|
280
|
+
Extract the project's actual conventions from Phase 0.8 discoveries, then verify the feature design conforms. Check each category:
|
|
281
|
+
|
|
282
|
+
**Naming & Structure** (discover from existing code):
|
|
283
|
+
- [ ] Function/method naming follows project convention (e.g., camelCase, snake_case, verb-noun)
|
|
284
|
+
- [ ] File naming follows project convention (e.g., kebab-case, PascalCase, suffixes like .service, .controller)
|
|
285
|
+
- [ ] Module/export patterns match existing code (e.g., default exports, named exports, module.exports)
|
|
286
|
+
|
|
287
|
+
**Error Handling** (discover from existing implementations):
|
|
288
|
+
- [ ] Error reporting follows project pattern (e.g., custom error classes, error codes, Result types)
|
|
289
|
+
- [ ] File/network operations use project's established safety patterns
|
|
290
|
+
- [ ] User-facing errors follow project's messaging conventions
|
|
291
|
+
|
|
292
|
+
**Code Quality** (discover from linter config, CONTRIBUTING.md, or existing code):
|
|
293
|
+
- [ ] Complexity stays within project's established limits (check linter rules or documented standards)
|
|
294
|
+
- [ ] Dependencies align with project policy (check package manager, dependency philosophy)
|
|
295
|
+
- [ ] Language/runtime version matches project requirements
|
|
296
|
+
|
|
297
|
+
**Output & I/O** (discover from existing interfaces):
|
|
298
|
+
- [ ] Output format matches project convention (JSON, structured logging, CLI output format)
|
|
299
|
+
- [ ] Path handling follows project patterns (relative vs absolute, normalization)
|
|
300
|
+
- [ ] Configuration follows project pattern (env vars, config files, CLI flags)
|
|
301
|
+
|
|
302
|
+
### 1.4 Dependency & Integration Map
|
|
303
|
+
```
|
|
304
|
+
[This Feature]
|
|
305
|
+
├── depends on: [existing module A]
|
|
306
|
+
├── depends on: [existing module B]
|
|
307
|
+
├── extends: [existing command C]
|
|
308
|
+
├── conflicts with: [nothing / feature D because...]
|
|
309
|
+
└── enables: [future feature E]
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
**require()/import chain:** Draw the module dependency path. Verify no circular dependencies.
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## Phase 1.5: Informed Clarification (Full Mode Only)
|
|
317
|
+
|
|
318
|
+
> *Ask smart questions grounded in what you discovered, not generic templates.*
|
|
319
|
+
|
|
320
|
+
Based on Phase 0.8 investigation and Phase 1 reconnaissance findings, ask 2-4 INFORMED clarification questions.
|
|
321
|
+
|
|
322
|
+
### Rules
|
|
323
|
+
1. Questions MUST reference specific files, line numbers, or patterns found during investigation (e.g., "I found your auth uses JWT with RS256 in `auth.cjs:47` — should this feature follow the same pattern?")
|
|
324
|
+
2. Surface architectural decisions the investigation revealed that need user input
|
|
325
|
+
3. Clarify ambiguities that code inspection couldn't resolve
|
|
326
|
+
4. Never ask generic questions ("Do you want tests?" — always want tests)
|
|
327
|
+
5. Maximum 4 questions — prefer fewer, more specific ones
|
|
328
|
+
|
|
329
|
+
### When to Skip
|
|
330
|
+
- Skip in `--internal`, `--outward`, and `--spike` modes — make reasonable assumptions based on discovered patterns and note them in the spec
|
|
331
|
+
- Skip in `--full` mode if the investigation made the scope completely unambiguous
|
|
332
|
+
- When skipping, document assumptions made in place of asking
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## Phase 2: Competitive Intelligence
|
|
337
|
+
|
|
338
|
+
**Research how the best AI workflow tools solve this problem.**
|
|
339
|
+
|
|
340
|
+
### 2.1 Deep-Dive Research (6+ Tools)
|
|
341
|
+
Select competitor tools relevant to the FEATURE DOMAIN, not a fixed list. Use web search for each.
|
|
342
|
+
|
|
343
|
+
**Competitor selection guidance:**
|
|
344
|
+
1. Identify the domain of the feature being designed (e.g., CI/CD, testing, API framework, state management, CLI tooling, AI coding)
|
|
345
|
+
2. Search for the top 6-8 tools in that domain
|
|
346
|
+
3. Include at least 2 open-source and 2 commercial options
|
|
347
|
+
4. Include the current market leader and the fastest-growing challenger
|
|
348
|
+
|
|
349
|
+
**For AI coding tool features** (when the project IS an AI coding tool):
|
|
350
|
+
- Research tools like Aider, Cursor, Cline, Windsurf, Continue.dev, GitHub Copilot, Amazon Kiro, and community patterns
|
|
351
|
+
|
|
352
|
+
**For all other domains:** Research the 6+ most relevant tools in the feature's problem space. The competitor set should be determined by what the feature does, not what the project is.
|
|
353
|
+
|
|
354
|
+
For each, extract: **UX** (how invoked), **Behavior** (guarantees), **Ergonomics** (love/hate), **Pitfalls** (known limits), **Evolution** (what they got wrong first).
|
|
355
|
+
|
|
356
|
+
### 2.2 Prior Art & Community Research
|
|
357
|
+
Search for: blog posts from domain experts, Reddit/HN discussions, open issues in competing tools.
|
|
358
|
+
|
|
359
|
+
### 2.3 Competitive Matrix
|
|
360
|
+
```
|
|
361
|
+
| Aspect | This Project | Competitor 1 | Competitor 2 | Competitor 3 | ... | Best |
|
|
362
|
+
|--------|-------------|-------------|-------------|-------------|-----|------|
|
|
363
|
+
| UX | ... | ... | ... | ... | ... | ... |
|
|
364
|
+
| Context | ... | ... | ... | ... | ... | ... |
|
|
365
|
+
| Reliability | ... | ... | ... | ... | ... | ... |
|
|
366
|
+
```
|
|
367
|
+
Populate column headers with the actual tools discovered in 2.1.
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
## Phase 2.5: Reality Check (OPTIONAL — only with `--audit` flag)
|
|
372
|
+
|
|
373
|
+
If any related implementation already exists, verify it's real:
|
|
374
|
+
- [ ] File existence check (not just claimed in docs)
|
|
375
|
+
- [ ] Code substance check (not stubs or TODOs)
|
|
376
|
+
- [ ] Actually run it and verify output
|
|
377
|
+
- [ ] Test validity check (tests assert real behavior, not just existence)
|
|
378
|
+
- [ ] Truth table: `| Item | Claimed | Real | Verdict |`
|
|
379
|
+
|
|
380
|
+
---
|
|
381
|
+
|
|
382
|
+
## Phase 3: Strategic Analysis
|
|
383
|
+
|
|
384
|
+
### 3.1 Blue Ocean Four Actions Framework
|
|
385
|
+
| Action | Question | Decisions |
|
|
386
|
+
|--------|----------|-----------|
|
|
387
|
+
| **ELIMINATE** | What should we drop? | (e.g., complex config, IDE lock-in) |
|
|
388
|
+
| **REDUCE** | What should be reduced? | (e.g., boilerplate, setup time) |
|
|
389
|
+
| **RAISE** | What should be raised? | (e.g., context quality, verification) |
|
|
390
|
+
| **CREATE** | What should we create? | (e.g., context rot prevention, state persistence) |
|
|
391
|
+
|
|
392
|
+
### 3.2 Wardley Evolution Assessment
|
|
393
|
+
```
|
|
394
|
+
Genesis ──── Custom-Built ──── Product ──── Commodity
|
|
395
|
+
```
|
|
396
|
+
- Where is this feature in the INDUSTRY?
|
|
397
|
+
- Where should we position it?
|
|
398
|
+
- What evolution in 2-3 years? (plan for it now)
|
|
399
|
+
|
|
400
|
+
### 3.3 Strategic Moat Analysis
|
|
401
|
+
| Moat Type | Contribution | Score (0-5) |
|
|
402
|
+
|-----------|-------------|-------------|
|
|
403
|
+
| **Technical Differentiation** | Does this create a capability competitors can't easily replicate? | |
|
|
404
|
+
| **Platform Reach** | Does this work across all platforms/runtimes the project supports? | |
|
|
405
|
+
| **Developer Experience** | Is this meaningfully better than alternatives? | |
|
|
406
|
+
| **Dependency Footprint** | Does this maintain the project's dependency philosophy? | |
|
|
407
|
+
| **Data Continuity** | Does this improve cross-session or cross-tool data persistence? | |
|
|
408
|
+
| **Quality Assurance** | Does this strengthen the project's verification/testing guarantees? | |
|
|
409
|
+
|
|
410
|
+
### 3.4 Strategic Recommendation
|
|
411
|
+
Based on 3.1-3.3 AND Phase 0 demand evidence, write a 1-paragraph recommendation:
|
|
412
|
+
- Should we build this? (Yes / No / Modified)
|
|
413
|
+
- What's our unique angle?
|
|
414
|
+
- What should we explicitly NOT copy?
|
|
415
|
+
- What's the strategic timing?
|
|
416
|
+
|
|
417
|
+
**If `--gate` flag: STOP HERE and present Phases 0-3 for user approval.**
|
|
418
|
+
|
|
419
|
+
---
|
|
420
|
+
|
|
421
|
+
## Phase 3.5: Architecture & Implementation Pattern Assessment
|
|
422
|
+
|
|
423
|
+
**Design with the project's architecture, not against it.**
|
|
424
|
+
|
|
425
|
+
### 3.5.1 Feature Type Classification
|
|
426
|
+
Classify the feature using categories discovered from the project's architecture in Phase 0.8:
|
|
427
|
+
|
|
428
|
+
| Type | Description | Integration Pattern |
|
|
429
|
+
|------|-------------|--------------------|
|
|
430
|
+
| **New endpoint / route** | New API or CLI entry point | Add to router/dispatcher, implement handler |
|
|
431
|
+
| **New service / module** | New business logic unit | Create module, wire dependencies, export interface |
|
|
432
|
+
| **New UI component** | User-facing interface element | Create component, integrate into layout/routing |
|
|
433
|
+
| **New background job** | Async processing, scheduled task | Create worker, configure scheduler/queue |
|
|
434
|
+
| **Core enhancement** | Modify existing module | Edit module, update dependents, update tests |
|
|
435
|
+
| **Infrastructure** | Build, deploy, or config change | Modify pipeline, test deployment |
|
|
436
|
+
| **Plugin / extension** | Extensibility point or hook | Define interface, implement adapter, register |
|
|
437
|
+
|
|
438
|
+
Adapt this table to match the project's actual architecture patterns discovered in Phase 0.8.
|
|
439
|
+
|
|
440
|
+
### 3.5.2 Layer Violation Check
|
|
441
|
+
Using the project's architectural boundaries discovered in Phase 0.8, verify:
|
|
442
|
+
- [ ] New code respects the project's layer separation (e.g., controllers don't access DB directly, services don't import UI)
|
|
443
|
+
- [ ] Dependencies flow in the correct direction (no upward or circular dependencies)
|
|
444
|
+
- [ ] Public interfaces follow the project's established patterns
|
|
445
|
+
- [ ] No layer bypass — intermediate layers are not skipped
|
|
446
|
+
|
|
447
|
+
Document the specific layer rules discovered for this project.
|
|
448
|
+
|
|
449
|
+
### 3.5.3 Output Contract Design (Contract-First)
|
|
450
|
+
Define the interface/schema BEFORE implementation:
|
|
451
|
+
```json
|
|
452
|
+
{
|
|
453
|
+
"field1": "type — description",
|
|
454
|
+
"field2": "type — description",
|
|
455
|
+
"error": "string — only present on failure"
|
|
456
|
+
}
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
**Contract rules:**
|
|
460
|
+
- [ ] Field names use project's naming convention (discover from existing interfaces)
|
|
461
|
+
- [ ] No field name collisions with existing output
|
|
462
|
+
- [ ] Error shape consistent with project's error handling pattern
|
|
463
|
+
- [ ] Paths in output normalized per project convention
|
|
464
|
+
- [ ] Output size reasonable for the use case
|
|
465
|
+
|
|
466
|
+
### 3.5.4 State Transition Modeling
|
|
467
|
+
**Required if the feature mutates state or planning files.**
|
|
468
|
+
|
|
469
|
+
| Current State | Action | New State | Error If Invalid |
|
|
470
|
+
|--------------|--------|-----------|-----------------|
|
|
471
|
+
| [state A] | [this command] | [state B] | [error message] |
|
|
472
|
+
|
|
473
|
+
### 3.5.5 Breaking Change Assessment
|
|
474
|
+
| Question | Answer |
|
|
475
|
+
|----------|--------|
|
|
476
|
+
| Changes any existing command's output schema? | Yes/No |
|
|
477
|
+
| Changes file formats? | Yes/No |
|
|
478
|
+
| Changes directory structure? | Yes/No |
|
|
479
|
+
| Changes installer output? | Yes/No |
|
|
480
|
+
|
|
481
|
+
**If ANY answer is Yes:** Define a migration strategy.
|
|
482
|
+
|
|
483
|
+
### 3.5.6 Composability Analysis
|
|
484
|
+
| Interaction | Works? | How |
|
|
485
|
+
|-------------|--------|-----|
|
|
486
|
+
| Output feeds another command's input | Yes/No | [which command] |
|
|
487
|
+
| Callable from an agent | Yes/No | [how] |
|
|
488
|
+
| Usable in a hook pipeline | Yes/No | [how] |
|
|
489
|
+
| Works in --raw mode for humans | Yes/No | [raw output format] |
|
|
490
|
+
|
|
491
|
+
### 3.5.7 Performance Budget
|
|
492
|
+
| Operation | Cost | Notes |
|
|
493
|
+
|-----------|------|-------|
|
|
494
|
+
| File reads (N x ~5ms) | ~Xms | [list files] |
|
|
495
|
+
| Markdown parsing | ~Xms | [if applicable] |
|
|
496
|
+
| Computation | ~Xms | [describe] |
|
|
497
|
+
| File writes (N x ~5ms) | ~Xms | [list files] |
|
|
498
|
+
| **Total** | **< 500ms** | Justify if exceeding |
|
|
499
|
+
|
|
500
|
+
### 3.5.8 Cross-Platform Considerations
|
|
501
|
+
| Platform | Consideration |
|
|
502
|
+
|----------|---------------|
|
|
503
|
+
| Windows | Path separators, shell escaping, CRLF, long path limits (if applicable) |
|
|
504
|
+
| Mac/Linux | POSIX paths, case-sensitive filesystem (if applicable) |
|
|
505
|
+
| All | Use platform-agnostic path APIs, no hardcoded separators |
|
|
506
|
+
| All targets | All supported platform/runtime compatibility (discover from Phase 0.8) |
|
|
507
|
+
|
|
508
|
+
---
|
|
509
|
+
|
|
510
|
+
## Phase 4: Design Synthesis
|
|
511
|
+
|
|
512
|
+
### 4.1 Guide-Level Explanation (User-Facing)
|
|
513
|
+
Write as if teaching this feature to a user who has never seen it:
|
|
514
|
+
- Introduce the feature by name
|
|
515
|
+
- Show 2-3 practical examples with real-world scenarios
|
|
516
|
+
- Explain how it interacts with existing commands they already know
|
|
517
|
+
- Show the error messages they'd see if they misuse it
|
|
518
|
+
- Explain what it does NOT do (prevent confusion)
|
|
519
|
+
|
|
520
|
+
### 4.2 Reference-Level Explanation (Technical)
|
|
521
|
+
|
|
522
|
+
#### 4.2.1 Interface Definition
|
|
523
|
+
```
|
|
524
|
+
Interface: [describe invocation — CLI command, API endpoint, function call, UI action]
|
|
525
|
+
Arguments / Parameters: [list with types]
|
|
526
|
+
Output: [schema or format from 3.5.3]
|
|
527
|
+
Status / Exit codes: [success and error codes per project convention]
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
#### 4.2.2 State Changes & Filesystem Scope
|
|
531
|
+
```
|
|
532
|
+
Reads from: [list — must be within project root]
|
|
533
|
+
Writes to: [list — must be within .planning/ or project root]
|
|
534
|
+
State mutations: [state changes]
|
|
535
|
+
Side effects: [git operations, directory creation, etc.]
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
#### 4.2.3 Error Handling
|
|
539
|
+
Every error condition must specify:
|
|
540
|
+
| Condition | JSON Output | Error Style |
|
|
541
|
+
|-----------|-------------|-------------|
|
|
542
|
+
| [missing file] | {"error": "X not found"} | safe read returns null |
|
|
543
|
+
| [bad args] | {"error": "X required"} | arg validation before fs ops |
|
|
544
|
+
|
|
545
|
+
### 4.3 Design Decisions
|
|
546
|
+
| Decision | Adopted From | Rationale | What We Did NOT Copy (and Why) |
|
|
547
|
+
|----------|-------------|-----------|-------------------------------|
|
|
548
|
+
|
|
549
|
+
### 4.4 Drawbacks & Alternatives
|
|
550
|
+
| Decision Point | Chosen | Alternative | Why Not | Drawback of Chosen |
|
|
551
|
+
|----------------|--------|------------|---------|-------------------|
|
|
552
|
+
|
|
553
|
+
### 4.5 Feature Ladder (Incremental Delivery)
|
|
554
|
+
| Version | Scope | Value Delivered | Effort |
|
|
555
|
+
|---------|-------|----------------|--------|
|
|
556
|
+
| **v0 (MVP)** | [smallest useful slice] | [what user can do] | XS-S |
|
|
557
|
+
| **v1 (Complete)** | [full feature as designed] | [full value] | S-M |
|
|
558
|
+
| **v2 (Enhanced)** | [future extensions] | [additional value] | M-L |
|
|
559
|
+
|
|
560
|
+
### 4.6 Adoption Analysis
|
|
561
|
+
| Question | Answer |
|
|
562
|
+
|----------|--------|
|
|
563
|
+
| How does the user discover this feature? | |
|
|
564
|
+
| What's the learning curve? | |
|
|
565
|
+
| Does it require changing existing workflows? | |
|
|
566
|
+
| What's the "aha moment"? | |
|
|
567
|
+
|
|
568
|
+
---
|
|
569
|
+
|
|
570
|
+
## Phase 5: Architecture Decision Record
|
|
571
|
+
|
|
572
|
+
Create a formal ADR:
|
|
573
|
+
|
|
574
|
+
```markdown
|
|
575
|
+
# ADR-NNNN: [Feature Name]
|
|
576
|
+
|
|
577
|
+
## Status
|
|
578
|
+
Proposed
|
|
579
|
+
|
|
580
|
+
## Context
|
|
581
|
+
[Problem context — what forces are at play?]
|
|
582
|
+
|
|
583
|
+
## Decision
|
|
584
|
+
[What was decided and why]
|
|
585
|
+
|
|
586
|
+
## Consequences
|
|
587
|
+
### Positive
|
|
588
|
+
- [Benefit 1]
|
|
589
|
+
### Negative
|
|
590
|
+
- [Cost 1]
|
|
591
|
+
### Neutral
|
|
592
|
+
- [Side effect]
|
|
593
|
+
|
|
594
|
+
## Options Considered
|
|
595
|
+
1. [Option A] — [summary]
|
|
596
|
+
2. [Option B — chosen] — [summary]
|
|
597
|
+
|
|
598
|
+
## Links
|
|
599
|
+
- Related to: [commands, modules, issues]
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
---
|
|
603
|
+
|
|
604
|
+
## Phase 6: Error Handling & Diagnostics Design
|
|
605
|
+
|
|
606
|
+
> *Make the feature diagnosable from day one.*
|
|
607
|
+
|
|
608
|
+
### 6.1 Failure Mode Analysis
|
|
609
|
+
| Failure Mode | Category | Detection Pattern | Recovery | User Sees |
|
|
610
|
+
|-------------|----------|-------------------|----------|-----------|
|
|
611
|
+
| Missing required file | User error | Check before access | Actionable error message | Clear guidance on what's missing |
|
|
612
|
+
| Invalid arguments | User error | Input validation | Error with usage hint | Usage guidance |
|
|
613
|
+
| External service unavailable | Environment | Timeout / connection error | Retry or graceful degradation | Service-specific message |
|
|
614
|
+
| Disk full / write failure | Environment | try-catch on write | Graceful error | No crash, no data corruption |
|
|
615
|
+
| Malformed input data | Data corruption | Validation on parse | Skip bad data or error | Degraded but functional |
|
|
616
|
+
| Concurrent access | Race condition | Project's concurrency pattern | Safe fallback | No corruption |
|
|
617
|
+
|
|
618
|
+
### 6.2 Diagnostic Support
|
|
619
|
+
Design diagnostics using the project's existing patterns:
|
|
620
|
+
| Diagnostic | How | When |
|
|
621
|
+
|------------|-----|------|
|
|
622
|
+
| Verbose / debug mode | Project's debug flag pattern | Debugging |
|
|
623
|
+
| Structured logging | Project's logging framework | Monitoring |
|
|
624
|
+
| Error context | Include relevant state in errors | Failures |
|
|
625
|
+
| Health check | Expose status endpoint or command | Operations |
|
|
626
|
+
|
|
627
|
+
---
|
|
628
|
+
|
|
629
|
+
## Phase 7: Security & Threat Model
|
|
630
|
+
|
|
631
|
+
### 7.1 Asset & Attack Surface Inventory
|
|
632
|
+
| Asset | Accessed How | Trust Level |
|
|
633
|
+
|-------|-------------|-------------|
|
|
634
|
+
| [file/data this feature touches] | Read / Write / Execute | User-controlled / System-generated |
|
|
635
|
+
|
|
636
|
+
| Input Vector | Source | Validation Required |
|
|
637
|
+
|-------------|--------|-------------------|
|
|
638
|
+
| CLI arguments | User-typed | Type check, length limit, no shell metacharacters |
|
|
639
|
+
| File contents (*.md, *.json) | Disk (user-writable) | Structure validation, size limit |
|
|
640
|
+
| Environment variables | OS | Only read known vars, never expose in output |
|
|
641
|
+
| Path arguments | User-typed | Full path safety protocol (below) |
|
|
642
|
+
|
|
643
|
+
### 7.2 Path Safety Protocol (MANDATORY for any path input)
|
|
644
|
+
1. Resolve to absolute: `path.resolve(cwd, userPath)`
|
|
645
|
+
2. Verify within project: resolved path starts with `path.resolve(cwd)`
|
|
646
|
+
3. Reject `..` segments before resolution
|
|
647
|
+
4. Reject null bytes (`\0`)
|
|
648
|
+
5. On Windows: reject alternate data streams (`:` after drive letter position 2)
|
|
649
|
+
|
|
650
|
+
### 7.3 Output Sanitization
|
|
651
|
+
- [ ] No absolute filesystem paths in output (use normalized relative paths)
|
|
652
|
+
- [ ] No environment variable values in output
|
|
653
|
+
- [ ] No stack traces in error messages
|
|
654
|
+
- [ ] No internal function names or line numbers in user-facing errors
|
|
655
|
+
|
|
656
|
+
### 7.4 Content Validation
|
|
657
|
+
Every file read must validate structure before processing:
|
|
658
|
+
- JSON files: `JSON.parse()` inside try-catch, validate expected keys
|
|
659
|
+
- Markdown files: Check for expected frontmatter or section headers
|
|
660
|
+
- Never pass raw file content to `eval()`, `Function()`, or template strings
|
|
661
|
+
|
|
662
|
+
### 7.5 Privilege Scope Declaration
|
|
663
|
+
```
|
|
664
|
+
Reads from: [explicit directory list — must be within project root]
|
|
665
|
+
Writes to: [explicit directory list — must be within .planning/ or project root]
|
|
666
|
+
Executes shell: [Yes/No — if yes, what commands and why]
|
|
667
|
+
Reads outside project: [Yes/No — if yes, justify]
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
---
|
|
671
|
+
|
|
672
|
+
## Phase 8: Implementation Roadmap
|
|
673
|
+
|
|
674
|
+
### 8.1 Command .md Definition (DRAFT NOW — not deferred)
|
|
675
|
+
Draft the command file content. The command file IS the interface for AI tools.
|
|
676
|
+
|
|
677
|
+
### 8.2 Implementation Tasks (Ordered)
|
|
678
|
+
Break into small, independently testable units:
|
|
679
|
+
|
|
680
|
+
```
|
|
681
|
+
### Task 1: [Core module changes]
|
|
682
|
+
Files: [paths]
|
|
683
|
+
Test: [test command]
|
|
684
|
+
Estimate: XS/S/M/L
|
|
685
|
+
Priority: P[0-6]
|
|
686
|
+
|
|
687
|
+
### Task 2: [CLI dispatcher routing]
|
|
688
|
+
...
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
### 8.3 Dependency Graph
|
|
692
|
+
```
|
|
693
|
+
Task 1 -> Task 2 -> Task 3 -> ...
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
### 8.4 Risk Register
|
|
697
|
+
| Risk | Probability | Impact | Mitigation |
|
|
698
|
+
|------|------------|--------|------------|
|
|
699
|
+
|
|
700
|
+
### 8.5 Cognitive Complexity Budget
|
|
701
|
+
Apply the project's established complexity limits (discover from linter config, CONTRIBUTING.md, or code review conventions):
|
|
702
|
+
- Max function length: [discover from project — check linter rules or established patterns]
|
|
703
|
+
- Max nesting depth: [discover from project]
|
|
704
|
+
- Max parameters: [discover from project — use options/config object if exceeded]
|
|
705
|
+
|
|
706
|
+
If the project has no documented limits, propose reasonable defaults and flag for team review.
|
|
707
|
+
|
|
708
|
+
---
|
|
709
|
+
|
|
710
|
+
## Phase 9: Test Plan
|
|
711
|
+
|
|
712
|
+
### 9.1 Test Pyramid (proportional to scope)
|
|
713
|
+
| Level | Pattern | Guidance | What It Catches |
|
|
714
|
+
|-------|---------|----------|-----------------|
|
|
715
|
+
| **Unit** | Test individual functions, mock externals | Cover all business logic paths + edge cases | Logic bugs, edge cases |
|
|
716
|
+
| **Integration** | Test with real dependencies (DB, filesystem, APIs) | Cover all integration boundaries | Wiring bugs, config issues, data flow |
|
|
717
|
+
| **E2E** | Full user workflow sequences | Cover critical user journeys | State transitions, cross-component interaction |
|
|
718
|
+
|
|
719
|
+
Scale test counts proportionally to feature complexity. Discover the project's test conventions from Phase 0.8 (framework, directory structure, naming, assertion library, helper patterns).
|
|
720
|
+
|
|
721
|
+
### 9.2 Assertion Density Requirements
|
|
722
|
+
Every test must assert AT MINIMUM:
|
|
723
|
+
- **Success tests:** (a) correct JSON shape, (b) correct values for >= 2 fields, (c) no `error` field
|
|
724
|
+
- **Error tests:** (a) `error` field with actionable message, (b) no data corruption, (c) clean exit
|
|
725
|
+
|
|
726
|
+
### 9.3 Boundary Value Analysis
|
|
727
|
+
Test these boundary conditions (adapt to project domain):
|
|
728
|
+
- [ ] Empty / fresh project state (no existing data)
|
|
729
|
+
- [ ] Minimal vs maximal input size
|
|
730
|
+
- [ ] Edge case inputs (special characters, unicode, empty strings, boundary numbers)
|
|
731
|
+
- [ ] Missing file / resource between check and access (race condition)
|
|
732
|
+
- [ ] Platform-specific edge cases (path lengths, encoding, line endings)
|
|
733
|
+
- [ ] Resource contention (file locks, concurrent access)
|
|
734
|
+
- [ ] Malformed / corrupted input data
|
|
735
|
+
|
|
736
|
+
### 9.4 Regression Verification
|
|
737
|
+
- [ ] Full suite passes unchanged
|
|
738
|
+
- [ ] Related modules explicitly re-tested
|
|
739
|
+
- [ ] No existing test expectations changed
|
|
740
|
+
|
|
741
|
+
### 9.5 Performance Validation
|
|
742
|
+
- [ ] Feature completes within acceptable time for typical usage (define budget based on project norms)
|
|
743
|
+
- [ ] No regression in full test suite runtime
|
|
744
|
+
- [ ] Output / response size reasonable for the use case
|
|
745
|
+
|
|
746
|
+
---
|
|
747
|
+
|
|
748
|
+
## Phase 10: Output Artifacts
|
|
749
|
+
|
|
750
|
+
### 10.1 Save Specification Document
|
|
751
|
+
Write complete spec to: `docs/specs/<feature_name>_featureai.md`
|
|
752
|
+
|
|
753
|
+
### 10.2 Save ADR
|
|
754
|
+
Write ADR to: `docs/decisions/ADR-NNNN-<feature_name>.md`
|
|
755
|
+
|
|
756
|
+
### 10.3 Report Summary
|
|
757
|
+
Output a complete summary with:
|
|
758
|
+
- **Problem & Evidence** — 1-sentence problem, evidence sources
|
|
759
|
+
- **Investigation Depth** — files read during Phase 0.8, patterns discovered, modules in impact analysis
|
|
760
|
+
- **Strategic Assessment** — Blue Ocean actions, Wardley position, Moat Score (N/30), Cognitive Load score, Recommendation
|
|
761
|
+
- **Competitive Position** — which competitors analyzed, where the project leads/lags for this feature
|
|
762
|
+
- **Design Summary** — feature type, modules affected, output schema, error handling, breaking changes
|
|
763
|
+
- **Feature Ladder** — v0/v1/v2 scope and effort
|
|
764
|
+
- **Implementation Tasks** — count, total complexity, files to create/modify
|
|
765
|
+
- **Security** — attack surface, path safety, output sanitization
|
|
766
|
+
- **Adoption** — discovery, learning curve, aha moment
|
|
767
|
+
- **Informed Questions** — count asked, what they clarified
|
|
768
|
+
- **Acceptance Criteria** — count, how many are machine-checkable
|
|
769
|
+
- **Documents Created** — spec path, ADR path, command .md path (if applicable)
|
|
770
|
+
- **Next Step** — recommended follow-up command
|
|
771
|
+
|
|
772
|
+
---
|
|
773
|
+
|
|
774
|
+
## NEVER DO
|
|
775
|
+
|
|
776
|
+
- Design without proving the problem exists (Phase 0 demand evidence is mandatory)
|
|
777
|
+
- Skip competitive research — must be best-of-breed
|
|
778
|
+
- Copy a tool's design without understanding WHY they made that choice
|
|
779
|
+
- Violate the project's dependency philosophy (discover from Phase 0.8)
|
|
780
|
+
- Add a feature without error handling design (Phase 6)
|
|
781
|
+
- Skip cross-platform considerations when the project supports multiple platforms
|
|
782
|
+
- Produce a spec without measurable success criteria
|
|
783
|
+
- Produce a spec without a test plan with enforced assertion density
|
|
784
|
+
- Trust existing implementation claims without `--audit` verification
|
|
785
|
+
- Design in isolation — always map dependencies and integration points
|
|
786
|
+
- Use `eval()`, `Function()`, string interpolation in shell commands, or unvalidated paths
|
|
787
|
+
- Violate the project's architectural layer boundaries (discover from Phase 0.8)
|
|
788
|
+
- Expose absolute paths, stack traces, or env vars in output
|
|
789
|
+
- Change existing public interfaces without a migration strategy
|
|
790
|
+
- Defer the interface definition to "documentation" — draft it during design
|
|
791
|
+
- Exceed the project's established complexity limits
|
|
792
|
+
- Add a feature scoring +2 on cognitive load without explicit justification
|
|
793
|
+
- Ship a feature with no demand evidence and no strategic justification
|
|
794
|
+
|
|
795
|
+
## ALWAYS DO
|
|
796
|
+
|
|
797
|
+
- Start from the USER's problem, not the technology
|
|
798
|
+
- Gather demand evidence before committing to design
|
|
799
|
+
- Check all existing project features for overlap before proposing new ones
|
|
800
|
+
- Research at least 6 competitor tools in the feature's domain before designing
|
|
801
|
+
- Apply Blue Ocean thinking — find where to CREATE, not just copy
|
|
802
|
+
- Define the output/interface contract BEFORE implementation design (contract-first)
|
|
803
|
+
- Write the guide-level explanation BEFORE the reference-level
|
|
804
|
+
- Draft the interface definition as part of the spec (it IS the integration point)
|
|
805
|
+
- Plan for failure (error messages, graceful degradation, actionable errors)
|
|
806
|
+
- Follow the project's error message conventions (discover from Phase 0.8)
|
|
807
|
+
- Apply the path safety protocol for any user-supplied path input
|
|
808
|
+
- Validate file content structure before processing (never trust disk contents)
|
|
809
|
+
- Follow existing patterns for output, errors, file reading
|
|
810
|
+
- Follow the project's dependency philosophy (discover from Phase 0.8)
|
|
811
|
+
- Enforce the project's test pyramid proportional to feature scope (discover from Phase 0.8)
|
|
812
|
+
- Verify dependency chain has no cycles
|
|
813
|
+
- Stay within the project's established complexity limits (discover from Phase 0.8)
|
|
814
|
+
- Define a feature ladder (v0 MVP -> v1 complete -> v2 enhanced)
|
|
815
|
+
- Model adoption friction (discovery, learning curve, aha moment)
|
|
816
|
+
- Produce a complete spec with ADR, ready for implementation
|