@gitwhy-cli/whyspec 0.1.16 → 0.1.18

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.
@@ -1,25 +1,38 @@
1
1
  ---
2
2
  name: whyspec-execute
3
- description: Implement a planned change using intent and design as context. Use when the user wants to start implementing, continue work, or execute tasks from a WhySpec plan.
3
+ description: Use when starting implementation, continuing work, or executing tasks from a WhySpec plan.
4
+ argument-hint: "[change-name]"
4
5
  ---
5
6
 
6
7
  Implement a change — read the plan, work through tasks, commit atomically.
7
8
 
8
- When all tasks are done, run `/whyspec-capture` to save your reasoning.
9
+ When all tasks are done, run `/whyspec:capture` to save your reasoning.
9
10
 
10
11
  ---
11
12
 
12
13
  **Input**: Optionally specify a change name. If omitted, auto-detect or prompt for available changes.
13
14
 
14
- **Steps**
15
+ ## Iron Law
16
+
17
+ **NEVER SKIP THE PLAN.** Read intent.md and design.md before writing a single line of code. The plan is the contract — if reality doesn't match the plan, update the plan first.
18
+
19
+ ## Red Flags — If You're Thinking This, STOP
20
+
21
+ - "The plan is clear enough, I'll just start coding" → Read intent.md. Now. It takes 15 seconds.
22
+ - "I'll batch all changes into one commit at the end" → One commit per task. That's the contract.
23
+ - "This task seems unnecessary, I'll skip it" → Ask the user to remove it. Don't silently skip.
24
+ - "The design says X but Y is clearly better" → Flag the contradiction. Don't silently override.
25
+ - "I'm done, no need to run the verify step" → Run it. Evidence beats confidence.
26
+
27
+ ## Steps
15
28
 
16
29
  1. **Select the change**
17
30
 
18
- If a name is provided, use it. Otherwise:
31
+ If ARGUMENTS provides a name, use it. Otherwise:
19
32
  - Auto-select if only one active change exists
20
- - If multiple changes exist, run `whyspec list --json` and use **AskUserQuestion** to let the user select
33
+ - If multiple changes exist, run `whyspec list --json` and let the user select
21
34
 
22
- Always announce: "Executing change: **<name>**"
35
+ Announce: "Executing change: **<name>**"
23
36
 
24
37
  2. **Load execution context**
25
38
 
@@ -37,7 +50,7 @@ When all tasks are done, run `/whyspec-capture` to save your reasoning.
37
50
 
38
51
  3. **Read plan files for context**
39
52
 
40
- Read the full content of these files from the change folder:
53
+ Read the full content of:
41
54
  - `intent.md` — understand WHY this change exists, what constraints apply
42
55
  - `design.md` — understand HOW to approach it, what decisions are pending
43
56
  - `tasks.md` — understand WHAT to implement and how to verify
@@ -53,7 +66,6 @@ When all tasks are done, run `/whyspec-capture` to save your reasoning.
53
66
  Remaining:
54
67
  - [ ] Task description 1
55
68
  - [ ] Task description 2
