@anhth2/spec-driven-dev-plugin 0.8.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/ARCHITECTURE.md +6 -2
  2. package/commands/debug.md +152 -0
  3. package/commands/debug.tmpl +16 -0
  4. package/commands/define-product.md +57 -0
  5. package/commands/fix-bug.md +153 -0
  6. package/commands/fix-bug.tmpl +17 -0
  7. package/commands/generate-bdd.md +277 -13
  8. package/commands/generate-bdd.tmpl +220 -13
  9. package/commands/generate-code.md +154 -2
  10. package/commands/generate-code.tmpl +97 -2
  11. package/commands/generate-design-spec.md +57 -0
  12. package/commands/generate-prd.md +114 -20
  13. package/commands/generate-prd.tmpl +57 -20
  14. package/commands/generate-spec-manifest.md +57 -0
  15. package/commands/generate-tech-docs.md +79 -1
  16. package/commands/generate-tech-docs.tmpl +22 -1
  17. package/commands/generate-tests.md +57 -0
  18. package/commands/learn.md +554 -0
  19. package/commands/learn.tmpl +63 -0
  20. package/commands/propose-scenario.md +521 -0
  21. package/commands/propose-scenario.tmpl +109 -0
  22. package/commands/refine-prd.md +66 -1
  23. package/commands/refine-prd.tmpl +9 -1
  24. package/commands/report-bug.md +543 -0
  25. package/commands/report-bug.tmpl +131 -0
  26. package/commands/review-code.md +153 -0
  27. package/commands/review-code.tmpl +17 -0
  28. package/commands/review-context.md +65 -0
  29. package/commands/review-context.tmpl +8 -0
  30. package/commands/review-tech-docs.md +146 -4
  31. package/commands/review-tech-docs.tmpl +89 -4
  32. package/commands/run-tests.md +82 -0
  33. package/commands/run-tests.tmpl +25 -0
  34. package/commands/setup-ai-first.md +15 -5
  35. package/commands/setup-ai-first.tmpl +10 -5
  36. package/commands/smoke-test.md +57 -0
  37. package/commands/sync.md +405 -0
  38. package/commands/sync.tmpl +345 -0
  39. package/commands/update-framework.md +211 -0
  40. package/commands/update-framework.tmpl +151 -0
  41. package/commands/validate-traces.md +115 -2
  42. package/commands/validate-traces.tmpl +58 -2
  43. package/core/FRAMEWORK_VERSION +1 -1
  44. package/core/commands/debug.md +152 -0
  45. package/core/commands/define-product.md +57 -0
  46. package/core/commands/fix-bug.md +153 -0
  47. package/core/commands/generate-bdd.md +277 -13
  48. package/core/commands/generate-code.md +154 -2
  49. package/core/commands/generate-design-spec.md +57 -0
  50. package/core/commands/generate-prd.md +114 -20
  51. package/core/commands/generate-spec-manifest.md +57 -0
  52. package/core/commands/generate-tech-docs.md +79 -1
  53. package/core/commands/generate-tests.md +57 -0
  54. package/core/commands/learn.md +554 -0
  55. package/core/commands/propose-scenario.md +521 -0
  56. package/core/commands/refine-prd.md +66 -1
  57. package/core/commands/report-bug.md +543 -0
  58. package/core/commands/review-code.md +153 -0
  59. package/core/commands/review-context.md +65 -0
  60. package/core/commands/review-tech-docs.md +146 -4
  61. package/core/commands/run-tests.md +82 -0
  62. package/core/commands/setup-ai-first.md +15 -5
  63. package/core/commands/smoke-test.md +57 -0
  64. package/core/commands/sync.md +405 -0
  65. package/core/commands/update-framework.md +211 -0
  66. package/core/commands/validate-traces.md +115 -2
  67. package/core/skills/code/SKILL.md +62 -0
  68. package/core/skills/debug/SKILL.md +67 -0
  69. package/core/skills/design-spec/SKILL.md +57 -0
  70. package/core/skills/discovery/SKILL.md +57 -0
  71. package/core/skills/prd/SKILL.md +10 -0
  72. package/core/skills/setup-ai-first/SKILL.md +5 -0
  73. package/core/skills/spec/SKILL.md +10 -0
  74. package/core/skills/test/SKILL.md +119 -0
  75. package/core/steps/capture-lesson.md +79 -0
  76. package/core/steps/context-loader.md +52 -0
  77. package/core/steps/report-footer.md +5 -0
  78. package/core/templates/prd.template.md +35 -20
  79. package/core/templates/project-context.yaml +11 -0
  80. package/package.json +9 -2
  81. package/skills/code/SKILL.md +62 -0
  82. package/skills/debug/SKILL.md +67 -0
  83. package/skills/design-spec/SKILL.md +57 -0
  84. package/skills/discovery/SKILL.md +57 -0
  85. package/skills/prd/SKILL.md +10 -0
  86. package/skills/setup-ai-first/SKILL.md +5 -0
  87. package/skills/spec/SKILL.md +10 -0
  88. package/skills/test/SKILL.md +119 -0
  89. package/steps/capture-lesson.md +79 -0
  90. package/steps/context-loader.md +52 -0
  91. package/steps/report-footer.md +5 -0
  92. package/templates/prd.template.md +35 -20
  93. package/templates/project-context.yaml +11 -0
