@brunosps00/dev-workflow 1.0.1 → 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 (32) hide show
  1. package/README.md +16 -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 +21 -0
  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-bugfix.md +124 -26
  9. package/scaffold/en/commands/dw-intel.md +30 -3
  10. package/scaffold/en/commands/dw-pause.md +92 -0
  11. package/scaffold/en/commands/dw-qa.md +87 -11
  12. package/scaffold/en/commands/dw-resume.md +90 -0
  13. package/scaffold/en/commands/dw-review.md +22 -12
  14. package/scaffold/en/templates/bugfix-summary-template.md +66 -0
  15. package/scaffold/en/templates/concerns-template.md +59 -0
  16. package/scaffold/en/templates/state-template.md +59 -0
  17. package/scaffold/pt-br/agent-instructions.md +21 -0
  18. package/scaffold/pt-br/commands/dw-analyze-project.md +64 -0
  19. package/scaffold/pt-br/commands/dw-autopilot.md +64 -5
  20. package/scaffold/pt-br/commands/dw-bugfix.md +134 -18
  21. package/scaffold/pt-br/commands/dw-intel.md +30 -3
  22. package/scaffold/pt-br/commands/dw-pause.md +92 -0
  23. package/scaffold/pt-br/commands/dw-qa.md +87 -11
  24. package/scaffold/pt-br/commands/dw-resume.md +90 -0
  25. package/scaffold/pt-br/commands/dw-review.md +22 -12
  26. package/scaffold/pt-br/templates/bugfix-summary-template.md +66 -0
  27. package/scaffold/pt-br/templates/concerns-template.md +59 -0
  28. package/scaffold/pt-br/templates/state-template.md +59 -0
  29. package/scaffold/skills/dw-codebase-intel/SKILL.md +9 -5
  30. package/scaffold/skills/dw-codebase-intel/references/query-patterns.md +52 -0
  31. package/scaffold/skills/dw-memory/SKILL.md +26 -1
  32. package/scaffold/skills/dw-memory/references/context-budget.md +63 -0
@@ -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
 
