@brunosps00/dev-workflow 1.0.0 → 1.0.2

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.
Files changed (36) hide show
  1. package/README.md +18 -9
  2. package/lib/constants.js +10 -6
  3. package/lib/init.js +28 -0
  4. package/package.json +1 -1
  5. package/scaffold/en/agent-instructions.md +28 -3
  6. package/scaffold/en/commands/dw-analyze-project.md +64 -0
  7. package/scaffold/en/commands/dw-autopilot.md +64 -5
  8. package/scaffold/en/commands/dw-brainstorm.md +166 -23
  9. package/scaffold/en/commands/dw-bugfix.md +124 -26
  10. package/scaffold/en/commands/dw-intel.md +30 -3
  11. package/scaffold/en/commands/dw-pause.md +92 -0
  12. package/scaffold/en/commands/dw-qa.md +87 -11
  13. package/scaffold/en/commands/dw-resume.md +90 -0
  14. package/scaffold/en/commands/dw-review.md +22 -12
  15. package/scaffold/en/templates/bugfix-summary-template.md +66 -0
  16. package/scaffold/en/templates/concerns-template.md +59 -0
  17. package/scaffold/en/templates/state-template.md +59 -0
  18. package/scaffold/pt-br/agent-instructions.md +28 -3
  19. package/scaffold/pt-br/commands/dw-analyze-project.md +64 -0
  20. package/scaffold/pt-br/commands/dw-autopilot.md +64 -5
  21. package/scaffold/pt-br/commands/dw-brainstorm.md +166 -23
  22. package/scaffold/pt-br/commands/dw-bugfix.md +134 -18
  23. package/scaffold/pt-br/commands/dw-intel.md +30 -3
  24. package/scaffold/pt-br/commands/dw-pause.md +92 -0
  25. package/scaffold/pt-br/commands/dw-qa.md +87 -11
  26. package/scaffold/pt-br/commands/dw-resume.md +90 -0
  27. package/scaffold/pt-br/commands/dw-review.md +22 -12
  28. package/scaffold/pt-br/templates/bugfix-summary-template.md +66 -0
  29. package/scaffold/pt-br/templates/concerns-template.md +59 -0
  30. package/scaffold/pt-br/templates/state-template.md +59 -0
  31. package/scaffold/skills/dw-codebase-intel/SKILL.md +9 -5
  32. package/scaffold/skills/dw-codebase-intel/references/query-patterns.md +52 -0
  33. package/scaffold/skills/dw-memory/SKILL.md +26 -1
  34. package/scaffold/skills/dw-memory/references/context-budget.md +63 -0
  35. package/scaffold/skills/dw-simplification/SKILL.md +10 -5
  36. package/scaffold/skills/dw-simplification/references/deep-modules.md +105 -0
@@ -11,14 +11,34 @@ You are a brainstorming facilitator for the current workspace. This command exis
11
11
  ## Pipeline Position
12
12
  **Predecessor:** (user idea) | **Successor:** `/dw-plan prd`
13
13
 
14
- ## Flags
14
+ ## How this command works (auto-dispatch, not flag switchboard)
15
15
 
16
- - **(default)**: normal brainstorm with 3-7 options (conservative, balanced, bold) and trade-offs. If the product has PRDs or rules, a **Product Inventory** is produced automatically and each option carries a classification tag.
17
- - **`--onepager`**: at the end of the brainstorm, generate a durable one-pager at `.dw/spec/ideas/<slug>.md` (using `.dw/templates/idea-onepager.md`) with Feature Inventory + Classification & Rationale + MVP Scope + Not Doing + Assumptions. Use when you want a persisted product artifact before moving to `/dw-plan prd`.
18
- - **`--council`**: after the normal brainstorm, invoke the `dw-council` skill to stress-test the top 2-3 options via 3-5 archetypes (pragmatic-engineer, architect-advisor, security-advocate, product-mind, devils-advocate). Useful when the choice is high-impact and there is genuine dissent between paths.
19
- - **`--research`**: heavyweight multi-source research mode. Pipeline: scope → plan → retrieve (parallel sources) → triangulate → outline-refine → synthesize → critique → refine → report. Output: cited research document. Use for state-of-the-art reviews, technology comparisons, regulatory landscape mapping. Sub-modes: `quick` (3 phases, 2-5min), `standard` (default, 6 phases, 5-10min), `deep` (8 phases, 10-20min), `ultradeep` (8+ phases, 20-45min).
20
- - **`--refactor`**: code-smell catalog mode. Audits a target directory or PRD scope for code smells using Martin Fowler's taxonomy (bloaters, change preventers, dispensables, couplers, conditional complexity, DRY violations). Maps each smell to a concrete refactoring technique with before/after sketches. Severity-ordered P0-P3 plan. Output: refactoring opportunities document.
21
- - Flags are composable where it makes sense: `--onepager --council` produces the one-pager after the council debate. `--research --onepager` saves the research output as a durable one-pager. `--refactor --onepager` saves the refactor plan as a durable one-pager. `--research --refactor` is NOT supported (pick one or the other — different ideation surfaces).
16
+ `/dw-brainstorm` runs **FULL** by default. It opens with a **Signal Reading** phase that inspects the user's request, the project state (PRDs, rules, intel, recent commits), and the conversation so far, then **dispatches one or more internal modes**. The user does not pick a mode the command does.
17
+
18
+ Internal modes (the dispatcher picks 1+):
19
+
20
+ | Mode | Auto-fires when |
21
+ |------|-----------------|
22
+ | **option-matrix** (always-on default) | Default surface: 3-7 options (conservative / balanced / bold) with `[IMPROVES] / [CONSOLIDATES] / [NEW]` tags. Always runs unless a hard override says otherwise. |
23
+ | **grill** | Vocabulary feels unsettled — user terms differ from `.dw/rules/` / `.dw/constitution.md`, or two synonyms compete in the same conversation, or a contributor proposes a name that clashes with the glossary. |
24
+ | **prototype** | User asks "is this state model right?" / "what should this look like?" with no clear answer; or the next sensible step is to RUN code, not write words. |
25
+ | **council** | Two or more competing approaches surface with no obvious winner; or consensus forms too quickly (false-consensus signal). |
26
+ | **research** | The question depends on external state-of-the-art ("what's the current best practice for X", multi-source comparisons, regulatory or framework landscape). |
27
+ | **refactor-audit** | User points at a directory or describes a code area as "messy", "needs cleanup", "tech debt"; or a quarterly health-check is requested. |
28
+ | **onepager** | The conversation has converged enough to deserve a durable product artifact (`.dw/spec/ideas/<slug>.md`); or the user signals they're about to call `/dw-plan prd` next. |
29
+
30
+ Modes can chain inside one session — grill can surface a design question that the dispatcher then sends to prototype; refactor-audit can produce findings that the dispatcher sends to council for stress-testing.
31
+
32
+ ### Optional overrides (rarely needed)
33
+
34
+ - **`--mode=<name>`** — force a specific dispatch and skip Signal Reading. Names: `option-matrix`, `grill`, `prototype`, `council`, `research`, `refactor-audit`, `onepager`. Combine with `+` to chain explicitly: `--mode=grill+onepager`.
35
+ - **`--quiet`** — skip Signal Reading entirely and run only `option-matrix` as a minimal facilitator.
36
+
37
+ Power users who already know what they want can pass `--mode=`. Everyone else gets auto-dispatch by default — the command reads the room and acts.
38
+
39
+ ### Migration note (transitional)
40
+
41
+ Old flag invocations (`--onepager`, `--council`, `--research`, `--refactor`, `--grill`, `--prototype`) remain accepted for one minor cycle and map to the equivalent `--mode=` value. New code should use `--mode=` or rely on auto-dispatch.
22
42
 