@@ -0,0 +1,151 @@
1
+ # /update-framework — Update the Spec-Driven Dev Framework
2
+
3
+ Upgrades the **framework tooling** (`.agent/commands/`, `steps/`, `modules/`, `hooks/`, `rules/`, `templates/`, `skills/`) to the latest published version from npm.
4
+
5
+ > **Not the same as `/sync`.**
6
+ > - `/sync` → pulls **project content** (submodule code/specs) + refreshes Living Docs. Run daily.
7
+ > - `/update-framework` → upgrades the **framework command files themselves**. Run occasionally, when a new framework version ships.
8
+
9
+ This command wraps `npx @anhth2/spec-driven-dev-plugin@latest --init`. It requires network + npm access.
10
+
11
+ ---
12
+
13
+ ## Step 0 — Detect Current State
14
+
15
+ 1. Read `.agent/FRAMEWORK_VERSION` → current installed version.
16
+ - If missing → this project was not installed via `--init`. Stop:
17
+ ```
18
+ ❌ .agent/FRAMEWORK_VERSION not found.
19
+ This project was not set up with the framework installer.
20
+ Run: npx @anhth2/spec-driven-dev-plugin --init
21
+ ```
22
+
23
+ 2. Read `.agent/project-context.yaml` → extract `setup.mode` (`umbrella` / absent = single) and `services`.
24
+
25
+ 3. List `.agent/modules/` → record installed module names (these must be re-passed on upgrade so they update too).
26
+
27
+ Print:
28
+ ```
29
+ Current framework : v{current}
30
+ Mode : {umbrella | single-service}
31
+ Installed modules : {list or "none"}
32
+ ```
33
+
34
+ ---
35
+
36
+ ## Step 1 — Check Latest Version
37
+
38
+ Run:
39
+ ```bash
40
+ npm view @anhth2/spec-driven-dev-plugin version
41
+ ```
42
+
43
+ Compare `current` vs `latest`:
44
+
45
+ | Result | Action |
46
+ |--------|--------|
47
+ | Network/registry unreachable | Warn `⚠️ Could not reach npm registry — check connection.` and stop |
48
+ | `current == latest` | Print `✅ Already up to date (v{current}). Nothing to do.` and stop |
49
+ | `latest > current` | Print `Update available: v{current} → v{latest}` and continue |
50
+
51
+ Ask: `Proceed with upgrade? (Y/N)` — wait for `Y`.
52
+
53
+ ---
54
+
55
+ ## Step 2 — Umbrella Awareness *(umbrella mode only)*
56
+
57
+ If `setup.mode == umbrella`, print this note before upgrading:
58
+
59
+ ```
60
+ ℹ️ Umbrella mode — framework tooling lives ONLY at this umbrella root.
61
+ Service submodules contain just .agent/project-context.yaml (config), not
62
+ command files — they read commands from the umbrella root. No per-service
63
+ framework update is needed here.
64
+
65
+ Exception: if a teammate opens Claude Code directly INSIDE a service repo
66
+ (outside the umbrella), that repo has its own .agent/ — its owning team runs
67
+ /update-framework there independently.
68
+ ```
69
+
70
+ ---
71
+
72
+ ## Step 3 — Pre-flight Git Check
73
+
74
+ Run `git status --short .agent/ .claude/commands/`.
75
+
76
+ If there are uncommitted changes in those paths:
77
+ ```
78
+ ⚠️ Uncommitted changes in .agent/ or .claude/commands/.
79
+ The upgrade overwrites framework files. Commit or stash first so you can
80
+ cleanly review the upgrade diff:
81
+ git add .agent/ .claude/commands/ && git commit -m "wip" (or git stash)
82
+ ```
83
+ Ask whether to continue anyway `(Y/N)`. Default to stopping.
84
+
85
+ ---
86
+
87
+ ## Step 4 — Run the Upgrade
88
+
89
+ Build the module flags from Step 0 (one `--module {name}` per installed module), then run:
90
+
91
+ ```bash
92
+ npx -y @anhth2/spec-driven-dev-plugin@latest --init {--module X ...}
93
+ ```
94
+
95
+ This **overwrites** (refreshes to the new version):
96
+ - `.agent/commands/`, `.agent/steps/`, `.agent/hooks/`, `.agent/rules/`, `.agent/templates/`, `.agent/skills/`, `.agent/modules/{installed}/`
97
+ - `.agent/FRAMEWORK_VERSION`
98
+ - `.claude/commands/` shortcuts
99
+
100
+ This **does NOT touch** (your content is safe):
101
+ - `.agent/project-context.yaml`
102
+ - `CLAUDE.md`
103
+ - `specs/domain-knowledge/` (business-dictionary, core-entities)
104
+ - `.trace/`
105
+
106
+ If the npx command exits non-zero → print the error and stop with `❌`.
107
+
108
+ ---
109
+
110
+ ## Step 5 — Review Changes
111
+
112
+ Run:
113
+ ```bash
114
+ git diff --stat .agent/ .claude/commands/
115
+ ```
116
+
117
+ Summarize for the user:
118
+ - **New commands** — `.md` files present now but not before
119
+ - **Updated commands** — files with changed content
120
+ - **Removed commands** — files deleted in the new version
121
+
122
+ If a new command appeared (e.g. a new slash command), call it out explicitly so the user knows it is now available.
123
+
124
+ ---
125
+
126
+ ## Output
127
+
128
+ {{include:steps/report-footer.md}}
129
+
130
+ ```
131
+ /update-framework — v{current} → v{latest}
132
+
133
+ ✅ Framework upgraded
134
+ Updated : {N} command files, {M} step files
135
+ New : {list any new commands, e.g. /some-new-command}
136
+ Removed : {list any removed commands, or "none"}
137
+
138
+ Your content was preserved:
139
+ project-context.yaml, CLAUDE.md, domain-knowledge/, .trace/ — untouched
140
+
141
+ Review & commit:
142
+ git diff .agent/
143
+ git add .agent/ .claude/commands/
144
+ git commit -m "chore: upgrade spec-driven-dev v{current} → v{latest}"
145
+ {umbrella mode: this is the umbrella root — service submodules need no framework update}
146
+
147
+ ---
148
+ Status : ✅ Complete | ⚠️ Warnings
149
+ Output Artifacts: refreshed .agent/ framework files, .claude/commands/ shortcuts
150
+ Next : review git diff, then commit | /sync to refresh project content
151
+ ```
@@ -180,6 +180,37 @@ If `services` section is present:
180
180
  - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
