@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,211 @@
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
+ # Report Footer — Standard Command Output Format
129
+
130
+ Every command report must end with this standard footer section.
131
+
132
+ ## Status Badge
133
+
134
+ Choose one based on outcome:
135
+ - `✅ Complete` — all steps succeeded, no issues found
136
+ - `❌ Failed` — command could not complete due to a blocking error
137
+ - `⚠️ Warnings` — completed with non-blocking issues that should be reviewed
138
+
139
+ ## Output Artifacts
140
+
141
+ List every file created or modified by this command:
142
+ ```
143
+ Output Artifacts:
144
+ {created|updated} {file-path} ({brief description})
145
+ {created|updated} {file-path} ({brief description})
146
+ ```
147
+
148
+ If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
149
+
150
+ ## Next Command Suggestion
151
+
152
+ Suggest the logical next command based on workflow phase:
153
+
154
+ | Current command | Suggest next |
155
+ |-------------------------|-----------------------------------------------|
156
+ | /setup-ai-first | `/define-product` to start your first feature |
157
+ | /define-product | `/generate-prd {product-definition-file}` |
158
+ | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
159
+ | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
160
+ | /review-context (PRD) | FE/App: `/generate-design-spec {prd-file}` (then BDD after sign-off); BE: `/generate-bdd {prd-file}` directly; fix PRD if NEEDS_FIX |
161
+ | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
162
+ | /generate-bdd | `/review-context {feature-file}` to verify coverage |
163
+ | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
164
+ | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
165
+ | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
166
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
167
+ | /generate-tests | `/run-tests {UC-ID}` |
168
+ | /run-tests (passing) | `/review-code {UC-ID}` |
169
+ | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
170
+ | /review-code | `/smoke-test {UC-ID}` or create PR |
171
+ | /smoke-test | Create PR and link to ticket |
172
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
173
+ | /fix-bug | Create PR and link to ticket |
174
+ | /debug | `/fix-bug {ticket-id}` if fix needed |
175
+ | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
176
+ | /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
177
+ | /learn | Continue working — lesson applies on next command |
178
+ | /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
179
+ | /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
180
+
181
+ Format the footer as:
182
+ ```
183
+ ---
184
+ Status : {badge}
185
+ {Output Artifacts block}
186
+ Next : {suggested command with example arguments}
187
+ ```
188
+
189
+
190
+ ```
191
+ /update-framework — v{current} → v{latest}
192
+
193
+ ✅ Framework upgraded
194
+ Updated : {N} command files, {M} step files
195
+ New : {list any new commands, e.g. /some-new-command}
196
+ Removed : {list any removed commands, or "none"}
197
+
198
+ Your content was preserved:
199
+ project-context.yaml, CLAUDE.md, domain-knowledge/, .trace/ — untouched
200
+
201
+ Review & commit:
202
+ git diff .agent/
203
+ git add .agent/ .claude/commands/
204
+ git commit -m "chore: upgrade spec-driven-dev v{current} → v{latest}"
205
+ {umbrella mode: this is the umbrella root — service submodules need no framework update}
206
+
207
+ ---
208
+ Status : ✅ Complete | ⚠️ Warnings
209
+ Output Artifacts: refreshed .agent/ framework files, .claude/commands/ shortcuts
210
+ Next : review git diff, then commit | /sync to refresh project content
211
+ ```
@@ -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
  ```
@@ -205,6 +205,37 @@ If `services` section is present:
205
205
  - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
206
206
  - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
207
207
  - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
208
+ - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
209
+ - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
210
+
211
+ > **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.
212
+
213
+ ---
214
+
215
+ ## Step 1.6 — [SERVICE CONVENTIONS] Load service-specific conventions (umbrella mode)
216
+
217
+ *Skip this step entirely if `active_service` is `"unresolved"` or context is single-service mode.*
218
+
219
+ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-service/`):
220
+
221
+ **1. Locate service config** — try in priority order:
222
+ - `{active_service}/.agent/project-context.yaml`
223
+ - `{active_service}/project-context.yaml`
224
+
225
+ **2. If found, override with service-specific values:**
226
+
227
+ | Variable | Source |
228
+ |----------|--------|
229
+ | `conventions.test_command` | service's `conventions.test_command` |
230
+ | `conventions.build_command` | service's `conventions.build_command` |
231
+ | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` — default: `{active_service}/.trace` |
232
+ | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
233
+
234
+ **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
235
+ - Shell commands (`/run-tests`, `/generate-tests`) run **from within** `service_root`
236
+ - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
237
+
238
+ **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).
208
239
 
209
240
  ---
210
241
 
@@ -298,6 +329,25 @@ These two variables (`active_module`, `platform_type`) are the canonical source
298
329
 
299
330
  ---
300
331
 
332
+ ## Step 6.7 — [GUARDRAILS] Load Project Lessons (conditional)
333
+
334
+ *Accumulated mistakes the AI must not repeat in this project. These are added over time via `/learn`
335
+ or accepted during `/review-code`, `/fix-bug`, `/debug`.*
336
+
337
+ Resolve the lessons file path:
338
+ - Use `paths.lessons_file` if set (may be service-overridden in umbrella mode, Step 1.6)
339
+ - Else default `specs/domain-knowledge/lessons-learned.md`
340
+ - In umbrella/service mode (when `service_root` is set), if `paths.lessons_file` is unset, default to `{service_root}/.agent/project-lessons.md`
341
+
342
+ If the file exists, read it and store ALL lessons as **ACTIVE GUARDRAILS** for the session:
343
+ - Treat each lesson's **Rule** as a hard constraint — same priority as CLAUDE.md coding standards (Step 3).
344
+ - 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).
345
+ - If a generated output would violate a lesson → correct it **before** presenting, and note which lesson (`L-NNN`) was applied.
346
+
347
+ If the file does not exist → skip silently (no lessons captured yet).
348
+
349
+ ---
350
+
301
351
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
302
352
 
303
353
  After loading all context, synthesize and output a compact summary block.
@@ -313,7 +363,9 @@ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Ser
313
363
  Ticket : {ticket_prefix}-
314
364
  Dict : {loaded — N canonical terms, M banned terms | missing}
315
365
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
366
+ Lessons : {loaded — N guardrails | none yet}
316
367
  Service : {active_service} ({active_service_module}) | single-service
368
+ Svc Root : {service_root} — conventions + trace_dir loaded from service config | —
317
369
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
318
370
  ```