56
- ...
57
69
  ```
58
70
 
59
71
  5. **Implement tasks sequentially**
@@ -67,47 +79,127 @@ When all tasks are done, run `/whyspec-capture` to save your reasoning.
67
79
  e. Commit atomically — one commit per task or logical unit
68
80
  f. Continue to next task
69
81
 
70
- **Pause if:**
71
- - Task is unclear or ambiguous → use **AskUserQuestion** to clarify before implementing
72
- - Implementation reveals a design issue → suggest updating design.md, ask user how to proceed
73
- - Task contradicts the stated intent → flag the contradiction to the user
74
- - Error or blocker encounteredreport what happened and wait for guidance
75
- - You're unsure about a "Decision to Make" from design.md → ask the user to resolve it
82
+ <examples>
83
+ <good>
84
+ Working on task 3/5: Add rate-limit middleware
85
+
86
+ Reading src/middleware/index.ts current chain: cors helmet bodyParser routes
87
+ Installing express-rate-limit@7.1.0 (compatible with Express 4.18)
88
+ Added rateLimiter middleware after helmet at src/middleware/index.ts:14
89
+ Config: 100 req/15min window, Redis store via existing src/lib/redis.ts client
90
+
91
+ verify: `npm test -- --grep "rate-limit"` → 4 tests pass
92
+ verify: `curl -I localhost:3000/api/users` → X-RateLimit-Limit: 100 header present
93
+
94
+ Committed: "feat(middleware): add rate-limit middleware with Redis backing"
95
+ Why good: References exact files/lines, shows what was done and why,
96
+ runs specific verification commands, commits atomically with clear message.
97
+ </good>
98
+
99
+ <bad>
100
+ Working on task 3/5: Add rate-limit middleware
101
+ Done! Moving to task 4.
102
+ Why bad: No detail about what was implemented. No verification.
103
+ No commit. The user can't tell if this was done correctly.
104
+ </bad>
105
+
106
+ <good>
107
+ Working on task 2/4: Refactor auth to use JWT
108
+ PAUSE — design.md says "cookie-based sessions" (design.md:12) but this task
109
+ says "JWT". This contradicts the design.
110
+ Options:
111
+ A) Update design.md to JWT and continue (Recommended — JWT aligns with the API-first intent)
112
+ B) Implement cookie-based sessions as designed
113
+ C) Discuss the trade-offs before deciding
114
+ Why good: Catches a contradiction between plan and task. Stops to resolve
115
+ with specific options instead of silently making a decision.
116
+ </good>
117
+
118
+ <bad>
119
+ Working on task 2/4: Refactor auth to use JWT
120
+ Design says cookies but I'll use JWT since the task says so.
121
+ Why bad: Silently overrides the design without flagging the contradiction.
122
+ </bad>
123
+ </examples>
76
124
 
77
125
  6. **On completion**
78
126
 
79
- When all tasks are done:
127
+ Report status using completion codes:
128
+
129
+ | Status | When | What to show |
130
+ |--------|------|-------------|
131
+ | DONE | All tasks completed and verified | Full summary + `/whyspec:capture` prompt |
132
+ | DONE_WITH_CONCERNS | Tasks done but something feels off | Summary + concerns + `/whyspec:capture` |
133
+ | BLOCKED | Cannot proceed without input | Blocker details + resume command |
134
+ | NEEDS_CONTEXT | Missing information | Specific question about what's missing |
80
135
 
81
136
  ```
82
- ## Implementation Complete
137
+ ## DONE
83
138
 
84
139
  Change: <name>
85
140
  Progress: M/M tasks complete
86
141
 
87
142
  Completed:
88
- - [x] Task 1: description
89
- - [x] Task 2: description
90
- ...
143
+ - [x] Task 1: description — committed as "feat: ..."
144
+ - [x] Task 2: description — committed as "feat: ..."
91
145
 