181
181
  - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
182
182
  - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
183
+ - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
184
+ - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
185
+
186
+ > **Why under `spec_source`:** tester feedback (`/report-bug`, `/propose-scenario`) must land in the **shared spec repo** so PO/Dev see it when they `/sync`. In single-service mode (no `spec_source`), these default to `feedback/bug-reports` and `feedback/bdd-proposals` at repo root — still shared, same repo.
187
+
188
+ ---
189
+
190
+ ## Step 1.6 — [SERVICE CONVENTIONS] Load service-specific conventions (umbrella mode)
191
+
192
+ *Skip this step entirely if `active_service` is `"unresolved"` or context is single-service mode.*
193
+
194
+ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-service/`):
195
+
196
+ **1. Locate service config** — try in priority order:
197
+ - `{active_service}/.agent/project-context.yaml`
198
+ - `{active_service}/project-context.yaml`
199
+
200
+ **2. If found, override with service-specific values:**
201
+
202
+ | Variable | Source |
203
+ |----------|--------|
204
+ | `conventions.test_command` | service's `conventions.test_command` |
205
+ | `conventions.build_command` | service's `conventions.build_command` |
206
+ | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` — default: `{active_service}/.trace` |
207
+ | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
208
+
209
+ **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
210
+ - Shell commands (`/run-tests`, `/generate-tests`) run **from within** `service_root`
211
+ - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
212
+
213
+ **4. If service config not found** — keep umbrella defaults, still set `service_root = {active_service}` (path anchor is always needed even without a config override).
183
214
 
184
215
  ---
185
216
 
@@ -273,6 +304,25 @@ These two variables (`active_module`, `platform_type`) are the canonical source
273
304
 
274
305
  ---
275
306
 
307
+ ## Step 6.7 — [GUARDRAILS] Load Project Lessons (conditional)
308
+
309
+ *Accumulated mistakes the AI must not repeat in this project. These are added over time via `/learn`
310
+ or accepted during `/review-code`, `/fix-bug`, `/debug`.*
311
+
312
+ Resolve the lessons file path:
313
+ - Use `paths.lessons_file` if set (may be service-overridden in umbrella mode, Step 1.6)
314
+ - Else default `specs/domain-knowledge/lessons-learned.md`
315
+ - In umbrella/service mode (when `service_root` is set), if `paths.lessons_file` is unset, default to `{service_root}/.agent/project-lessons.md`
316
+
317
+ If the file exists, read it and store ALL lessons as **ACTIVE GUARDRAILS** for the session:
318
+ - Treat each lesson's **Rule** as a hard constraint — same priority as CLAUDE.md coding standards (Step 3).
319
+ - Before generating or modifying any artifact (PRD, BDD, tech-doc, code, test), check the output against every lesson whose `category` matches the current command AND whose `scope` matches the target (domain / file).
320
+ - If a generated output would violate a lesson → correct it **before** presenting, and note which lesson (`L-NNN`) was applied.
321
+
322
+ If the file does not exist → skip silently (no lessons captured yet).
323
+
324
+ ---
325
+
276
326
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
277
327
 