319
371
 
@@ -462,6 +514,11 @@ Suggest the logical next command based on workflow phase:
462
514
  | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
463
515
  | /fix-bug | Create PR and link to ticket |
464
516
  | /debug | `/fix-bug {ticket-id}` if fix needed |
517
+ | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
518
+ | /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
519
+ | /learn | Continue working — lesson applies on next command |
520
+ | /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
521
+ | /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
465
522
 
466
523
  Format the footer as:
467
524
  ```
@@ -575,6 +632,11 @@ Suggest the logical next command based on workflow phase:
575
632
  | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
576
633
  | /fix-bug | Create PR and link to ticket |
577
634
  | /debug | `/fix-bug {ticket-id}` if fix needed |
635
+ | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
636
+ | /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
637
+ | /learn | Continue working — lesson applies on next command |
638
+ | /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
639
+ | /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
578
640
 
579
641
  Format the footer as:
580
642
  ```
@@ -120,6 +120,37 @@ If `services` section is present:
120
120
  - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
121
121
  - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
122
122
  - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
123
+ - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
124
+ - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
125
+
126
+ > **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.
127
+
128
+ ---
129
+
130
+ ## Step 1.6 — [SERVICE CONVENTIONS] Load service-specific conventions (umbrella mode)
131
+
132
+ *Skip this step entirely if `active_service` is `"unresolved"` or context is single-service mode.*
133
+
134
+ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-service/`):
135
+
136
+ **1. Locate service config** — try in priority order:
137
+ - `{active_service}/.agent/project-context.yaml`
138
+ - `{active_service}/project-context.yaml`
139
+
140
+ **2. If found, override with service-specific values:**
141
+
142
+ | Variable | Source |
143
+ |----------|--------|
144
+ | `conventions.test_command` | service's `conventions.test_command` |
145
+ | `conventions.build_command` | service's `conventions.build_command` |
146
+ | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` — default: `{active_service}/.trace` |
147
+ | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
148
+
149
+ **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
150
+ - Shell commands (`/run-tests`, `/generate-tests`) run **from within** `service_root`
151
+ - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
152
+
153
+ **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).
123
154
 