92
- Ready to capture reasoning? Run /whyspec-capture
146
+ Ready to capture reasoning? Run /whyspec:capture
93
147
  ```
94
148
 
95
- If paused before completion:
149
+ ## Tools
96
150
 
97
- ```
98
- ## Implementation Paused
151
+ | Tool | When to use | When NOT to use |
152
+ |------|------------|-----------------|
153
+ | **Read** | Read plan files (intent.md, design.md, tasks.md) BEFORE coding | Don't skip reading the plan |
154
+ | **Grep** | Find affected code before editing (e.g., all usages of a function you're changing) | Don't grep after editing — grep BEFORE to understand impact |
155
+ | **Edit** | Modify existing files — prefer Edit over Write for existing code | Don't rewrite entire files when a targeted edit suffices |
156
+ | **Write** | Create new files only | Don't use Write to modify existing files |
157
+ | **Bash** | Run tests (`npm test`), verify (`curl`, build commands), commit (`git commit`) | Don't run destructive git commands without asking |
158
+ | **AskUserQuestion** | When a task is unclear, or design contradicts implementation (see format below) | Don't ask about things you can determine from the plan or code |
99
159
 
100
- Change: <name>
101
- Progress: N/M tasks complete
160
+ ### AskUserQuestion Format (use for contradictions and blockers)
102
161
 
103
- Issue: <what caused the pause>
162
+ 1. **Re-ground**: "Executing task N/M of **<change>** — `<task description>`"
163
+ 2. **The contradiction/blocker**: What you found vs what the plan says
164
+ 3. **Options with recommendation**: Lettered choices with your pick
104
165
 
105
- Resume with: /whyspec-execute <name>
106
- ```
166
+ <examples>
167
+ <good>
168
+ Executing task 2/4 of **add-rate-limiting** — "Configure Redis store"
169
+
170
+ design.md says use the existing ioredis client (src/lib/redis.ts:8), but that
171
+ client uses `db: 0` which is shared with session data. Rate limit keys could
172
+ collide with session keys.
173
+
174
+ A) Use db: 0 with a `ratelimit:` key prefix (simple, small collision risk)
175
+ B) Create a separate client on db: 1 (isolated, adds ~2MB memory)
176
+ C) Reuse db: 0 but with a Redis namespace library
177
+
178
+ I'd recommend B — isolation is worth 2MB.
179
+ Why good: Specific blocker with evidence from code. Options with trade-offs.
180
+ </good>
181
+ </examples>
182
+
183
+ ## Escalation Protocol
184
+
185
+ | Situation | Attempts allowed | Action |
186
+ |-----------|-----------------|--------|
187
+ | Task is unclear or ambiguous | 0 — ask immediately | Ask ONE specific clarification question |
188
+ | Implementation keeps failing | 3 attempts max | Report: what was tried, what failed, what error |
189
+ | Design contradiction found | 0 — flag immediately | Present options, let user decide |
190
+ | Unexpected dependency or constraint | 1 attempt to resolve | If can't resolve, present findings and ask |
191
+
192
+ ## Rationalization Table
107
193
 
108
- **Always end with the capture prompt** the reasoning is freshest right after implementation.
194
+ | If you catch yourself thinking... | Reality |
195
+ |----------------------------------|---------|
196
+ | "I'll read the plan later, the task name is clear enough" | The plan has constraints you'll violate. Read it. 15 seconds. |
197
+ | "One big commit is fine, I'll split it later" | You won't. Atomic commits are the contract. Do it now. |
198
+ | "This test is probably passing, no need to run it" | "Probably" is not evidence. Run the test. |
199
+ | "I'll skip the verify step for this trivial task" | Trivial tasks have trivial verifications. Run them anyway. |
200
+ | "The design is slightly wrong but my way is better" | Flag it. The user made the design for a reason you might not see. |
109
201
 
110
- **Guardrails**
202
+ ## Guardrails
111
203
 
112
204
  - **Read intent.md before coding** — every implementation decision should align with the stated intent and constraints.
113
205
  - **Never skip tasks** — work through all tasks in order. If a task seems unnecessary, ask the user to remove it rather than silently skipping.
@@ -115,4 +207,4 @@ When all tasks are done, run `/whyspec-capture` to save your reasoning.
115
207
  - **Pause on unclear tasks** — don't guess at ambiguous requirements. Ask for clarification.
116
208
  - **Pause on design issues** — if reality doesn't match the plan, stop and suggest design.md updates before continuing.
117
209
  - **Mark checkboxes immediately** — update tasks.md after each task completion, not at the end.
118
- - **Always prompt capture** — end every execution session (complete or paused) with the `/whyspec-capture` suggestion.
210
+ - **Always prompt capture** — end every execution session with the `/whyspec:capture` suggestion.
@@ -1,36 +1,72 @@
1
1
  ---
2
2
  name: whyspec-plan
3
- description: Plan a change by declaring intent, design, and tasks before coding. Use when the user wants to plan what to build, capture decisions that need to be made, or set up the Decision Bridge before implementation.
3
+ description: Use when planning a code change, capturing decisions before coding, or setting up the Decision Bridge.
4
+ argument-hint: "<change-name-or-description>"
4
5
  ---
5
6
 
6
7
  Plan a change — create intent.md, design.md, and tasks.md with the Decision Bridge.
7
8
 
8
- When ready to implement, run `/whyspec-execute`
9
+ When ready to implement, run `/whyspec:execute`
9
10
 
10
11
  ---
11
12
 
12
- **Input**: A change name (kebab-case) or description of what to build.
13
+ **Input**: A change name (kebab-case) or description of what to build via ARGUMENTS.
13
14
 
14
- **Steps**
15
+ ## Iron Law
15
16
 
16
- 1. **Ask forcing questions before anything else**
17
+ **ACT FIRST, ASK ONLY WHEN STUCK.** The user invoked `/whyspec:plan` with a description of what they want. Your job is to structure their intent into plan files — not to interview them.
17
18
 
18
- Do NOT create any files yet. Use the **AskUserQuestion tool** to ask these questions they shape the entire plan:
19
+ ## Red FlagsIf You're Thinking This, STOP
19
20
 
20
- First ask:
21
- > "What problem does this solve? Who feels this pain today?"
21
+ - "I should ask what problem this solves" → The user TOLD you. Read ARGUMENTS.
22
+ - "Let me ask about constraints first" Explore the codebase. Find them yourself.
23
+ - "I need more context before I can plan" → You have a codebase. Read it.
24
+ - "This is too vague to plan" → Even "fix auth" is enough. Read the auth code, find the issues, plan the fix.
25
+ - "I'll create a generic template and ask the user to fill it in" → That's not planning. That's homework assignment.
22
26
 
23
- Then, building on their answer:
24
- > "What constraints exist? (technical limits, timeline, dependencies, things that can't change)"
27
+ ## Steps
25
28
 
26
- Finally:
27
- > "How will you know it works? What does success look like?"
29
+ 1. **Parse ARGUMENTS and infer intent**
28
30
 
29
- If the user provides a rich description upfront that already answers these, you may condense to one clarifying question. But never skip entirely.
31
+ Read what the user typed. Derive a kebab-case name (e.g., "add user authentication" `add-user-auth`).
30
32
 
31
- 2. **Create the change folder**
33
+ **If ARGUMENTS is empty or a single ambiguous word** (e.g., just "plan" or "help"):
34
+ Ask ONE question: "What change are you planning?" — then proceed.
35
+
36
+ **If ARGUMENTS has any meaningful description** (even brief):
37
+ Proceed immediately. Do NOT ask forcing questions. The user told you what they want.
38
+
39
+ <examples>
40
+ <good>
41
+ User: `/whyspec:plan add dark mode support`
42
+ Agent: Creates change folder, writes intent.md capturing dark mode as the goal,
43
+ design.md with CSS custom properties vs class-based approach trade-off,
44
+ tasks.md with implementation steps.
45
+ Why good: User stated what they want. Agent structured it into plan files without interrogation.
46
+ </good>
47
+
48
+ <bad>
49
+ User: `/whyspec:plan add dark mode support`
50
+ Agent: "What problem does this solve? Who feels this pain today?"
51
+ Why bad: The user literally just told you — they want dark mode. Asking "what problem does
52
+ this solve" is patronizing checklist-walking. The answer is obvious from the input.
53
+ </bad>
32
54
 
33
- Derive a kebab-case name from the user's input (e.g., "add user authentication" → `add-user-auth`).
55
+ <good>
56
+ User: `/whyspec:plan`
57
+ Agent: "What change are you planning?"
58
+ Why good: ARGUMENTS is empty. ONE question to get started is justified.
59
+ </good>
60
+
61
+ <bad>
62
+ User: `/whyspec:plan refactor auth middleware`
63
+ Agent: "What constraints exist? What does success look like? How will you know it works?"
64
+ Why bad: Three rounds of corporate interview questions. The user wants to refactor auth
65
+ middleware — explore the codebase to understand constraints, don't ask generic questions.
66
+ </bad>
67
+ </examples>
68
+
69
+ 2. **Create the change folder**
34
70
 
35
71
  ```bash
36
72
  whyspec plan --json "<name>"
@@ -42,53 +78,105 @@ When ready to implement, run `/whyspec-execute`
42
78
  - `context`: Project context from config.yaml (constraints for you — do NOT copy into files)
43
79
  - `rules`: Project-specific rules (constraints for you — do NOT copy into files)
44
80
 
45
- If a change with that name already exists, use **AskUserQuestion** to ask: continue the existing change, or create a new one with a different name?
81
+ If a change with that name already exists, ask: continue the existing change, or create a new one with a different name?
82
+
83
+ 3. **Explore codebase for context** (if the change touches existing code)
46
84
 
47
- 3. **Create intent.md**
85
+ Before writing plan files, read relevant code to understand:
86
+ - Current architecture in the affected area
87
+ - Existing patterns and conventions
88
+ - Dependencies and constraints
48
89
 
49
- Write to `<path>/intent.md`. Populate using the user's answers to the forcing questions:
90
+ <examples>
91
+ <good>
92
+ User wants to add rate limiting.
93
+ Agent reads src/middleware/index.ts, finds Express + helmet at line 12,
94
+ sees the middleware chain: cors → helmet → bodyParser → routes.
95
+ Writes design.md: "Insert express-rate-limit after helmet in the existing
96
+ chain at src/middleware/index.ts:14. Use sliding window algorithm.
97
+ Redis backing via existing ioredis client at src/lib/redis.ts."
98
+ Why good: References exact files, line numbers, existing dependencies.
99
+ Plan is grounded in code the agent actually read.
100
+ </good>
101
+
102
+ <bad>
103
+ User wants to add rate limiting.
104
+ Agent writes design.md: "Consider using express-rate-limit or a custom
105
+ middleware solution. Evaluate Redis vs in-memory storage."
106
+ Why bad: Generic advice from training data. Ignores the actual codebase.
107
+ Could have been written without reading a single file.
108
+ </bad>
109
+ </examples>
110
+
111
+ 4. **Create intent.md**
112
+
113
+ Write to `<path>/intent.md`. Here's a concrete filled-in example:
50
114
 
51
115
  ```markdown
52
116
  ## Why This Change Exists
53
117
 
54
- [Problem statement from forcing question 1. Be specific about who feels the pain.]
118
+ POST /api/users returns 500 under load because we have no rate limiting.
119
+ Production logs show 12k requests/min from a single IP during the March 28 incident.
55
120
 
56
121
  ## What It Enables
57
122
 
58
- [Capabilities this unlocks. What becomes possible that wasn't before?]
123
+ API stability under load. Prevents abuse without blocking legitimate traffic.
59
124
 
60
125
  ## Decisions to Make
61
126
 
62
- - [ ] [Decision 1: option A vs option B?]
63
- - [ ] [Decision 2: approach X vs approach Y?]
64
- - [ ] [Decision 3: ...]
127
+ - [ ] Rate limit storage: Redis (shared across 3 instances) vs in-memory (simpler, single-instance only)?
128
+ - [ ] Limit granularity: per-IP vs per-user-token vs both?
129
+ - [ ] Response on limit: 429 with Retry-After header vs 429 with custom error body?
65
130
 
66
131
  These checkboxes form the "before" side of the Decision Bridge.
67
- They will be resolved during /whyspec-capture after implementation.
132
+ They will be resolved during /whyspec:capture after implementation.
68
133
 
69
134
  ## Constraints
70
135
 
71
- [From forcing question 2 technical limits, non-negotiables, dependencies]
136
+ - Must work with existing Express middleware chain (cors → helmet → bodyParser → routes)
137
+ - Redis (ioredis) already available at src/lib/redis.ts — prefer reuse over new dependency
138
+ - P99 latency budget: <5ms per request for rate limit check
72
139
 
73
140
  ## Success Looks Like
74
141
 
75
- [From forcing question 3 observable outcomes, acceptance criteria]
142
+ - `npm test` passes with rate limit integration tests
143
+ - Siege test: 1000 req/s returns 429 after threshold, Retry-After header present
144
+ - No latency regression visible in existing API benchmark
76
145
 
77
146
  ## Assumptions
78
147
 
79
- [What we're assuming is true but haven't verified]
148
+ - Redis is available in all environments (need to verify staging)
149
+ - Current ioredis client supports the rate limiting pattern we choose
80
150
  ```
81
151
 
82
- **IMPORTANT**: The "Decisions to Make" checkboxes are the Decision Bridge. Every design choice that isn't settled yet MUST be listed here. These get resolved in the context file after implementation.
152
+ **IMPORTANT**: The "Decisions to Make" checkboxes are the Decision Bridge. Every unsettled design choice MUST be listed here.
153
+
154
+ <examples>
155
+ <good>
156
+ ## Decisions to Make
157
+ - [ ] Rate limit storage: Redis (shared across instances) vs in-memory (simpler, single-instance only)?
158
+ - [ ] Limit granularity: per-IP vs per-user-token vs both?
159
+ - [ ] Response on limit: 429 with Retry-After header vs 429 with custom error body?
160
+ Why good: Specific, actionable decisions with concrete options derived from the codebase.
161
+ </good>
162
+
163
+ <bad>
164
+ ## Decisions to Make
165
+ - [ ] What technology to use?
166
+ - [ ] How to implement it?
167
+ - [ ] What approach is best?
168
+ Why bad: Vague decisions that could apply to literally any change. Not useful.
169
+ </bad>
170
+ </examples>
83
171
 
84
- 4. **Create design.md**
172
+ 5. **Create design.md**
85
173
 
86
- Write to `<path>/design.md`:
174
+ Write to `<path>/design.md`. Skip the trade-off matrix for simple changes:
87
175
 
88
176
  ```markdown
89
177
  ## Approach
90
178
 
91
- [Chosen technical direction — 2-3 sentences on the high-level strategy]
179
+ [Chosen technical direction — 2-3 sentences grounded in the actual codebase]
92
180
 
93
181
  ## Trade-off Matrix
94
182
 
@@ -104,29 +192,27 @@ When ready to implement, run `/whyspec-execute`
104
192
  ## Questions to Resolve
105
193
 
106
194
  - [ ] [Open question needing an answer before or during coding]
107
- - [ ] [Another open question]
108
195
 
109
196
  ## Risks & Unknowns
110
197
 
111
198
  - [What could go wrong]
112
- - [What we don't know yet]
113
199
 
114
200
  ## Dependencies
115
201
 
116
- - [External libraries, APIs, services, other teams' work]
202
+ - [External libraries, APIs, services]
117
203
  ```
118
204
 
119
- 5. **Create tasks.md**
205
+ 6. **Create tasks.md**
120
206
 
121
- Write to `<path>/tasks.md`. **Define verification FIRST** — goal-backward planning means you know what success looks like before listing tasks:
207
+ Write to `<path>/tasks.md`. Define verification FIRST — goal-backward planning:
122
208
 
123
209
  ```markdown
124
210
  ## Verification
125
211
 
126
212
  What proves this change works — defined BEFORE tasks:
127
213
 
128
- - [ ] [Verification criterion 1 — e.g., "all auth tests pass"]
129
- - [ ] [Verification criterion 2 — e.g., "login flow works end-to-end"]
214
+ - [ ] [Verification criterion 1]
215
+ - [ ] [Verification criterion 2]
130
216
 
131
217
  ## Tasks
132
218
 
@@ -134,15 +220,11 @@ When ready to implement, run `/whyspec-execute`
134
220
  verify: [how to verify this specific task]
135
221
  - [ ] Task 2: [description]
136
222
  verify: [verification step]
137
- - [ ] Task 3: [description]
138
- verify: [verification step]
139
223
  ```
140
224
 
141
- Each task should be small enough for one atomic commit. Include a `verify:` line where meaningful.
225
+ Each task should be small enough for one atomic commit.
142
226
 
143
- 6. **Show summary**
144
-
145
- Display:
227
+ 7. **Show summary**
146
228
 
147
229
  ```
148
230
  ## Plan Created: <name>
@@ -153,18 +235,97 @@ When ready to implement, run `/whyspec-execute`
153
235
  tasks.md — WHAT: verification criteria + implementation checklist
154
236
 
155
237
  Decisions to make: N pending
156
- Questions to resolve: N open
157
238
  Tasks: N defined
158
239
 
159
- Ready to implement? Run /whyspec-execute
240
+ Ready to implement? Run /whyspec:execute
160
241
  ```
161
242
 
162
- **Guardrails**
243
+ ## Tools
244
+
245
+ | Tool | When to use | When NOT to use |
246
+ |------|------------|-----------------|
247
+ | **Glob** | Find files by pattern before writing plan (e.g., `src/middleware/**/*.ts`) | Don't glob blindly — know what area you're looking for |
248
+ | **Grep** | Search for patterns in code (e.g., existing rate limit logic, auth middleware) | Don't grep the whole repo — scope to relevant dirs |
249
+ | **Read** | Read specific files to understand architecture before planning | Don't read files unrelated to the change |
250
+ | **Bash** | Run `whyspec plan --json` (CLI-as-oracle). Run `git log` to understand recent changes | Don't run destructive commands |
251
+ | **AskUserQuestion** | ONLY when ARGUMENTS is empty or genuinely ambiguous (see format below) | Don't ask questions answerable by reading code |
252
+
253
+ ### Codebase First, Web Never-First
254
+
255
+ Read the codebase BEFORE considering web search. Web search is justified ONLY when:
256
+ - The change involves a library/framework not present in the codebase
257
+ - You need version-specific migration docs
258
+ - Security advisory lookup (CVEs)
259
+
260
+ Never search the web for: architecture decisions, "best practices", or how to use a library already in the codebase.
261
+
262
+ ### AskUserQuestion Format (use sparingly)
263
+
264
+ When you MUST ask (ARGUMENTS empty, or genuinely stuck after codebase exploration):
265
+
266
+ 1. **Re-ground**: "Planning **<change>** in `<project>` on `<branch>`"
267
+ 2. **What you found**: Show what you already discovered in the codebase
268
+ 3. **One specific question**: Not a checklist. One thing you need.
269
+ 4. **Recommendation**: "I'd suggest X because Y — your call"
270
+
271
+ <examples>
272
+ <good>
273
+ Planning **add-rate-limiting** in `my-api` on `main`
274
+
275
+ I found Express 4.18 with helmet middleware at src/middleware/index.ts,
276
+ and an existing ioredis client at src/lib/redis.ts.
277
+
278
+ Should the rate limit apply globally (all routes) or only to /api/* routes?
279
+ I'd suggest /api/* only — internal health checks shouldn't be rate-limited.
280
+ Why good: Shows what was already found. Asks ONE specific question with a recommendation.
281
+ </good>
282
+
283
+ <bad>
284
+ What problem does this solve? What constraints exist? How will you know it works?
285
+ Why bad: Three generic questions. No codebase context. Classic checklist-walking.
286
+ </bad>
287
+ </examples>
288
+
289
+ ## Escalation Protocol
290
+
291
+ If you hit any of these, STOP and ask the user (max 3 attempts before escalating):
292
+
293
+ | Situation | Action |
294
+ |-----------|--------|
295
+ | ARGUMENTS is genuinely ambiguous after codebase exploration | Ask ONE specific question, not a checklist |
296
+ | Multiple valid architectures with no clear winner | Present the trade-off matrix, ask user to pick |
297
+ | Change requires access or knowledge you don't have | State what you know, what you need, and ask |
298
+ | After 3 failed attempts to infer intent | Escalate: "I need more context. Here's what I've found so far: [findings]" |
299
+
300
+ ## Guardrails
163
301
 
164
- - **Ask forcing questions FIRST** — never create files before asking. The questions shape the plan quality.
165
- - **Don't implement code** — this skill creates plan files only. Implementation happens in `/whyspec-execute`.
166
- - **Don't skip "Decisions to Make"** — every unsettled design choice must be a checkbox. These are the Decision Bridge. If the user hasn't mentioned trade-offs, ask: "What decisions haven't been made yet?"
302
+ - **Don't interrogate the user** — if ARGUMENTS contains a meaningful description, proceed. Only ask when ARGUMENTS is empty or genuinely ambiguous.
303
+ - **Ground plans in the codebase** — read relevant code before writing. Plans that ignore the actual architecture are useless.
304
+ - **Don't implement code** — this skill creates plan files only. Implementation happens in `/whyspec:execute`.
305
+ - **Don't skip "Decisions to Make"** — every unsettled design choice must be a checkbox. If you can't find any decisions, you haven't thought hard enough about the change.
167
306
  - **Use CLI-as-oracle** — always call `whyspec plan --json` to create the folder. Don't create paths or generate IDs manually.
168
307
  - **Apply `context` and `rules` as constraints** — they guide your writing but must NOT appear in the output files.
169
- - **Verification before tasks** — in tasks.md, define what "done" looks like before listing the work to do.
170
- - **Don't over-design** — if the user describes a small fix, create proportionally small plan files. Not every change needs a full trade-off matrix.
308
+ - **Verification before tasks** — in tasks.md, define what "done" looks like before listing the work.
309
+ - **Scale to the change** — a typo fix gets a 3-line intent and 1 task. A major refactor gets the full treatment.
310
+
311
+ ## Rationalization Table
312
+
313
+ | If you catch yourself thinking... | Reality |
314
+ |----------------------------------|---------|
315
+ | "I should ask the user some clarifying questions first" | Read the codebase. Most "clarifying questions" can be answered by reading code. |
316
+ | "The user's description is too vague to plan" | Even "fix auth" is plannable — read the auth code, find the issues, plan the fix. |
317
+ | "I need to understand the full architecture before planning" | Plan the change, not the universe. Read what's relevant, skip what's not. |
318
+ | "I should create a comprehensive plan with all sections" | Scale to the change. A 1-line fix gets a 3-line plan. Don't over-engineer. |
319
+ | "Let me ask about success criteria" | Infer from the change. "Success = tests pass + the thing works." Write it yourself. |
320
+ | "I'll write generic placeholder text and the user can fill it in" | That's not planning. Populate every field with specific, codebase-grounded content. |
321
+
322
+ ## Anti-Patterns
323
+
324
+ | If you're about to... | STOP — do this instead |
325
+ |----------------------|----------------------|
326
+ | Ask "What problem does this solve?" | Read ARGUMENTS — the user just told you |
327
+ | Ask "What constraints exist?" | Explore the codebase — find the constraints yourself |
328
+ | Ask "Who is this for?" | This is a code change, not a product pitch |
329
+ | Write a generic plan without reading code | Read the affected files first |
330
+ | Create a massive plan for a small fix | Scale the plan to match the change size |
331
+ | Skip Decisions to Make because "it's obvious" | If it's obvious, write it down — it takes 10 seconds |