278
328
  After loading all context, synthesize and output a compact summary block.
@@ -288,7 +338,9 @@ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Ser
288
338
  Ticket : {ticket_prefix}-
289
339
  Dict : {loaded — N canonical terms, M banned terms | missing}
290
340
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
341
+ Lessons : {loaded — N guardrails | none yet}
291
342
  Service : {active_service} ({active_service_module}) | single-service
343
+ Svc Root : {service_root} — conventions + trace_dir loaded from service config | —
292
344
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
293
345
  ```
294
346
 
@@ -314,12 +366,33 @@ Proceed to the next step of the calling command.
314
366
 
315
367
  ## Process
316
368
 
369
+ ### Step 0 — Umbrella Mode Detection
370
+
371
+ Check whether `services` array exists in `project-context.yaml`.
372
+
373
+ **If `services` exists (umbrella mode):**
374
+ - Resolve the trace dir for each service:
375
+ - Use `services[N].trace_dir` if explicitly set
376
+ - Otherwise default to `{services[N].path}/.trace`
377
+ - Set `all_trace_dirs = [ dir1, dir2, ... ]` — one per service
378
+ - Set `umbrella_root_trace = ".trace"` (at umbrella workspace root)
379
+ - Step 1 will read TSVs from ALL dirs in `all_trace_dirs`, tagged by service name
380
+
381
+ **If no `services` key (single-service mode):**
382
+ - Set `all_trace_dirs = [ {paths.trace_dir} ]`
383
+ - No umbrella sync needed
384
+
385
+ ---
386
+
317
387
  ### Step 1 — Load TSV data
318
388
 
319
- Read all `{paths.trace_dir}/{UC-ID}.tsv` files matching the target domain (or all domains if no domain filter).
389
+ **Umbrella mode:** read all `{trace_dir}/{UC-ID}.tsv` files from every dir in `all_trace_dirs`. For each TSV, tag its rows with the originating service name.
390
+
391
+ **Single-service mode:** read all `{paths.trace_dir}/{UC-ID}.tsv` files matching the target domain (or all domains if no domain filter).
392
+
320
393
  Each file gives the persisted trace state for that UC.
321
394
 
322
- **If no `.tsv` files found** in `{paths.trace_dir}`:
395
+ **If no `.tsv` files found** in any of the trace dirs:
323
396
  - Scan all `{paths.specs_dir}/**/*.feature` files in the target domain to build an in-memory list of all scenarios.
324
397
  - Treat all scenarios as `UNTRACKED` (no code generated yet).
325
398
  - Print: "⚠️ No trace files found. All {N} scenarios across {M} UCs are UNTRACKED."
@@ -499,6 +572,36 @@ Schema:
499
572
  - Always write to `{paths.trace_dir}/trace-report.json` regardless of domain filter — if a domain filter was applied, include only those PRDs in `prds[]` but note the domain in the `domain` field
500
573
  - **TSV `"—"` mapping**: when reading TSV files, map dash values to JSON types: `implemented_by: "—"` → `null`; `test_count: "—"` → `0`; `test_classes: "—"` → `[]`; `tech_doc_revision: "—"` → `0`
501
574
 
575
+ ### Step 8b — Umbrella Living Docs Sync *(umbrella mode only)*
576
+
577
+ *Skip this step in single-service mode.*
578
+
579
+ After writing each service's `trace-report.json`, sync trace files to the umbrella root so the Living Docs VS Code panel (opened at umbrella root) can read them:
580
+
581
+ 1. Create directory `{umbrella_root_trace}/` if it does not exist (`mkdir -p .trace`).
582
+
583
+ 2. **Copy TSV files** from each service trace dir to umbrella trace dir with service namespace:
584
+ ```
585
+ {service.path}/.trace/{UC-ID}.tsv → .trace/{service-name}/{UC-ID}.tsv
586
+ ```
587
+ Overwrite if exists. Do not delete files in `.trace/` that no longer have a service source — they may be from a previous run.
588
+
589
+ 3. **Write aggregated `trace-report.json`** to `{umbrella_root_trace}/trace-report.json`:
590
+ - Merge all per-service `trace-report.json` data into one document
591
+ - Add `"service"` field to each scenario row
592
+ - Recalculate summary aggregates across all services
593
+
594
+ 4. **Print sync summary:**
595
+ ```
596
+ Umbrella sync → .trace/
597
+ user-service : {N} TSV files copied
598
+ order-service : {N} TSV files copied
599
+ trace-report.json: merged ({total} scenarios across {S} services)
600
+ Living Docs panel will reflect this data immediately.
601
+ ```
602
+
603
+ > **Note:** `.trace/` at umbrella root is a **read-only mirror** — do NOT commit it to the umbrella repo. Add `.trace/` to the umbrella's `.gitignore`. Authoritative trace state lives in each service submodule's `.trace/` dir and is committed there.
604
+
502
605
  ## Output
503
606
 
504
607
  # Report Footer — Standard Command Output Format
@@ -548,6 +651,11 @@ Suggest the logical next command based on workflow phase:
548
651
  | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
549
652
  | /fix-bug | Create PR and link to ticket |
550
653
  | /debug | `/fix-bug {ticket-id}` if fix needed |
654
+ | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
655
+ | /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
656
+ | /learn | Continue working — lesson applies on next command |
657
+ | /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
658
+ | /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
551
659
 
552
660
  Format the footer as:
553
661
  ```