@@ -0,0 +1,92 @@
1
+ <system_instructions>
2
+ You are a session-handoff agent. Your job is to consolidate the current session's mental state into `.dw/STATE.md` so the next session (yours or a teammate's) can resume without losing context.
3
+
4
+ ## When to Use
5
+ - Use when the user says "pause work", "end session", "I need to stop for now", "save what we're doing"
6
+ - Use proactively before a long break, before switching projects, or before a context window is about to be compacted
7
+ - Do NOT use mid-task when nothing has been decided or learned (nothing to consolidate)
8
+ - Do NOT use as a substitute for `/dw-commit` — STATE.md is mental state, not code changes
9
+
10
+ ## Pipeline Position
11
+ **Predecessor:** any working session | **Successor:** `/dw-resume` (in a future session)
12
+
13
+ ## What this command does NOT do
14
+ - It does NOT commit code (use `/dw-commit`)
15
+ - It does NOT replace per-PRD `MEMORY.md` (workflow memory for a single feature lives there; `dw-memory` skill manages it)
16
+ - It does NOT promote anything to ADRs (use `/dw-adr` for durable architectural decisions)
17
+
18
+ ## File Location
19
+ - Single artifact: `.dw/STATE.md` (project-level, not per-PRD)
20
+ - Template: `.dw/templates/state-template.md` (used only on first creation)
21
+
22
+ ## Workflow
23
+
24
+ ### 1. Ensure STATE.md exists
25
+ - If `.dw/STATE.md` is missing, copy `.dw/templates/state-template.md` to `.dw/STATE.md`. Notify in chat: "STATE.md not found — initialized from template."
26
+ - If `.dw/templates/state-template.md` is also missing (very old project), create a minimal STATE.md with the required sections (Open Loops, Decisions, Blockers, Todos, Deferred Ideas, Lessons, Preferences, Notes).
27
+
28
+ ### 2. Survey the session
29
+ Read the conversation context and identify, **without inventing**:
30
+
31
+ - **Open loops**: tasks/work started but not finished (e.g. "PRD `prd-foo` is at TechSpec stage, awaiting user approval"; "Task 3 of `prd-bar` failing on lint")
32
+ - **Decisions made**: choices the user and agent agreed on during the session that affect future work
33
+ - **Blockers encountered**: things that stopped forward motion (waiting on input, broken tooling, knowledge gap)
34
+ - **Todos** mentioned in passing that don't yet have a PRD or task file
35
+ - **Ideas explored and parked** (with the reason for parking)
36
+ - **Lessons learned** — small operational lessons worth recording
37
+ - **Preferences expressed** — conventions the user wants applied going forward
38
+
39
+ ### 3. Merge into STATE.md
40
+
41
+ <critical>NEVER overwrite STATE.md blindly. Read the existing file, parse the sections, and merge: append new items, do not delete old ones unless the user explicitly asked you to.</critical>
42
+
43
+ Rules:
44
+ - Each new entry gets a date prefix `YYYY-MM-DD` (use today's date).
45
+ - Use bullet lists. Keep each item to one line where possible; two lines if context is essential.
46
+ - If a section ends up with `_none_` placeholder and you have nothing to add, keep `_none_`.
47
+ - Update the `last_paused` frontmatter field to today's date (YYYY-MM-DD).
48
+
49
+ ### 4. Compaction pass (when STATE.md is large)
50
+
51
+ If after merging STATE.md exceeds **~6KB** or any single section exceeds **20 items**, compact:
52
+
53
+ - **Open Loops resolved during the session**: remove them.
54
+ - **Todos completed during the session**: remove them.
55
+ - **Decisions older than 30 days that have been formalized into ADRs or constitution**: remove (the ADR is the durable record).
56
+ - **Lessons older than 60 days**: keep only those still relevant; drop dated tactical advice.
57
+ - **Deferred Ideas older than 90 days with no revisit trigger**: ask the user before dropping.
58
+
59
+ If compaction removes more than 5 items, list them in chat so the user can veto.
60
+
61
+ ### 5. Report
62
+
63
+ Present a brief summary to the user:
64
+
65
+ ```
66
+ ## Session Paused
67
+
68
+ Updated `.dw/STATE.md`:
69
+ - Open Loops: +N (now: X total)
70
+ - Decisions: +N
71
+ - Blockers: +N (Y unresolved)
72
+ - Todos: +N (Z total)
73
+ - Deferred: +N
74
+
75
+ [If compaction ran: lines removed and why]
76
+
77
+ Resume with `/dw-resume` next session.
78
+ ```
79
+
80
+ ## Required Behavior
81
+
82
+ <critical>NEVER fabricate state. If you don't see evidence of a blocker or decision in the conversation, don't add it. Empty sections are fine.</critical>
83
+
84
+ <critical>NEVER touch per-PRD memory files (`.dw/spec/*/MEMORY.md`, `.dw/spec/*/tasks/*_memory.md`). Those are managed by `dw-memory` skill and are PRD-local.</critical>
85
+
86
+ <critical>NEVER drop user content silently. If you compact, you list what you removed.</critical>
87
+
88
+ ## Inspired by
89
+
90
+ This command adapts the session-handoff pattern from [`tech-leads-club/agent-skills/tlc-spec-driven`](https://github.com/tech-leads-club/agent-skills/tree/main/packages/skills-catalog/skills/(development)/tlc-spec-driven) (CC-BY-4.0, Felipe Rodrigues). Adaptations: `.dw/STATE.md` location instead of `.specs/project/STATE.md`, explicit compaction protocol, frontmatter with `last_paused` / `last_resumed` for ordering signals, complementarity with the existing `dw-memory` skill.
91
+
92
+ </system_instructions>
@@ -19,6 +19,8 @@ You are the QA orchestrator. Two modes: run QA against the implementation (UI or
19
19
  | `/dw-qa --fix` | QA pass followed by an iterative fix+retest loop. Each detected bug → root-cause → fix → retest with evidence → mark resolved. Continues until all bugs marked Closed or user accepts a deferred list. |
20
20
  | `/dw-qa --api` | Forces API-only mode (skips UI even when frontend dependencies are present). Useful for backend-only sub-features in fullstack repos. |
21
21
  | `/dw-qa --ai` | Adds AI feature evaluation against the reference dataset at `.dw/eval/datasets/<feature>/`. Computes precision@k / faithfulness / outcome accuracy per the feature type. Logs JSONL to `QA/logs/ai/`. |
22
+ | `/dw-qa --uat` | **Interactive UAT walkthrough.** The agent walks the user through the feature step-by-step, asking targeted questions ("does this match expectation?", "what's the expected behavior in case X?"). No Playwright auto-driving, no AI eval. Output: `QA/uat-report.md`. Used after `--fix` (or instead of `/dw-qa` for primarily-judgment-bound features). |
23
+ | `/dw-qa --bugfix <NNN-slug>` | Targets a bugfix at `.dw/bugfixes/NNN-slug/` instead of a PRD. Runs the standard QA flow scoped to the files touched by the fix; output written to `.dw/bugfixes/NNN-slug/QA/`. Combines with `--fix`/`--api`/`--ai`/`--uat`. |
22
24
 
23
25
  ## Mode auto-detection
24
26
 
@@ -32,8 +34,17 @@ The default `/dw-qa` inspects the project to choose UI vs API:
32
34
 
33
35
  | Variable | Description | Example |
34
36
  |----------|-------------|---------|
35
- | `{{PRD_PATH}}` | Path to PRD directory containing tasks (auto-detect from active branch if omitted) | `.dw/spec/prd-invoice-export` |
36
- | `{{MODE}}` | `--fix` / `--api` / `--ai` (optional; default = auto-detect) | |
37
+ | `{{PRD_PATH}}` | Path to PRD directory containing tasks (auto-detect from active branch if omitted; ignored when `--bugfix` is used) | `.dw/spec/prd-invoice-export` |
38
+ | `{{BUGFIX_SLUG}}` | Bugfix slug when `--bugfix` flag is used | `001-login-not-working` |
39
+ | `{{MODE}}` | `--fix` / `--api` / `--ai` / `--uat` / `--bugfix <slug>` (optional; default = auto-detect, target = PRD) | — |
40
+
41
+ ## Target Resolution
42
+
43
+ Compute `<target>` ONCE at the start; substitute it wherever you see `<target>` below.
44
+
45
+ 1. **PRD target (default):** `<target>` = `{{PRD_PATH}}`. Artifacts read: `prd.md` (FRs), `techspec.md`, `tasks.md`, per-task files. Output written to `<target>/QA/`.
46
+
47
+ 2. **Bugfix target (`--bugfix <slug>`):** `<target>` = `.dw/bugfixes/<slug>/`. Artifacts read: `TASK.md` (numbered tasks + files touched), `fix-report.md` (verify evidence + reproduction trace), `SUMMARY.md`. QA is scoped to the files in the `Files Touched` table and the adjacent surfaces those files expose. Output written to `<target>/QA/`. The `qa-report.md` produced here is shorter — there are at most 5 tasks and a single root-cause to validate, not a full FR matrix.
37
48
 
38
49
  ## Complementary Skills
39
50
 
@@ -50,19 +61,20 @@ When available under `./.agents/skills/`, these are invoked operationally:
50
61
  ## Output Structure
51
62
 
52
63
  ```
53
- .dw/spec/<prd>/QA/
54
- ├── qa-report.md # Test plan + execution summary
55
- ├── bugs.md # Bug catalog with status
64
+ <target>/QA/ # <target> = .dw/spec/<prd>/ OR .dw/bugfixes/<NNN-slug>/
65
+ ├── qa-report.md # Test plan + execution summary
66
+ ├── bugs.md # Bug catalog with status
67
+ ├── uat-report.md # (--uat mode only) Walkthrough log + user observations
56
68
  ├── scripts/
57
- │ ├── ui/<RF>-<slug>.spec.ts # Playwright scripts (UI mode)
58
- │ ├── api/<RF>-<slug>.http # API test files
59
- │ └── ai/<feature>-eval.ts # AI eval scripts (--ai mode)
69
+ │ ├── ui/<RF>-<slug>.spec.ts # Playwright scripts (UI mode)
70
+ │ ├── api/<RF>-<slug>.http # API test files
71
+ │ └── ai/<feature>-eval.ts # AI eval scripts (--ai mode)
60
72
  ├── evidence/
61
- │ ├── ui/ # Screenshots per RF + retests
73
+ │ ├── ui/ # Screenshots per RF + retests
62
74
  │ └── ...
63
75
  └── logs/
64
- ├── api/<RF>-<slug>.log # JSONL request/response per call
65
- └── ai/<feature>-<date>.jsonl # AI eval results
76
+ ├── api/<RF>-<slug>.log # JSONL request/response per call
77
+ └── ai/<feature>-<date>.jsonl # AI eval results
66
78
  ```
67
79
 
68
80
  ## Mode 1: Default (`/dw-qa`)
@@ -105,6 +117,70 @@ When available under `./.agents/skills/`, these are invoked operationally:
105
117
  4. Compare to prior run's JSONL — alert on >10% regression in any metric.
106
118
  5. Append AI-mode section to `qa-report.md`.
107
119
 
120
+ ## Mode 1.5: Interactive UAT (`/dw-qa --uat`)
121
+
122
+ The UAT mode is a **human-in-the-loop walkthrough**. There is no Playwright auto-driving and no AI eval. The agent is the navigator; the user is the verifier. Use this when behavior is judgment-bound — a redesign, a content-heavy flow, a new flow whose acceptance criteria are partly aesthetic, or a bugfix whose user-facing manifestation needs a human eye to confirm.
123
+
124
+ ### Pre-flight
125
+
126
+ 1. **Bugfix target:** read `<target>/SUMMARY.md` → Symptom + Resolution. The walkthrough is the reproduction trace from `fix-report.md` (before → after), now confirmed live.
127
+ 2. **PRD target:** read `<target>/prd.md` → for each FR, draft a one-line "what should you see when X happens?" question.
128
+ 3. Start the project's dev server (or instruct the user to start it if it needs interactive credentials).
129
+
130
+ ### Walkthrough loop
131
+
132
+ For each FR (PRD target) or each numbered task in `TASK.md` (bugfix target):
133
+
134
+ 1. **Agent describes the next step in plain words.** Example: "Open `/invoices/export` while logged in as a viewer. The export button should be disabled and a tooltip should explain why."
135
+ 2. **User performs the step in their browser/app** and reports what they observed.
136
+ 3. **Agent asks one targeted follow-up** matched to the FR/task — never more than one open question at a time:
137
+ - "Does the disabled state visually communicate why? (text, icon, contrast — your call)"
138
+ - "If you tab to the button, does the tooltip become accessible via keyboard?"
139
+ - "What happened in the network panel?" (only if a backend behavior is relevant)
140
+ 4. **Agent records the answer verbatim** in `uat-report.md` under that FR/task's section. No interpretation, no rephrasing.
141
+ 5. **Agent flags a finding** when the user reports unexpected behavior. The finding goes into `bugs.md` with `source: uat` and `severity: <user's choice>`.
142
+ 6. **Repeat until all FRs / numbered tasks have been walked.**
143
+
144
+ ### Output
145
+
146
+ Save to `<target>/QA/uat-report.md`:
147
+
148
+ ```markdown
149
+ # UAT Walkthrough — <target>
150
+
151
+ Date: YYYY-MM-DD
152
+ Walked by: <user identifier or "user">
153
+ Browser/env: <as reported>
154
+
155
+ ## FR-1.1 (or Task 1) — <one-line scope>
156
+
157
+ - Step: <what agent asked>
158
+ - User observation: <verbatim>
159
+ - Verdict: PASS / FAIL / NEEDS-DESIGN-INPUT
160
+ - Notes: <any follow-up>
161
+
162
+ ## FR-1.2 (or Task 2) — ...
163
+ ...
164
+
165
+ ## Summary
166
+
167
+ - Walked: N FRs / tasks
168
+ - PASS: N
169
+ - FAIL: N (cross-ref bugs.md entries with source:uat)
170
+ - NEEDS-DESIGN-INPUT: N (no bug; the spec was under-defined here)
171
+ ```
172
+
173
+ ### Required behavior
174
+
175
+ <critical>
176
+ - NEVER auto-drive the browser in `--uat` mode. The user navigates; you observe.
177
+ - NEVER paraphrase the user's observation. Quote verbatim under each FR/task.
178
+ - NEVER mark a finding as a bug without the user's explicit "yes, that's a bug" — UAT findings can also surface unclear specs (NEEDS-DESIGN-INPUT), which are not bugs.
179
+ - Cap each FR's section at one open question per turn. UAT is interactive, not interrogation.
180
+ </critical>
181
+
182
+ UAT composes with `--bugfix <slug>` (walks the regression test path with the user instead of FRs) and with `--fix` (after a fix lands, UAT is the human green-light before commit).
183
+
108
184
  ## Mode 2: Fix loop (`/dw-qa --fix`)
109
185
 
110
186
  ### Behavior
@@ -0,0 +1,90 @@
1
+ <system_instructions>
2
+ You are a session-resumption agent. Your job is to read `.dw/STATE.md`, orient yourself and the user, and route to the most useful next step. This command is the inverse of `/dw-pause`.
3
+
4
+ ## When to Use
5
+ - Use when the user says "resume work", "continue", "where did we stop?", "pick up where we left off", or starts a new session in an existing project
6
+ - Use proactively at the start of any session that lands in a project with a non-empty `.dw/STATE.md` and the user hasn't yet stated an intent
7
+
8
+ ## Pipeline Position
9
+ **Predecessor:** `/dw-pause` (previous session) | **Successor:** depends on what's open (typically `/dw-run --resume`, `/dw-bugfix`, `/dw-plan`, `/dw-qa`, or `/dw-review`)
10
+
11
+ ## File Location
12
+ - Read-only target: `.dw/STATE.md`
13
+ - Cross-reference: `.dw/spec/` (list active PRDs), `.dw/bugfixes/` (list open bugfixes), `.dw/incidents/` (if any)
14
+
15
+ ## Workflow
16
+
17
+ ### 1. Read STATE.md
18
+ - If `.dw/STATE.md` is missing, report: "No paused state found — this looks like a fresh session. Run `/dw-help` for next steps." Stop here.
19
+ - If `STATE.md` exists but every section is `_none_`, report: "STATE.md is empty — nothing to resume. Tell me what you want to do."
20
+
21
+ ### 2. Cross-reference with disk
22
+ Verify that the state still matches the filesystem:
23
+
24
+ - For each Open Loop referencing a PRD path, run `ls` on `.dw/spec/<slug>/`. If missing, flag `[stale: PRD not found]` and ask if the user wants it removed.
25
+ - For each Open Loop referencing a bugfix slug, check `.dw/bugfixes/<NNN-slug>/`.
26
+ - For each Blocker referencing an external system, do not verify — just surface it.
27
+ - If `last_paused` in frontmatter is more than 14 days old, surface this prominently (state may be stale).
28
+
29
+ ### 3. Produce TLDR
30
+
31
+ Present a concise summary, **not the raw STATE.md**:
32
+
33
+ ```
34
+ ## Where you left off
35
+
36
+ Last paused: YYYY-MM-DD (Nd ago)
37
+
38
+ ### Open Loops (N)
39
+ - [path or label] — next: <one-line next action> [<status flag if stale>]
40
+ - ...
41
+
42
+ ### Blockers (N unresolved)
43
+ - [label] — waiting on <X>
44
+
45
+ ### Top Todos (up to 5)
46
+ - ...
47
+
48
+ [Decisions, Lessons, Preferences — only mention if relevant to active loops]
49
+ ```
50
+
51
+ Keep the TLDR under 30 lines. If STATE.md has more, summarize and offer `cat .dw/STATE.md` as a follow-up.
52
+
53
+ ### 4. Suggest the next step
54
+
55
+ Based on the TLDR, route to a concrete command. Use these heuristics:
56
+
57
+ | Strongest signal in STATE.md | Suggested command |
58
+ |------------------------------|-------------------|
59
+ | Open Loop on a PRD at `tasks/` stage | `/dw-run --resume` |
60
+ | Open Loop on a PRD at `techspec` stage | `/dw-plan techspec` |
61
+ | Open Loop on a PRD at `prd` stage | `/dw-plan tasks` (if PRD approved) or continue PRD |
62
+ | Open Loop on a bugfix slug | `/dw-bugfix --resume <slug>` or `/dw-qa --bugfix <slug>` |
63
+ | Blocker waiting on external input | Suggest the user resolve the blocker first |
64
+ | Only Todos and Decisions, no active work | Ask the user what they want to start |
65
+
66
+ Phrase the suggestion as a question, not an order:
67
+
68
+ ```
69
+ Want me to <suggested command>?
70
+ - yes → I'll run it
71
+ - no, <other intent> → tell me what instead
72
+ ```
73
+
74
+ ### 5. Update STATE.md frontmatter
75
+
76
+ Set `last_resumed` to today's date (YYYY-MM-DD). Do not modify section content — that's the user's call now that the session is back.
77
+
78
+ ## Required Behavior
79
+
80
+ <critical>NEVER auto-execute the suggested command. `/dw-resume` only proposes; the user confirms before any `/dw-run`, `/dw-plan`, or `/dw-bugfix` fires.</critical>
81
+
82
+ <critical>NEVER fabricate stale-detection results. If you didn't run `ls`, don't report the file exists or doesn't exist.</critical>
83
+
84
+ <critical>NEVER dump the full STATE.md into the chat. Summarize. Long state files mean compaction is needed — suggest `/dw-pause` to compact next time.</critical>
85
+
86
+ ## Inspired by
87
+
88
+ This command adapts the session-handoff pattern from [`tech-leads-club/agent-skills/tlc-spec-driven`](https://github.com/tech-leads-club/agent-skills/tree/main/packages/skills-catalog/skills/(development)/tlc-spec-driven) (CC-BY-4.0, Felipe Rodrigues). Adaptations: routing heuristics map STATE.md content to specific `dw-*` commands; cross-reference with `.dw/spec/` and `.dw/bugfixes/` to detect staleness; never auto-execute.
89
+
90
+ </system_instructions>