23
43
  ## Decision Flowchart: Brainstorm vs Direct PRD
24
44
 
@@ -42,15 +62,16 @@ digraph brainstorm_decision {
42
62
 
43
63
  When available in the project under `./.agents/skills/`, use these skills to enrich ideation:
44
64
 
45
- - `dw-council` (opt-in via `--council`): multi-advisor stress-test of the most promising options with mandatory steel-manning and concession tracking. **DO NOT invoke by default** — only when the flag is present or when consensus forms too quickly (false-consensus signal).
46
- - `dw-ui-discipline`: use when brainstorming involves frontend or UI direction its hard-gate (scene sentence, surface job) is a generative forcing function during ideation, not just a review check
47
- - `vercel-react-best-practices`: use when brainstorming React/Next.js architecture or performance trade-offs
48
- - `security-review`: use when brainstorming touches auth, data handling, or security-sensitive features
65
+ - `dw-council`: invoked by the dispatcher's **council** mode — multi-advisor stress-test of the most promising options with mandatory steel-manning and concession tracking. The dispatcher fires it when 2+ paths tie OR consensus forms too quickly (false-consensus signal). Not invoked on every brainstorm — only when signals justify it.
66
+ - `dw-simplification`: invoked by the dispatcher's **refactor-audit** mode applies Chesterton's Fence + complexity metrics + the new **deep-modules** reference (deletion test, locality, leverage, interface depth) to every flagged smell.
67
+ - `dw-ui-discipline`: use when brainstorming involves frontend or UI direction — its hard-gate (scene sentence, surface job) is a generative forcing function during ideation, not just a review check. Also picked up by the **prototype** mode's UI branch.
68
+ - `vercel-react-best-practices`: use when brainstorming React/Next.js architecture or performance trade-offs.
69
+ - `security-review`: use when brainstorming touches auth, data handling, or security-sensitive features.
49
70
 
50
71
  ## Template Reference
51
72
 
52
73
  - Brainstorm matrix template: `.dw/templates/brainstorm-matrix.md` (relative to workspace root)
53
- - Durable one-pager template: `.dw/templates/idea-onepager.md` (used with `--onepager` flag)
74
+ - Durable one-pager template: `.dw/templates/idea-onepager.md` (used by the **onepager** mode)
54
75
 
55
76
  Use this command when the user wants to:
56
77
  - Generate ideas for product, UX, architecture, or automation
@@ -63,6 +84,19 @@ Use this command when the user wants to:
63
84
 
64
85
  <critical>The brainstorm is a **product-level** phase, not technical. DO NOT dive into architecture, stack, endpoints, schemas. That's the techspec's job. Here we work user journeys, value, features, and boundaries.</critical>
65
86
 
87
+ ### 0. Signal Reading (always first, unless `--quiet` or explicit `--mode=`)
88
+
89
+ Before producing any output, **read the situation**:
90
+
91
+ 1. Inspect `.dw/spec/prd-*/`, `.dw/rules/`, `.dw/constitution.md`, `.dw/intel/` if they exist. Note the project's current vocabulary and recent PRDs.
92
+ 2. Inspect recent git activity (`git log --oneline -20`) to detect ongoing work.
93
+ 3. Re-read the user's request against the Auto-Dispatch table at the top of this file. Match signals to modes.
94
+ 4. Decide the dispatch: **option-matrix** always runs unless an explicit mode override skips it. Other modes (grill, prototype, council, research, refactor-audit, onepager) fire **additively** when their signals are present.
95
+ 5. State the dispatch decision to the user in one short line: e.g., "Dispatching: option-matrix + onepager (PRD is one step away)" or "Dispatching: grill (vocabulary unsettled in current PRD)". Do not bury this — surface it before running.
96
+ 6. Then proceed with the modes in this order (when chained): grill → research → option-matrix → council → refactor-audit → prototype → onepager. Skip modes not in the dispatch.
97
+
98
+ ### Standard flow (option-matrix mode)
99
+
66
100
  1. Start by summarizing the problem in 1 to 3 sentences.
67
101
  2. **Reframe as "How Might We"**: turn the raw idea into `How might we [verb] for [user] so that [outcome]?`. This pulls the team out of premature "solution mode".
68
102
  3. **Product Inventory (required if the product exists)**:
@@ -80,7 +114,7 @@ Use this command when the user wants to:
80
114
  - Approximate effort level
81
115
  7. Whenever it makes sense, include conservative, balanced, and bold alternatives.
82
116
  8. Close with a pragmatic recommendation and clear next steps.
83
- 9. **If the `--onepager` flag is present**: at the end, generate `.dw/spec/ideas/<slug>.md` using `.dw/templates/idea-onepager.md`, filling Feature Inventory, Classification & Rationale, Recommended Direction (product language), MVP Scope (user stories), Not Doing, Key Assumptions, and Open Questions. Report the path to the user.
117
+ 9. **If the dispatcher selected `onepager` mode** (auto-fires when conversation has converged enough, or user signals they're heading to `/dw-plan prd` next): at the end, generate `.dw/spec/ideas/<slug>.md` using `.dw/templates/idea-onepager.md`, filling Feature Inventory, Classification & Rationale, Recommended Direction (product language), MVP Scope (user stories), Not Doing, Key Assumptions, and Open Questions. Report the path to the user.
84
118
 
85
119
  ## Preferred Response Format
86
120
 
@@ -104,7 +138,7 @@ Use this command when the user wants to:
104
138
  - Recommend 1 or 2 paths
105
139
  - Explain why they win in the current context
106
140
 
107
- ### 6. One-pager (if `--onepager`)
141
+ ### 6. One-pager (if `onepager` mode fired)
108
142
  - Path of the created file at `.dw/spec/ideas/<slug>.md`
109
143
 
110
144
  ### 7. Next Steps
@@ -141,13 +175,15 @@ At the end, always leave the user in one of these situations:
141
175
  - With a clear recommendation (including an IMPROVES/CONSOLIDATES/NEW classification)
142
176
  - With better questions to decide
143
177
  - With a next workspace command to follow
144
- - With the one-pager at `.dw/spec/ideas/<slug>.md` (if `--onepager` was used)
145
- - With the research report at `~/Documents/<Topic>_Research_<date>/` (if `--research`)
146
- - With the refactor plan at `<target>/refactor-plan.md` (if `--refactor`)
178
+ - With the one-pager at `.dw/spec/ideas/<slug>.md` (if **onepager** mode fired)
179
+ - With the research report at `~/Documents/<Topic>_Research_<date>/` (if **research** mode fired)
180
+ - With the refactor plan at `<target>/refactor-plan.md` (if **refactor-audit** mode fired)
181
+ - With sharpened glossary entries in `.dw/rules/` (if **grill** mode fired)
182
+ - With a runnable throwaway prototype + verdict template (if **prototype** mode fired)
147
183
 
148
- ## Mode: `--research` (multi-source research)
184
+ ## Mode: research (multi-source research)
149
185
 
150
- Activated by the `--research` flag. Replaces the default brainstorm with a structured research pipeline that produces a cited document with verified claims.
186
+ Fires when the question depends on external state-of-the-art (multi-source comparisons, framework / regulatory landscape, decisions needing cited evidence). Override: `--mode=research`. Replaces the default option-matrix with a structured research pipeline that produces a cited document with verified claims.
151
187
 
152
188
  <critical>Every factual claim MUST be cited immediately with [N] in the same sentence</critical>
153
189
  <critical>NEVER fabricate citations — if no source is found, say so explicitly</critical>
@@ -165,7 +201,7 @@ Activated by the `--research` flag. Replaces the default brainstorm with a struc
165
201
  ```
166
202
  Selection
167
203
  ├── Initial exploration → quick (3 phases, 2-5 min)
168
- ├── Standard research → standard (6 phases, 5-10 min) [DEFAULT for --research]
204
+ ├── Standard research → standard (6 phases, 5-10 min) [DEFAULT for research]
169
205
  ├── Critical decision → deep (8 phases, 10-20 min)
170
206
  └── Comprehensive review → ultradeep (8+ phases, 20-45 min)
171
207
  ```
@@ -216,9 +252,9 @@ Target lengths: quick 2-4k words; standard 4-8k; deep 8-15k; ultradeep 15-20k+.
216
252
  - Label speculation explicitly.
217
253
  - Admit uncertainty: "No sources found for X."
218
254
 
219
- ## Mode: `--refactor` (code-smell catalog)
255
+ ## Mode: refactor-audit (code-smell catalog + deep-modules)
220
256
 
221
- Activated by the `--refactor` flag. Audits a target codebase area for refactoring opportunities using Martin Fowler's smell taxonomy.
257
+ Fires when the user points at a directory or describes a code area as "messy" / "needs cleanup" / "tech debt", or when a quarterly health-check is requested. Override: `--mode=refactor-audit`. Audits the target area for refactoring opportunities using Martin Fowler's smell taxonomy combined with the deep-modules analysis (deletion test, locality, leverage, interface depth) bundled in the `dw-simplification` skill.
222
258
 
223
259
  <critical>ASK EXACTLY 3 CLARIFICATION QUESTIONS BEFORE STARTING THE ANALYSIS</critical>
224
260
 
@@ -292,6 +328,111 @@ Saved to `<target>/refactor-plan.md`:
292
328
  - Proposing refactors that aren't tested or testable → high risk, won't ship.
293
329
  - Ignoring documented architectural decisions in `.dw/rules/` → flagging intentional design as smell.
294
330
 
331
+ ## Mode: grill (domain-grilling)
332
+
333
+ Fires when vocabulary feels unsettled — user terms differ from `.dw/rules/` / `.dw/constitution.md`, two synonyms compete in the same conversation, or a contributor proposes a name that clashes with the glossary. Override: `--mode=grill`. Replaces the option-generation default with an **interview-style stress-test** of the plan/PRD against the project's domain vocabulary. Each round of questions sharpens one piece. Updates `.dw/rules/` (or `.dw/constitution.md`) inline as terms crystallize — never deferred to "after the conversation."
334
+
335
+ <critical>Ask ONE question at a time. Wait for the answer. Don't dump a list of 5 questions and hope for the best.</critical>
336
+
337
+ ### When to use grill mode
338
+
339
+ - Before `/dw-plan prd` when the domain feels unsettled or the team uses competing terms.
340
+ - After `/dw-plan prd` when reviewers flag ambiguous language in the PRD.
341
+ - During architectural discussion when "module", "service", "component" are being used interchangeably and you need to pin the canonical term.
342
+ - When a contributor proposes a name that doesn't match the project's existing glossary.
343
+
344
+ ### During-session disciplines
345
+
346
+ 1. **Challenge against the glossary.** Read `.dw/rules/index.md` + per-module `.dw/rules/<module>.md` + `.dw/constitution.md`. Flag terminology conflicts the instant the user uses a term that differs from (or contradicts) what's already documented.
347
+
348
+ 2. **Sharpen fuzzy language.** When the user says "the user thing" or "the order stuff", propose a precise canonical term. Don't pretend you understood — push back.
349
+
350
+ 3. **Discuss concrete scenarios.** Force precision via specific edge cases: "What happens to the Order in state X when event Y arrives during retry Z?" Vague answers go back as further questions.
351
+
352
+ 4. **Cross-reference code.** When the user states a behavior, glance at the codebase to confirm it. Surface contradictions: "You said the API returns `OrderId` but `src/api/orders.ts:42` returns `{ order_id, status }`." Don't argue from generalities.
353
+
354
+ 5. **Update `.dw/rules/` inline.** When a term crystallizes, write it into the appropriate rules file in the same conversation turn. Lazy file creation: if the file doesn't exist, create it. Format follows the glossary discipline established by the project (see `.dw/rules/index.md` for shape).
355
+
356
+ 6. **Skip implementation details in the glossary.** `.dw/rules/` and `.dw/constitution.md` describe vocabulary and principles — not implementation. "Order: a customer's request to purchase one or more items, in one of these states: pending, paid, shipped, delivered, refunded" is fine. "Order: a TypeScript class in `src/orders/`" is implementation leak.
357
+
358
+ ### ADR creation discipline
359
+
360
+ Only propose an ADR via `/dw-adr` when **all three** hold:
361
+
362
+ | Criterion | Test |
363
+ |-----------|------|
364
+ | **Hard to reverse** | If we change this in 6 months, does it cost >1 week of work? |
365
+ | **Surprising without context** | Would a new contributor reasonably reach a different decision? |
366
+ | **Genuine trade-off** | Was there a real alternative we considered and chose against? |
367
+
368
+ If any is missing, skip the ADR. Don't ADR every casual decision — that turns the ADR folder into noise.
369
+
370
+ ### Output
371
+
372
+ grill mode produces:
373
+ - **Updated `.dw/rules/<module>.md`** or `.dw/constitution.md` with crystallized terms.
374
+ - **Updated PRD / TechSpec** if grilling happens mid-plan (terms in the artifact are aligned with the glossary).
375
+ - **Optional `.dw/spec/<prd>/adrs/adr-NNN.md`** if criteria above hold.
376
+ - **NO** option matrix or recommendation (that's option-matrix mode; grill is purely about sharpening). If the dispatcher chained grill+option-matrix, the option matrix runs in a separate phase.
377
+
378
+ ### When the discipline bends
379
+
380
+ - **Greenfield project with no `.dw/rules/`**: grill anyway; the conversation produces the FIRST entries in `.dw/rules/index.md`. That's the value.
381
+ - **Cosmetic terminology disagreements** ("should we call it `userId` or `user_id`?"): skip grill mode; use a coding-conventions ADR or `.dw/rules/index.md` Naming section.
382
+
383
+ ## Mode: prototype (throwaway prototype)
384
+
385
+ Fires when the user asks "is this state model right?" / "what should this look like?" with no clear answer — i.e., the next sensible step is to RUN code, not write words. Override: `--mode=prototype`. Builds a **throwaway prototype that answers a single question**. The question decides the shape — pick a branch.
386
+
387
+ <critical>The prototype is throwaway from day one. Don't polish. Don't add tests. Don't extract abstractions. The point is to LEARN something fast and then DELETE or absorb.</critical>
388
+
389
+ ### Pick a branch
390
+
391
+ | User's question | Branch |
392
+ |-----------------|--------|
393
+ | "Does this state/logic model feel right?" | **LOGIC** — interactive terminal app that pushes the state machine through edge cases that are hard to reason about on paper. |
394
+ | "What should this look like?" | **UI** — several radically different UI variations on a single route, switchable via a URL search param and a floating bottom bar. |
395
+
396
+ If the question is ambiguous, ask the user. If user not reachable: default by surrounding code (backend module → LOGIC; page/component → UI) and state the assumption at the top of the prototype.
397
+
398
+ ### Rules (apply to both branches)
399
+
400
+ 1. **Throwaway from day one, clearly marked.** Place the prototype next to the module/page it's prototyping for (so context is obvious) but name it so a casual reader can see it's a prototype (`prototype-<slug>.ts`, `prototype-route.tsx`, etc.).
401
+
402
+ 2. **One command to run.** Whatever the project's task runner supports — `pnpm <name>`, `python <path>`, `bun <path>`, etc. The user must start it without thinking.
403
+
404
+ 3. **No persistence by default.** State lives in memory. Persistence is what the prototype is CHECKING, not what it depends on. If the question explicitly involves a database, hit a scratch DB or a local file with a clear `PROTOTYPE — wipe me` name.
405
+
406
+ 4. **Skip the polish.** No tests, no error handling beyond what makes the prototype runnable, no abstractions.
407
+
408
+ 5. **Surface the state.** After every action (LOGIC) or on every variant switch (UI), print or render the full relevant state so the user can see what changed.
409
+
410
+ 6. **Delete or absorb when done.** When the prototype has answered its question, either delete it or fold the validated decision into real code. Don't leave it rotting in the repo.
411
+
412
+ ### When done
413
+
414
+ The **answer** is the only thing worth keeping. Capture it durably:
415
+ - Commit message that closes the prototype: "removed prototype X; decided <answer> based on <observation>"
416
+ - Or an ADR (if the criteria from grill mode hold)
417
+ - Or `.dw/spec/<prd>/NOTES.md` if mid-PRD
418
+ - Or an issue comment if user-driven
419
+
420
+ If the user isn't around, leave a `PROTOTYPE VERDICT: <pending>` placeholder so the next pass can fill it in before deletion.
421
+
422
+ ### Output
423
+
424
+ prototype mode produces:
425
+ - **Throwaway code file(s)** in the appropriate location.
426
+ - A `NOTES.md` next to the prototype with the QUESTION it's answering.
427
+ - After the user runs it and answers the question, instructions to remove the prototype + capture the verdict.
428
+
429
+ ### Anti-patterns
430
+
431
+ - Building a prototype that's actually a feature in disguise — production-quality code, tests, deployment config. That's not a prototype; it's a first draft.
432
+ - Leaving the prototype in the repo "in case we need it later" — six months later it's load-bearing.
433
+ - Not capturing the verdict — the prototype answered the question and the answer evaporated.
434
+ - Multiple prototypes stacked up at once — pick one question, answer it, move.
435
+
295
436
  ## Inspired by
296
437
 
297
438
  The codebase-grounded idea refinement pattern is inspired by [`addyosmani/agent-skills@idea-refine`](https://skills.sh/addyosmani/agent-skills/idea-refine) (Addy Osmani, Google — 1.4K+ installs). Adaptations for dev-workflow:
@@ -301,6 +442,8 @@ The codebase-grounded idea refinement pattern is inspired by [`addyosmani/agent-
301
442
  - Output at `.dw/spec/ideas/<slug>.md` (sibling of `prd-<slug>/`) instead of `docs/ideas/` — preserves dev-workflow path conventions.
302
443
  - Integration with the existing pipeline: `/dw-plan prd` accepts the one-pager as input, reducing clarification questions.
303
444
 
304
- Credit: Addy Osmani and the `idea-refine` pattern.
445
+ The **grill** and **prototype** modes are adapted from [`mattpocock/skills/grill-with-docs`](https://github.com/mattpocock/skills/tree/main/grill-with-docs) and [`mattpocock/skills/prototype`](https://github.com/mattpocock/skills/tree/main/prototype) (Matt Pocock, MIT). dev-workflow adaptation: integrated as INTERNAL auto-dispatched modes rather than separate skills, paths rebased on `.dw/rules/` + `.dw/spec/<prd>/`, ADR creation gated on the 3-criteria test (hard-to-reverse + surprising + genuine trade-off).
446
+
447
+ Credit: Addy Osmani (idea-refine) and Matt Pocock (grill-with-docs, prototype).
305
448
 
306
449
  </system_instructions>
@@ -9,7 +9,30 @@
9
9
  - Do NOT use when fixing bugs found during QA testing (use `/dw-qa --fix` instead)
10
10
 
11
11
  ## Pipeline Position
12
- **Predecessor:** (bug report) | **Successor:** `/dw-commit` then `/dw-generate-pr`
12
+ **Predecessor:** (bug report) | **Successor:** `/dw-commit` then `/dw-generate-pr` (optionally `/dw-review --bugfix <slug>` and `/dw-qa --bugfix <slug>` in between for additional rigor)
13
+
14
+ ## File Locations
15
+
16
+ Every bugfix has an index entry in `.dw/bugfixes/`. Direct mode keeps the full artifact there. Analysis mode and safety-valve escalations split: the index entry stays in `.dw/bugfixes/`, but the `prd.md` that `/dw-plan` will consume lands in `.dw/spec/prd-bugfix-<slug>/` (the path `/dw-plan techspec` and `/dw-plan tasks` already expect).
17
+
18
+ **Index home — always created:**
19
+
20
+ - Bugfix index directory: `.dw/bugfixes/NNN-<slug>/` (NNN zero-padded to 3 digits, sequential across all bugfixes ever recorded)
21
+ - Direct-mode artifacts written here: `TASK.md` (triage + plan), `fix-report.md` (verify evidence), `SUMMARY.md` (one-page record)
22
+ - Analysis / escalation artifacts written here: `TASK.md` (triage + would-be plan), `escalated.md` (one line pointing to the spec directory that took over)
23
+ - Downstream review output (when `/dw-review --bugfix <slug>` runs): `.dw/bugfixes/NNN-<slug>/review/`
24
+ - Downstream QA output (when `/dw-qa --bugfix <slug>` runs): `.dw/bugfixes/NNN-<slug>/QA/`
25
+
26
+ **Spec home — created only on Analysis or safety-valve escalation:**
27
+
28
+ - Spec directory: `.dw/spec/prd-bugfix-<slug>/`
29
+ - `prd.md` lives here (NOT in `.dw/bugfixes/`) so `/dw-plan techspec prd-bugfix-<slug>` and `/dw-plan tasks prd-bugfix-<slug>` operate against the path they were designed for, with no modification to `/dw-plan`.
30
+
31
+ **Templates:** `.dw/templates/bugfix-template.md` (for `TASK.md`/`prd.md`), `.dw/templates/bugfix-summary-template.md` (for `SUMMARY.md`), `.dw/templates/pr-bugfix-template.md` (for the PR body).
32
+
33
+ **Next-number discovery:** list `.dw/bugfixes/`, parse the leading 3-digit prefix of each directory, take `max + 1` (or `1` if empty). Create the directory before writing anything. The same `NNN-<slug>` is used to name the spec directory's slug portion (e.g., bugfix `007-stripe-webhook-retry` escalates to spec `.dw/spec/prd-bugfix-stripe-webhook-retry/`).
34
+
35
+ **Slug:** kebab-case derived from `{{BUG_DESCRIPTION}}` (e.g., "login-not-working", "error-500-save-user").
13
36
 
14
37
  ## Complementary Skills
15
38
 
@@ -34,23 +57,23 @@
34
57
 
35
58
  | Mode | When to Use | Result |
36
59
  |------|-------------|--------|
37
- | **Direct** (default) | Simple bug, <=5 files, no migration | Executes immediate fix |
38
- | **Analysis** (`--analysis`) | Complex bug, needs planning | Generates `tasks/dw-bugfix-*/prd.md` for techspec -> tasks |
60
+ | **Direct** (default) | Simple bug, <=5 files, no migration, <=5 numbered tasks | Executes immediate fix; persists `TASK.md` + `fix-report.md` + `SUMMARY.md` in `.dw/bugfixes/NNN-<slug>/` |
61
+ | **Analysis** (`--analysis`) | Complex bug, needs planning | Splits: `.dw/bugfixes/NNN-<slug>/{TASK.md, escalated.md}` as the index entry + `.dw/spec/prd-bugfix-<slug>/prd.md` for the techspec -> tasks pipeline |
39
62
 
40
63
  ### Analysis Mode
41
64
 
42
- When the user specifies `--analysis` or when you detect the bug needs more planning:
65
+ When the user specifies `--analysis` or when the safety valve (step 5.0) trips:
43
66
 
44
67
  ```
45
68
  bugfix my-project "Login not working" --analysis
46
69
  ```
47
70
 
48
71
  In this mode:
49
- 1. Follow the normal question and analysis flow
50
- 2. Instead of executing, generate a document at `.dw/spec/dw-bugfix-[name]/prd.md`
51
- 3. The file is named `prd.md` to maintain compatibility with the create-techspec/dw-plan tasks pipeline
52
- 4. Then the user can run `create-techspec .dw/spec/dw-bugfix-[name]`
53
- 5. And then `create-tasks .dw/spec/dw-bugfix-[name]`
72
+ 1. Follow the normal question and analysis flow.
73
+ 2. Allocate `NNN` and create `.dw/bugfixes/NNN-<slug>/`. Write `TASK.md` (the triage + clarification answers + the would-be plan that won't run here).
74
+ 3. Create the spec directory `.dw/spec/prd-bugfix-<slug>/` and write `prd.md` there (using `.dw/templates/bugfix-template.md`). This is the path `/dw-plan techspec` and `/dw-plan tasks` already know how to operate against.
75
+ 4. Write `.dw/bugfixes/NNN-<slug>/escalated.md` with exactly one line: `Escalated to /dw-plan on <YYYY-MM-DD> → see .dw/spec/prd-bugfix-<slug>/`. This is the cross-reference that lets `/dw-intel --build` include the bugfix in `bugfixes.json` even though the active planning happens in `.dw/spec/`.
76
+ 5. Tell the user the next commands: `/dw-plan techspec prd-bugfix-<slug>` and `/dw-plan tasks prd-bugfix-<slug>`.
54
77
 
55
78
  ## Workflow
56
79
 
@@ -144,6 +167,27 @@
144
167
  - {{TARGET}}/.dw/rules/*.md
145
168
  ```
146
169
 
170
+ ### 1.5. Load Concerns (Required when concerns.md exists)
171
+
172
+ If `.dw/rules/concerns.md` exists:
173
+ - Read it once.
174
+ - For each file or module referenced in `{{BUG_DESCRIPTION}}` or in the suspected fix area, cross-check against Hot Spots, Fragile Integrations, Hostile Code, and Known Bug History.
175
+ - If a match is found, surface it BEFORE asking the 3 clarification questions:
176
+
177
+ ```
178
+ ## Concern detected
179
+
180
+ The area you're touching is flagged in `.dw/rules/concerns.md`:
181
+
182
+ > [verbatim entry from concerns.md]
183
+
184
+ This means: [translate the concern into what it implies for this fix — extra test, extra reviewer, ADR, etc.]
185
+
186
+ Proceeding — but the fix-report.md must explicitly call out which concern was touched and how it was handled.
187
+ ```
188
+
189
+ If `.dw/rules/concerns.md` is missing, do NOT auto-create it (that's `/dw-analyze-project` Step 9's job). Note in chat: "no concerns map yet — consider running `/dw-analyze-project` after the fix to build one." Continue.
190
+
147
191
  ### 2. Collect Evidence (Required)
148
192
 
149
193
  Execute commands to understand the current state:
@@ -246,6 +290,40 @@
246
290
  - With `--analysis`: Go to step 6
247
291
  - Without `--analysis`: Continue to step 5
248
292
 
293
+ ### 5.0. Safety Valve (MANDATORY before step 5)
294
+
295
+ <critical>
296
+ BEFORE drafting the numbered task list in step 5, sketch the inline steps you intend to write.
297
+ If that sketch reveals **more than 5 distinct numbered tasks**, OR **any cross-file dependency that means tasks must be executed in a specific order**, OR **a task that requires running database migration / refactor / new endpoint / API contract change**, then the bugfix scope was UNDERESTIMATED and you MUST escalate.
298
+ </critical>
299
+
300
+ **Why this exists:** the triage at step 0 catches scope problems from the symptom description. The checkpoint at 4.1 catches them after root cause analysis. This valve catches the remaining case — when the fix itself, once laid out, reveals more complexity than triage and root cause analysis predicted. There is NO bypass flag. Escalation is the correct outcome.
301
+
302
+ **Escalation procedure:**
303
+
304
+ 1. Allocate `NNN` for `.dw/bugfixes/NNN-<slug>/`. Write `TASK.md` with the triage, clarifications, root cause, and the would-be plan.
305
+ 2. Create `.dw/spec/prd-bugfix-<slug>/` and write `prd.md` there (use `.dw/templates/bugfix-template.md`). This is the path `/dw-plan` expects.
306
+ 3. Write `.dw/bugfixes/NNN-<slug>/escalated.md` with: `Escalated to /dw-plan on <YYYY-MM-DD> — reason: <which valve criterion tripped> → see .dw/spec/prd-bugfix-<slug>/`.
307
+ 4. Report to the user:
308
+
309
+ ```
310
+ ## Scope larger than a bugfix
311
+
312
+ Listing the fix produced [N] tasks / [cross-file deps] / [forbidden change type].
313
+ Per the safety valve, this is no longer a surgical bugfix.
314
+
315
+ Bugfix index preserved at `.dw/bugfixes/NNN-<slug>/{TASK.md, escalated.md}`.
316
+ PRD created at `.dw/spec/prd-bugfix-<slug>/prd.md`.
317
+
318
+ Next — pick one:
319
+ - Manual chain: `/dw-plan techspec prd-bugfix-<slug>` → `/dw-plan tasks prd-bugfix-<slug>` → `/dw-run` → `/dw-qa` → `/dw-review` → `/dw-commit` → `/dw-generate-pr`.
320
+ - Hand off to autopilot: `/dw-autopilot --from-prd prd-bugfix-<slug>` — picks up at GATE 1 (PRD approval) and runs the rest automatically with the usual three gates.
321
+ ```
322
+
323
+ 5. Stop this command. Do not proceed to step 5. The user (or autopilot) invokes `/dw-plan` or `/dw-autopilot --from-prd` next.
324
+
325
+ **If the valve does NOT trip:** Continue to step 5.
326
+
249
327
  ### 5. Propose Numbered Tasks (Required)
250
328
 
251
329
  <critical>
@@ -284,14 +362,24 @@
284
362
  - `adjust` - Tell me what to modify in the plan
285
363
  ```
286
364
 
287
- ### 5.5. Final Verification (Direct mode — required before commit)
365
+ ### 5.5. Final Verification + Persistence (Direct mode — required before commit)
288
366
 
289
367
  <critical>After applying the approved tasks in Direct mode, invoke `dw-verify` before committing. The VERIFICATION REPORT must show:
290
368
  1. The project's verify command (test + lint + build) with exit 0.
291
369
  2. Original-symptom reproduction: the scenario that triggered the bug no longer triggers it.
292
-
370
+
293
371
  Without PASS on both, DO NOT commit. Report what failed and return to step 4 (root-cause analysis).</critical>
294
372
 
373
+ **On PASS, persist the bugfix artifact (always — including Direct mode):**
374
+
375
+ 1. Discover the next `NNN` (see File Locations section).
376
+ 2. Create `.dw/bugfixes/NNN-<slug>/` if not yet created in step 5.0.
377
+ 3. Write `TASK.md` with the triage, clarifications, root cause, and the approved plan as executed (use `.dw/templates/bugfix-template.md` as the base structure).
378
+ 4. Write `fix-report.md` with the verbatim `dw-verify` VERIFICATION REPORT plus the before/after reproduction trace.
379
+ 5. Write `SUMMARY.md` using `.dw/templates/bugfix-summary-template.md`. Fill in slug, date, status `Fixed`, severity, related_concerns (from step 1.5), Symptom (verbatim), Root Cause (one sentence), Resolution (2-4 bullets), Files Touched, Verification, Related, Followups.
380
+ 6. If the fix touched a concern listed in `.dw/rules/concerns.md`, append a line to that concern's row's `Last incident` column (or add a new row under Known Bug History) — preserve hand-written entries between `<!-- preserved:start -->` markers.
381
+ 7. Report paths of all three files in chat before the commit step.
382
+
295
383
  ### 6. Generate Bugfix Document (Analysis Mode)
296
384
 
297
385
  <critical>
@@ -301,28 +389,35 @@
301
389
  </critical>
302
390
 
303
391
  **Actions:**
304
- 1. Create directory: `.dw/spec/dw-bugfix-[bug-name]/`
305
- 2. Populate with all information collected in previous steps
306
- 3. Save as: `.dw/spec/dw-bugfix-[bug-name]/prd.md` (uses name `prd.md` for pipeline compatibility)
392
+ 1. Discover the next `NNN` and create `.dw/bugfixes/NNN-<slug>/`.
393
+ 2. Write `TASK.md` in the bugfix dir (the triage, clarifications, root cause, and analysis output) using `.dw/templates/bugfix-template.md` as the base.
394
+ 3. Create `.dw/spec/prd-bugfix-<slug>/` and write `prd.md` there using `.dw/templates/bugfix-template.md`. This is the path `/dw-plan` already understands — no modification to `/dw-plan` needed.
395
+ 4. Write `.dw/bugfixes/NNN-<slug>/escalated.md` with: `Analysis mode on <YYYY-MM-DD> → see .dw/spec/prd-bugfix-<slug>/`.
307
396
 
308
- **Bug name:** Use kebab-case based on the description (e.g., "login-not-working", "error-500-save-user")
397
+ **Bug slug:** kebab-case from the description (e.g., "login-not-working", "error-500-save-user").
309
398
 
310
- **IMPORTANT:** The file must be named `prd.md` (not `bugfix.md`) so that the
311
- `create-techspec` and `create-tasks` commands work without modification, since they expect `prd.md`.
399
+ **Why the split:** `/dw-plan techspec` and `/dw-plan tasks` already hardcode `.dw/spec/prd-<slug>/prd.md` as their input. To keep `/dw-plan` untouched, the PRD lands there; the `.dw/bugfixes/NNN-<slug>/` directory remains the queryable index entry (consumed by `/dw-intel`, `/dw-review --bugfix`, `/dw-qa --bugfix`). The `escalated.md` file is the cross-reference.
312
400
 
313
401
  **Output format:**
314
402
  ```
315
403
  ## Bugfix Document Generated
316
404
 
317
- File created: `.dw/spec/dw-bugfix-[name]/prd.md`
405
+ Bugfix index: `.dw/bugfixes/NNN-<slug>/{TASK.md, escalated.md}`
406
+ Planning PRD: `.dw/spec/prd-bugfix-<slug>/prd.md`
407
+
408
+ **Next steps — pick one:**
409
+
410
+ Option A (manual chain, full control):
411
+ 1. Review `.dw/spec/prd-bugfix-<slug>/prd.md`
412
+ 2. Run: `/dw-plan techspec prd-bugfix-<slug>`
413
+ 3. Run: `/dw-plan tasks prd-bugfix-<slug>`
414
+ 4. Execute tasks with: `/dw-run` (or by task ID against the spec)
318
415
 
319
- **Next steps:**
320
- 1. Review the generated document
321
- 2. Run: `create-techspec .dw/spec/dw-bugfix-[name]`
322
- 3. Run: `create-tasks .dw/spec/dw-bugfix-[name]`
323
- 4. Execute the tasks with: `run-task [number] .dw/spec/dw-bugfix-[name]`
416
+ Option B (hand off to autopilot):
417
+ 1. Run: `/dw-autopilot --from-prd prd-bugfix-<slug>`
418
+ 2. Autopilot picks up at GATE 1 (PRD approval) and runs TechSpec, Tasks, Run, QA, Review, Commit, PR with the usual three gates.
324
419
 
325
- The flow follows the same pattern as a feature/PRD.
420
+ The bugfix index entry stays queryable via `/dw-intel "bugfix history in <module>"`. Downstream `/dw-review --bugfix <slug>` and `/dw-qa --bugfix <slug>` still target `.dw/bugfixes/NNN-<slug>/` when you want a focused review of just the eventual surgical patch.
326
421
  ```
327
422
 
328
423
  ---
@@ -376,18 +471,21 @@
376
471
 
377
472
  ## Quality Checklist
378
473
 
379
- - [ ] **Bug vs Feature triage performed**
380
- - [ ] **Scope checkpoint performed (step 4.1)**
474
+ - [ ] **Bug vs Feature triage performed (step 0)**
475
+ - [ ] **Concerns map consulted if present (step 1.5)**
381
476
  - [ ] Project/PRD context loaded
382
477
  - [ ] Evidence collected (git log, errors)
383
478
  - [ ] **EXACTLY 3 questions asked**
384
479
  - [ ] Responses received and analyzed
385
480
  - [ ] Root cause identified
481
+ - [ ] **Scope checkpoint performed (step 4.1)**
482
+ - [ ] **Safety valve checked (step 5.0) — escalated to `/dw-plan` if tripped**
386
483
  - [ ] Tasks numbered sequentially
387
484
  - [ ] **Maximum 5 affected files**
388
485
  - [ ] **No migrations**
389
486
  - [ ] **Test task included (correct project framework)**
390
487
  - [ ] Awaiting approval before executing
488
+ - [ ] **`.dw/bugfixes/NNN-<slug>/{TASK,fix-report,SUMMARY}.md` written after verify PASS**
391
489
 
392
490
  <critical>
393
491
  FIRST: Evaluate if it's a bug or feature (Step 0).
@@ -38,9 +38,10 @@ You are the codebase intelligence assistant. Two modes: query the existing index
38
38
 
39
39
  ## File Locations
40
40
 
41
- - Machine-readable intel (queried first): `.dw/intel/{stack,files,apis,deps}.json` + `.dw/intel/arch.md`
41
+ - Machine-readable intel (queried first): `.dw/intel/{stack,files,apis,deps,bugfixes}.json` + `.dw/intel/arch.md`
42
42
  - Refresh metadata: `.dw/intel/.last-refresh.json`
43
- - Human-readable rules (queried second): `.dw/rules/{index,<module>,integrations}.md`
43
+ - Human-readable rules (queried second): `.dw/rules/{index,<module>,integrations,concerns}.md`
44
+ - Bugfix history source: `.dw/bugfixes/*/SUMMARY.md`
44
45
  - Direct grep fallback (queried last): the project source files
45
46
 
46
47
  ## Required Behavior
@@ -67,6 +68,8 @@ Classify the user's `{{QUERY}}` into one of the shapes documented in `.agents/sk
67
68
  - **api-list** — primary: `apis.json`
68
69
  - **find-export** — primary: `files.json` (search `exports` arrays)
69
70
  - **convention** — primary: `arch.md`, secondary: `.dw/rules/`
71
+ - **bugfix-history** — primary: `bugfixes.json`, secondary: `.dw/rules/concerns.md` (triggers: "bugs in <module>", "recent fixes", "what broke in X", "fix history for Y")
72
+ - **risk-area** — primary: `.dw/rules/concerns.md`, secondary: `bugfixes.json` (triggers: "is X risky", "what's fragile", "hot spots", "tech debt")
70
73
 
71
74
  ### 3. Search execution
72
75
 
@@ -143,7 +146,31 @@ When invoked with `--build`, the command produces or refreshes the queryable int
143
146
  5. **API extraction.** Routes, RPC handlers, GraphQL resolvers, public CLI surface. Output to `.dw/intel/apis.json`. Budget ≤1.5K tokens.
144
147
  6. **Dependency map.** Internal cross-module imports + external packages with `used_by` arrays. Output to `.dw/intel/deps.json`. Budget ≤1K tokens.
145
148
  7. **Architecture summary.** Prose document describing the project's shape, key patterns, request flows, deployment topology. Output to `.dw/intel/arch.md`. Budget ≤1.5K tokens.
146
- 8. **Refresh metadata.** Write `.dw/intel/.last-refresh.json` with `updated_at`, `version`, `mode` (full or incremental), files-scanned count.
149
+ 8. **Bugfix history.** If `.dw/bugfixes/` exists and is non-empty, scan every `SUMMARY.md` and build `.dw/intel/bugfixes.json` (budget ≤1K tokens). Schema:
150
+ ```json
151
+ {
152
+ "schema_version": "1.0",
153
+ "fixes": [
154
+ {
155
+ "slug": "001-login-not-working",
156
+ "date": "YYYY-MM-DD",
157
+ "status": "Fixed",
158
+ "severity": "Medium",
159
+ "symptom_one_line": "...",
160
+ "root_cause_one_line": "...",
161
+ "modules_touched": ["src/auth/", "src/api/login/"],
162
+ "files_touched": ["src/auth/session.ts", "src/auth/session.test.ts"],
163
+ "related_concerns": ["src/auth/session.ts"],
164
+ "path": ".dw/bugfixes/001-login-not-working/"
165
+ }
166
+ ],
167
+ "by_module": {
168
+ "src/auth/": ["001-login-not-working", "007-refresh-token-leak"]
169
+ }
170
+ }
171
+ ```
172
+ Skip if `.dw/bugfixes/` does not exist. Reject SUMMARY.md files that fail frontmatter validation; log them in the build report. **Escalated bugfixes** (those with `escalated.md` but no `SUMMARY.md` because the fix lives under `.dw/spec/prd-bugfix-<slug>/`) are skipped from `bugfixes.json` until the spec ships a fix — they re-enter the index when their SUMMARY.md is eventually written. The escalated `TASK.md` remains queryable by direct grep; the index only tracks completed fixes.
173
+ 9. **Refresh metadata.** Write `.dw/intel/.last-refresh.json` with `updated_at`, `version`, `mode` (full or incremental), files-scanned count, and `bugfixes_indexed` count.
147
174
 
148
175
  ### Complementary skill for build mode
149
176