@@ -595,4 +703,9 @@ Recommendations:
595
703
  - /generate-code {UC-ID} for DRIFT and UNTRACKED scenarios
596
704
  - /generate-tests {UC-ID} for GAP (missing tests)
597
705
  - /generate-bdd {prd-file} for PRD version drift
706
+
707
+ [Umbrella mode only]
708
+ Living Docs synced → .trace/ (umbrella root)
709
+ Tip: run /validate-traces after each codegen session to refresh the panel.
710
+ .trace/ at umbrella root is a mirror — do not commit it (add to .gitignore).
598
711
  ```
@@ -14,12 +14,33 @@ Read-only check of coverage between specs, code, and tests — including PRD ver
14
14
 
15
15
  ## Process
16
16
 
17
+ ### Step 0 — Umbrella Mode Detection
18
+
19
+ Check whether `services` array exists in `project-context.yaml`.
20
+
21
+ **If `services` exists (umbrella mode):**
22
+ - Resolve the trace dir for each service:
23
+ - Use `services[N].trace_dir` if explicitly set
24
+ - Otherwise default to `{services[N].path}/.trace`
25
+ - Set `all_trace_dirs = [ dir1, dir2, ... ]` — one per service
26
+ - Set `umbrella_root_trace = ".trace"` (at umbrella workspace root)
27
+ - Step 1 will read TSVs from ALL dirs in `all_trace_dirs`, tagged by service name
28
+
29
+ **If no `services` key (single-service mode):**
30
+ - Set `all_trace_dirs = [ {paths.trace_dir} ]`
31
+ - No umbrella sync needed
32
+
33
+ ---
34
+
17
35
  ### Step 1 — Load TSV data
18
36
 
19
- Read all `{paths.trace_dir}/{UC-ID}.tsv` files matching the target domain (or all domains if no domain filter).
37
+ **Umbrella mode:** read all `{trace_dir}/{UC-ID}.tsv` files from every dir in `all_trace_dirs`. For each TSV, tag its rows with the originating service name.
38
+
39
+ **Single-service mode:** read all `{paths.trace_dir}/{UC-ID}.tsv` files matching the target domain (or all domains if no domain filter).
40
+
20
41
  Each file gives the persisted trace state for that UC.
21
42
 
22
- **If no `.tsv` files found** in `{paths.trace_dir}`:
43
+ **If no `.tsv` files found** in any of the trace dirs:
23
44
  - Scan all `{paths.specs_dir}/**/*.feature` files in the target domain to build an in-memory list of all scenarios.
24
45
  - Treat all scenarios as `UNTRACKED` (no code generated yet).
25
46
  - Print: "⚠️ No trace files found. All {N} scenarios across {M} UCs are UNTRACKED."
@@ -199,6 +220,36 @@ Schema:
199
220
  - Always write to `{paths.trace_dir}/trace-report.json` regardless of domain filter — if a domain filter was applied, include only those PRDs in `prds[]` but note the domain in the `domain` field
200
221
  - **TSV `"—"` mapping**: when reading TSV files, map dash values to JSON types: `implemented_by: "—"` → `null`; `test_count: "—"` → `0`; `test_classes: "—"` → `[]`; `tech_doc_revision: "—"` → `0`
201
222
 
223
+ ### Step 8b — Umbrella Living Docs Sync *(umbrella mode only)*
224
+
225
+ *Skip this step in single-service mode.*
226
+
227
+ After writing each service's `trace-report.json`, sync trace files to the umbrella root so the Living Docs VS Code panel (opened at umbrella root) can read them:
228
+
229
+ 1. Create directory `{umbrella_root_trace}/` if it does not exist (`mkdir -p .trace`).
230
+
231
+ 2. **Copy TSV files** from each service trace dir to umbrella trace dir with service namespace:
232
+ ```
233
+ {service.path}/.trace/{UC-ID}.tsv → .trace/{service-name}/{UC-ID}.tsv
234
+ ```
235
+ Overwrite if exists. Do not delete files in `.trace/` that no longer have a service source — they may be from a previous run.
236
+
237
+ 3. **Write aggregated `trace-report.json`** to `{umbrella_root_trace}/trace-report.json`:
238
+ - Merge all per-service `trace-report.json` data into one document
239
+ - Add `"service"` field to each scenario row
240
+ - Recalculate summary aggregates across all services
241
+
242
+ 4. **Print sync summary:**
243
+ ```
244
+ Umbrella sync → .trace/
245
+ user-service : {N} TSV files copied
246
+ order-service : {N} TSV files copied
247
+ trace-report.json: merged ({total} scenarios across {S} services)
248
+ Living Docs panel will reflect this data immediately.
249
+ ```
250
+
251
+ > **Note:** `.trace/` at umbrella root is a **read-only mirror** — do NOT commit it to the umbrella repo. Add `.trace/` to the umbrella's `.gitignore`. Authoritative trace state lives in each service submodule's `.trace/` dir and is committed there.
252
+
202
253
  ## Output
203
254
 
204
255
  {{include:steps/report-footer.md}}
@@ -240,4 +291,9 @@ Recommendations:
240
291
  - /generate-code {UC-ID} for DRIFT and UNTRACKED scenarios
241
292
  - /generate-tests {UC-ID} for GAP (missing tests)
242
293
  - /generate-bdd {prd-file} for PRD version drift
294
+
295
+ [Umbrella mode only]
296
+ Living Docs synced → .trace/ (umbrella root)
297
+ Tip: run /validate-traces after each codegen session to refresh the panel.
298
+ .trace/ at umbrella root is a mirror — do not commit it (add to .gitignore).
243
299
  ```