124
155
  ---
125
156
 
@@ -213,6 +244,25 @@ These two variables (`active_module`, `platform_type`) are the canonical source
213
244
 
214
245
  ---
215
246
 
247
+ ## Step 6.7 — [GUARDRAILS] Load Project Lessons (conditional)
248
+
249
+ *Accumulated mistakes the AI must not repeat in this project. These are added over time via `/learn`
250
+ or accepted during `/review-code`, `/fix-bug`, `/debug`.*
251
+
252
+ Resolve the lessons file path:
253
+ - Use `paths.lessons_file` if set (may be service-overridden in umbrella mode, Step 1.6)
254
+ - Else default `specs/domain-knowledge/lessons-learned.md`
255
+ - In umbrella/service mode (when `service_root` is set), if `paths.lessons_file` is unset, default to `{service_root}/.agent/project-lessons.md`
256
+
257
+ If the file exists, read it and store ALL lessons as **ACTIVE GUARDRAILS** for the session:
258
+ - Treat each lesson's **Rule** as a hard constraint — same priority as CLAUDE.md coding standards (Step 3).
259
+ - 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).
260
+ - If a generated output would violate a lesson → correct it **before** presenting, and note which lesson (`L-NNN`) was applied.
261
+
262
+ If the file does not exist → skip silently (no lessons captured yet).
263
+
264
+ ---
265
+
216
266
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
217
267
 
218
268
  After loading all context, synthesize and output a compact summary block.
@@ -228,7 +278,9 @@ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Ser
228
278
  Ticket : {ticket_prefix}-
229
279
  Dict : {loaded — N canonical terms, M banned terms | missing}
230
280
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
281
+ Lessons : {loaded — N guardrails | none yet}
231
282
  Service : {active_service} ({active_service_module}) | single-service
283
+ Svc Root : {service_root} — conventions + trace_dir loaded from service config | —
232
284
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
233
285
  ```
234
286
 
@@ -400,6 +452,11 @@ Suggest the logical next command based on workflow phase:
400
452
  | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
401
453
  | /fix-bug | Create PR and link to ticket |
402
454
  | /debug | `/fix-bug {ticket-id}` if fix needed |
455
+ | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
456
+ | /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
457
+ | /learn | Continue working — lesson applies on next command |
458
+ | /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
459
+ | /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
403
460
 
404
461
  Format the footer as:
405
462
  ```
@@ -539,6 +596,11 @@ Suggest the logical next command based on workflow phase:
539
596
  | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
540
597
  | /fix-bug | Create PR and link to ticket |
541
598
  | /debug | `/fix-bug {ticket-id}` if fix needed |
599
+ | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
600
+ | /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
601
+ | /learn | Continue working — lesson applies on next command |
602
+ | /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
603
+ | /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
542
604
 
543
605
  Format the footer as:
544
606
  ```
@@ -635,6 +697,11 @@ Suggest the logical next command based on workflow phase:
635
697
  | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
636
698
  | /fix-bug | Create PR and link to ticket |
637
699
  | /debug | `/fix-bug {ticket-id}` if fix needed |
700
+ | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
701
+ | /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
702
+ | /learn | Continue working — lesson applies on next command |
703
+ | /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
704
+ | /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
638
705
 
639
706
  Format the footer as:
640
707
  ```
@@ -194,6 +194,37 @@ If `services` section is present:
194
194
  - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
195
195
  - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
196
196
  - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
197
+ - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
198
+ - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
199
+
200
+ > **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.
201
+
202
+ ---
203
+
204
+ ## Step 1.6 — [SERVICE CONVENTIONS] Load service-specific conventions (umbrella mode)
205
+
206
+ *Skip this step entirely if `active_service` is `"unresolved"` or context is single-service mode.*
207
+
208
+ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-service/`):
209
+
210
+ **1. Locate service config** — try in priority order:
211
+ - `{active_service}/.agent/project-context.yaml`
212
+ - `{active_service}/project-context.yaml`
213
+
214
+ **2. If found, override with service-specific values:**
215
+
216
+ | Variable | Source |
217
+ |----------|--------|
218
+ | `conventions.test_command` | service's `conventions.test_command` |
219
+ | `conventions.build_command` | service's `conventions.build_command` |
220
+ | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` — default: `{active_service}/.trace` |
221
+ | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
222
+
223
+ **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
224
+ - Shell commands (`/run-tests`, `/generate-tests`) run **from within** `service_root`
225
+ - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
226
+
227
+ **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).
197
228
 
198
229
  ---
199
230
 
@@ -287,6 +318,25 @@ These two variables (`active_module`, `platform_type`) are the canonical source
287
318
 
288
319
  ---
289
320
 
321
+ ## Step 6.7 — [GUARDRAILS] Load Project Lessons (conditional)
322
+
323
+ *Accumulated mistakes the AI must not repeat in this project. These are added over time via `/learn`
324
+ or accepted during `/review-code`, `/fix-bug`, `/debug`.*
325
+
326
+ Resolve the lessons file path:
327
+ - Use `paths.lessons_file` if set (may be service-overridden in umbrella mode, Step 1.6)
328
+ - Else default `specs/domain-knowledge/lessons-learned.md`
329
+ - In umbrella/service mode (when `service_root` is set), if `paths.lessons_file` is unset, default to `{service_root}/.agent/project-lessons.md`
330
+
331
+ If the file exists, read it and store ALL lessons as **ACTIVE GUARDRAILS** for the session:
332
+ - Treat each lesson's **Rule** as a hard constraint — same priority as CLAUDE.md coding standards (Step 3).
333
+ - 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).
334
+ - If a generated output would violate a lesson → correct it **before** presenting, and note which lesson (`L-NNN`) was applied.
335
+
336
+ If the file does not exist → skip silently (no lessons captured yet).
337
+
338
+ ---
339
+
290
340
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
291
341
 
292
342
  After loading all context, synthesize and output a compact summary block.
@@ -302,7 +352,9 @@ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Ser
302
352
  Ticket : {ticket_prefix}-
303
353
  Dict : {loaded — N canonical terms, M banned terms | missing}
304
354
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
355
+ Lessons : {loaded — N guardrails | none yet}
305
356
  Service : {active_service} ({active_service_module}) | single-service
357
+ Svc Root : {service_root} — conventions + trace_dir loaded from service config | —
306
358
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
307
359
  ```
308
360
 
@@ -429,6 +481,11 @@ Suggest the logical next command based on workflow phase:
429
481
  | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
430
482
  | /fix-bug | Create PR and link to ticket |
431
483
  | /debug | `/fix-bug {ticket-id}` if fix needed |
484
+ | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
485
+ | /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
486
+ | /learn | Continue working — lesson applies on next command |
487
+ | /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
488
+ | /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
432
489
 
433
490
  Format the footer as:
434
491
  ```