@@ -1 +1 @@
1
- 0.8.0
1
+ 0.9.1
@@ -181,6 +181,37 @@ If `services` section is present:
181
181
  - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
182
182
  - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
183
183
  - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
184
+ - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
185
+ - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
186
+
187
+ > **Why under `spec_source`:** tester feedback (`/report-bug`, `/propose-scenario`) must land in the **shared spec repo** so PO/Dev see it when they `/sync`. In single-service mode (no `spec_source`), these default to `feedback/bug-reports` and `feedback/bdd-proposals` at repo root — still shared, same repo.
188
+
189
+ ---
190
+
191
+ ## Step 1.6 — [SERVICE CONVENTIONS] Load service-specific conventions (umbrella mode)
192
+
193
+ *Skip this step entirely if `active_service` is `"unresolved"` or context is single-service mode.*
194
+
195
+ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-service/`):
196
+
197
+ **1. Locate service config** — try in priority order:
198
+ - `{active_service}/.agent/project-context.yaml`
199
+ - `{active_service}/project-context.yaml`
200
+
201
+ **2. If found, override with service-specific values:**
202
+
203
+ | Variable | Source |
204
+ |----------|--------|
205
+ | `conventions.test_command` | service's `conventions.test_command` |
206
+ | `conventions.build_command` | service's `conventions.build_command` |
207
+ | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` — default: `{active_service}/.trace` |
208
+ | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
209
+
210
+ **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
211
+ - Shell commands (`/run-tests`, `/generate-tests`) run **from within** `service_root`
212
+ - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
213
+
214
+ **4. If service config not found** — keep umbrella defaults, still set `service_root = {active_service}` (path anchor is always needed even without a config override).
184
215
 
185
216
  ---
186
217
 
@@ -274,6 +305,25 @@ These two variables (`active_module`, `platform_type`) are the canonical source
274
305
 
275
306
  ---
276
307
 
308
+ ## Step 6.7 — [GUARDRAILS] Load Project Lessons (conditional)
309
+
310
+ *Accumulated mistakes the AI must not repeat in this project. These are added over time via `/learn`
311
+ or accepted during `/review-code`, `/fix-bug`, `/debug`.*
312
+
313
+ Resolve the lessons file path:
314
+ - Use `paths.lessons_file` if set (may be service-overridden in umbrella mode, Step 1.6)
315
+ - Else default `specs/domain-knowledge/lessons-learned.md`
316
+ - In umbrella/service mode (when `service_root` is set), if `paths.lessons_file` is unset, default to `{service_root}/.agent/project-lessons.md`
317
+
318
+ If the file exists, read it and store ALL lessons as **ACTIVE GUARDRAILS** for the session:
319
+ - Treat each lesson's **Rule** as a hard constraint — same priority as CLAUDE.md coding standards (Step 3).
320
+ - Before generating or modifying any artifact (PRD, BDD, tech-doc, code, test), check the output against every lesson whose `category` matches the current command AND whose `scope` matches the target (domain / file).
321
+ - If a generated output would violate a lesson → correct it **before** presenting, and note which lesson (`L-NNN`) was applied.
322
+
323
+ If the file does not exist → skip silently (no lessons captured yet).
324
+
325
+ ---
326
+
277
327
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
278
328
 
279
329
  After loading all context, synthesize and output a compact summary block.
@@ -289,7 +339,9 @@ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Ser
289
339
  Ticket : {ticket_prefix}-
290
340
  Dict : {loaded — N canonical terms, M banned terms | missing}
291
341
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
342
+ Lessons : {loaded — N guardrails | none yet}
292
343
  Service : {active_service} ({active_service_module}) | single-service
344
+ Svc Root : {service_root} — conventions + trace_dir loaded from service config | —
293
345
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
294
346
  ```
295
347
 
@@ -562,6 +614,11 @@ Suggest the logical next command based on workflow phase:
562
614
  | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
563
615
  | /fix-bug | Create PR and link to ticket |
564
616
  | /debug | `/fix-bug {ticket-id}` if fix needed |
617
+ | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
618
+ | /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
619
+ | /learn | Continue working — lesson applies on next command |
620
+ | /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
621
+ | /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
565
622
 
566
623
  Format the footer as:
567
624
  ```
@@ -594,3 +651,98 @@ See CLAUDE.md §{section}
594
651
  - To fully fix → /fix-bug {TICKET_ID}
595
652
  - Just needed analysis → done
596
653
  ```
654
+
655
+ ---
656
+
657
+ ## Offer to Record a Lesson (optional)
658
+
659
+ If the root cause is a **mistake the AI made when generating code and could repeat**
660
+ (not an environment/config issue or external cause), ask:
661
+
662
+ ```
663
+ This looks like a repeatable AI mistake. Record it as a project lesson? (Y/N)
664
+ ```
665
+
666
+ If `Y` → run the capture procedure below with `source=/debug`, an appropriate `category`
667
+ (usually `code-gen`), and `scope` = the affected domain or file glob.
668
+
669
+ # Capture Lesson — Record a Recurring Mistake as a Guardrail
670
+
671
+ Reusable procedure to persist a "lesson" so the AI does not repeat a mistake in this project.
672
+ Used by `/learn` (manual) and offered by `/review-code`, `/fix-bug`, `/debug` (auto).
673
+
674
+ > **Project memory, not model training.** A lesson is plain text injected into context at the
675
+ > start of every command (context-loader Step 6.7). Functionally this stops the repeat — the AI
676
+ > sees the guardrail before it generates. No model weights change.
677
+
678
+ ## L1 — Resolve the lessons file
679
+
680
+ Resolve `lessons_path` in this order:
681
+ 1. `paths.lessons_file` from loaded context (may be service-overridden in umbrella mode, Step 1.6)
682
+ 2. Default `specs/domain-knowledge/lessons-learned.md` (single-service)
683
+ 3. In umbrella/service mode (when `service_root` is set) default `{service_root}/.agent/project-lessons.md`
684
+
685
+ ## L2 — Build the lesson
686
+
687
+ Gather these fields — from `$ARGUMENTS` (for `/learn`) or from the calling command's findings
688
+ (for `/review-code`, `/fix-bug`, `/debug`):
689
+
690
+ | Field | Meaning |
691
+ |-------|---------|
692
+ | `category` | one of: `code-gen` \| `bdd` \| `tech-docs` \| `tests` \| `prd` \| `general` |
693
+ | `title` | short phrase naming the mistake |
694
+ | `mistake` | concretely, what the AI did wrong |
695
+ | `rule` | imperative correction — "Always …" / "Never …" — testable, not vague |
696
+ | `scope` | where it applies: a domain, a file glob (e.g. `*Controller.*`), or `all` |
697
+ | `source` | how captured: `/learn` \| `/review-code {UC-ID}` \| `/fix-bug {TICKET}` \| `/debug` |
698
+
699
+ If `rule` is vague (e.g. "be careful"), rewrite it into a concrete, checkable instruction before saving.
700
+
701
+ ## L3 — De-duplicate
702
+
703
+ Read existing lessons in `lessons_path`. If one already covers the same mistake:
704
+ - **Refine** that entry (tighten the Rule, widen/narrow Scope, bump Date, append the new Source) — do NOT add a duplicate.
705
+
706
+ Otherwise assign the next id `L-{NNN}` = (highest existing number + 1), zero-padded to 3 digits.
707
+
708
+ ## L4 — Write
709
+
710
+ If `lessons_path` does not exist, create it with this header first:
711
+
712
+ ```markdown
713
+ # Project Lessons — Learned Guardrails
714
+
715
+ > Mistakes the AI must NOT repeat in this project. Loaded by context-loader at the start of
716
+ > every command and treated as hard constraints (same priority as CLAUDE.md coding standards).
717
+ > Add with /learn, or accept the prompt during /review-code, /fix-bug, /debug.
718
+ > Commit this file so the whole team shares the guardrails.
719
+
720
+ | Category | Applies to |
721
+ |----------|-----------|
722
+ | code-gen | /generate-code output |
723
+ | bdd | /generate-bdd output |
724
+ | tech-docs | /generate-tech-docs output |
725
+ | tests | /generate-tests output |
726
+ | prd | /generate-prd, /refine-prd output |
727
+ | general | every command |
728
+
729
+ ---
730
+ ```
731
+
732
+ Insert the new lesson directly under the `---` separator (**newest first**), in this exact shape:
733
+
734
+ ```markdown
735
+ ### L-{NNN} — [{category}] {title}
736
+ - **Date**: {today YYYY-MM-DD}
737
+ - **Scope**: {scope}
738
+ - **Mistake**: {mistake}
739
+ - **Rule**: {rule}
740
+ - **Source**: {source}
741
+
742
+ ```
743
+
744
+ ## L5 — Confirm
745
+
746
+ Print: `📝 Lesson {id} recorded → {lessons_path} ([{category}] {title})`
747
+ Then remind: `Commit {lessons_path} so the team shares this guardrail.`
748
+
@@ -178,6 +178,37 @@ If `services` section is present:
178
178
  - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
179
179
  - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
180
180
  - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
181
+ - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
182
+ - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
183
+
184
+ > **Why under `spec_source`:** tester feedback (`/report-bug`, `/propose-scenario`) must land in the **shared spec repo** so PO/Dev see it when they `/sync`. In single-service mode (no `spec_source`), these default to `feedback/bug-reports` and `feedback/bdd-proposals` at repo root — still shared, same repo.
185
+
186
+ ---
187
+
188
+ ## Step 1.6 — [SERVICE CONVENTIONS] Load service-specific conventions (umbrella mode)
189
+
190
+ *Skip this step entirely if `active_service` is `"unresolved"` or context is single-service mode.*
191
+
192
+ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-service/`):
193
+
194
+ **1. Locate service config** — try in priority order:
195
+ - `{active_service}/.agent/project-context.yaml`
196
+ - `{active_service}/project-context.yaml`
197
+
198
+ **2. If found, override with service-specific values:**
199
+
200
+ | Variable | Source |
201
+ |----------|--------|
202
+ | `conventions.test_command` | service's `conventions.test_command` |
203
+ | `conventions.build_command` | service's `conventions.build_command` |
204
+ | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` — default: `{active_service}/.trace` |
205
+ | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
206
+
207
+ **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
208
+ - Shell commands (`/run-tests`, `/generate-tests`) run **from within** `service_root`
209
+ - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
210
+
211
+ **4. If service config not found** — keep umbrella defaults, still set `service_root = {active_service}` (path anchor is always needed even without a config override).
181
212
 
182
213
  ---
183
214
 
@@ -271,6 +302,25 @@ These two variables (`active_module`, `platform_type`) are the canonical source
271
302
 
272
303
  ---
273
304
 
305
+ ## Step 6.7 — [GUARDRAILS] Load Project Lessons (conditional)
306
+
307
+ *Accumulated mistakes the AI must not repeat in this project. These are added over time via `/learn`
308
+ or accepted during `/review-code`, `/fix-bug`, `/debug`.*
309
+
310
+ Resolve the lessons file path:
311
+ - Use `paths.lessons_file` if set (may be service-overridden in umbrella mode, Step 1.6)
312
+ - Else default `specs/domain-knowledge/lessons-learned.md`
313
+ - In umbrella/service mode (when `service_root` is set), if `paths.lessons_file` is unset, default to `{service_root}/.agent/project-lessons.md`
314
+
315
+ If the file exists, read it and store ALL lessons as **ACTIVE GUARDRAILS** for the session:
316
+ - Treat each lesson's **Rule** as a hard constraint — same priority as CLAUDE.md coding standards (Step 3).
317
+ - Before generating or modifying any artifact (PRD, BDD, tech-doc, code, test), check the output against every lesson whose `category` matches the current command AND whose `scope` matches the target (domain / file).
318
+ - If a generated output would violate a lesson → correct it **before** presenting, and note which lesson (`L-NNN`) was applied.
319
+
320
+ If the file does not exist → skip silently (no lessons captured yet).
321
+
322
+ ---
323
+
274
324
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
275
325
 
276
326
  After loading all context, synthesize and output a compact summary block.
@@ -286,7 +336,9 @@ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Ser
286
336
  Ticket : {ticket_prefix}-
287
337
  Dict : {loaded — N canonical terms, M banned terms | missing}
288
338
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
339
+ Lessons : {loaded — N guardrails | none yet}
289
340
  Service : {active_service} ({active_service_module}) | single-service
341
+ Svc Root : {service_root} — conventions + trace_dir loaded from service config | —
290
342
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
291
343
  ```
292
344
 
@@ -496,6 +548,11 @@ Suggest the logical next command based on workflow phase:
496
548
  | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
497
549
  | /fix-bug | Create PR and link to ticket |
498
550
  | /debug | `/fix-bug {ticket-id}` if fix needed |
551
+ | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
552
+ | /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
553
+ | /learn | Continue working — lesson applies on next command |
554
+ | /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
555
+ | /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
499
556
 
500
557
  Format the footer as:
501
558
  ```