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

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 (89) 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 +75 -0
  13. package/commands/generate-prd.tmpl +18 -0
  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 +57 -0
  23. package/commands/report-bug.md +543 -0
  24. package/commands/report-bug.tmpl +131 -0
  25. package/commands/review-code.md +153 -0
  26. package/commands/review-code.tmpl +17 -0
  27. package/commands/review-context.md +57 -0
  28. package/commands/review-tech-docs.md +139 -4
  29. package/commands/review-tech-docs.tmpl +82 -4
  30. package/commands/run-tests.md +82 -0
  31. package/commands/run-tests.tmpl +25 -0
  32. package/commands/setup-ai-first.md +15 -5
  33. package/commands/setup-ai-first.tmpl +10 -5
  34. package/commands/smoke-test.md +57 -0
  35. package/commands/sync.md +405 -0
  36. package/commands/sync.tmpl +345 -0
  37. package/commands/update-framework.md +211 -0
  38. package/commands/update-framework.tmpl +151 -0
  39. package/commands/validate-traces.md +115 -2
  40. package/commands/validate-traces.tmpl +58 -2
  41. package/core/FRAMEWORK_VERSION +1 -1
  42. package/core/commands/debug.md +152 -0
  43. package/core/commands/define-product.md +57 -0
  44. package/core/commands/fix-bug.md +153 -0
  45. package/core/commands/generate-bdd.md +277 -13
  46. package/core/commands/generate-code.md +154 -2
  47. package/core/commands/generate-design-spec.md +57 -0
  48. package/core/commands/generate-prd.md +75 -0
  49. package/core/commands/generate-spec-manifest.md +57 -0
  50. package/core/commands/generate-tech-docs.md +79 -1
  51. package/core/commands/generate-tests.md +57 -0
  52. package/core/commands/learn.md +554 -0
  53. package/core/commands/propose-scenario.md +521 -0
  54. package/core/commands/refine-prd.md +57 -0
  55. package/core/commands/report-bug.md +543 -0
  56. package/core/commands/review-code.md +153 -0
  57. package/core/commands/review-context.md +57 -0
  58. package/core/commands/review-tech-docs.md +139 -4
  59. package/core/commands/run-tests.md +82 -0
  60. package/core/commands/setup-ai-first.md +15 -5
  61. package/core/commands/smoke-test.md +57 -0
  62. package/core/commands/sync.md +405 -0
  63. package/core/commands/update-framework.md +211 -0
  64. package/core/commands/validate-traces.md +115 -2
  65. package/core/skills/code/SKILL.md +62 -0
  66. package/core/skills/debug/SKILL.md +67 -0
  67. package/core/skills/design-spec/SKILL.md +57 -0
  68. package/core/skills/discovery/SKILL.md +57 -0
  69. package/core/skills/prd/SKILL.md +10 -0
  70. package/core/skills/setup-ai-first/SKILL.md +5 -0
  71. package/core/skills/spec/SKILL.md +10 -0
  72. package/core/skills/test/SKILL.md +119 -0
  73. package/core/steps/capture-lesson.md +79 -0
  74. package/core/steps/context-loader.md +52 -0
  75. package/core/steps/report-footer.md +5 -0
  76. package/core/templates/project-context.yaml +11 -0
  77. package/package.json +1 -1
  78. package/skills/code/SKILL.md +62 -0
  79. package/skills/debug/SKILL.md +67 -0
  80. package/skills/design-spec/SKILL.md +57 -0
  81. package/skills/discovery/SKILL.md +57 -0
  82. package/skills/prd/SKILL.md +10 -0
  83. package/skills/setup-ai-first/SKILL.md +5 -0
  84. package/skills/spec/SKILL.md +10 -0
  85. package/skills/test/SKILL.md +119 -0
  86. package/steps/capture-lesson.md +79 -0
  87. package/steps/context-loader.md +52 -0
  88. package/steps/report-footer.md +5 -0
  89. package/templates/project-context.yaml +11 -0
@@ -122,6 +122,59 @@ Check all standard sections are present and non-empty:
122
122
 
123
123
  → All T6 missing-section findings are **auto-fixable**: AI adds skeleton section with prompts.
124
124
 
125
+ ### T7 — Cross-Team API Contract Review
126
+
127
+ *Only applies when ALL of the following are true:*
128
+ *1. Source BDD has `@trace.platform: system`.*
129
+ *2. Tech-doc header does NOT have `@trace.api_source: existing`.*
130
+
131
+ *If `@trace.api_source: existing` → **skip T7 entirely**. Contract đã được PO xác định trong PRD — không có API design mới để đồng thuận.*
132
+
133
+ This dimension ensures FE, App, and BE teams all agree on the API contract before implementation starts.
134
+
135
+ **Step 1 — Check sign-off status in tech-doc header:**
136
+
137
+ Read the `@trace.sign_off` block in the tech doc header. If absent → add it as a finding (auto-fixable: add skeleton).
138
+
139
+ ```yaml
140
+ # @trace.sign_off:
141
+ # be_team: pending # author — set to "done" when BE satisfied with design
142
+ # fe_team: pending # FE/Web — must confirm contract matches web BDD expectations
143
+ # app_team: pending # App — must confirm contract matches app BDD expectations (if applicable)
144
+ # sa: pending # SA/Tech Lead — final approval
145
+ ```
146
+
147
+ **Step 2 — Contract vs BDD cross-check:**
148
+
149
+ Load the web and app BDDs for this TICKET-ID (from `{paths.specs_dir}/{domain}/web/` and `{paths.specs_dir}/{domain}/app/` in the spec submodule or spec repo).
150
+
151
+ For each platform BDD, verify the tech doc's API contract satisfies the BDD's `Then` clauses:
152
+
153
+ | Check | Severity |
154
+ |---|---|
155
+ | Response fields in API contract don't cover what web BDD `Then` expects | Critical |
156
+ | Response fields in API contract don't cover what app BDD `Then` expects | Critical |
157
+ | Error response shape doesn't match what platform BDDs expect | Major |
158
+ | System BDD `@system.resolution` annotation contradicts the API contract design | Critical |
159
+
160
+ **Step 3 — Pending sign-off report:**
161
+
162
+ After the review, list which sign-offs are still `pending`:
163
+
164
+ ```
165
+ ⏳ Pending sign-offs before tech docs can be approved:
166
+ fe_team — FE/Web team must confirm API contract matches web BDD expectations
167
+ app_team — App team must confirm API contract matches app BDD expectations
168
+ sa — SA/Tech Lead final approval
169
+
170
+ Once sign-offs are collected → update @trace.sign_off in tech doc header, then re-run /review-tech-docs.
171
+ Tech docs cannot be set to "approved" while any required sign-off is pending.
172
+ ```
173
+
174
+ **Approval gate:**
175
+ - If `be_team: done` AND `fe_team: done` AND `app_team: done` (or N/A) AND `sa: done` → tech docs may be set to `approved`
176
+ - Otherwise → `@trace.status` stays `in-review` — `generate-code` is blocked
177
+
125
178
  ---
126
179
 
127
180
  ## Write Findings File
@@ -135,10 +188,18 @@ domain: "{domain}"
135
188
  generated_at: "{ISO datetime}"
136
189
  review_type: "tech-design"
137
190
  status: "pending_review"
191
+ is_system_bdd: {true | false} # true if source BDD has @trace.platform: system
192
+
193
+ sign_off: # only present when is_system_bdd: true
194
+ be_team: pending # read from @trace.sign_off in tech-doc header
195
+ fe_team: pending
196
+ app_team: pending # "n/a" if project has no app platform
197
+ sa: pending
198
+ sign_off_gate: blocked # blocked | ready — "ready" only when all required are "done"
138
199
 
139
200
  findings:
140
201
  - id: "F001"
141
- check_id: "T1" # T1–T6
202
+ check_id: "T1" # T1–T7
142
203
  severity: "critical" # critical | major | minor
143
204
  section: "{section heading or component name where issue was found}"
144
205
  finding: "{clear description of the violation or gap}"
@@ -152,6 +213,7 @@ summary:
152
213
  auto_fixable: {N}
153
214
  requires_human_decision: {N}
154
215
  recommendation: "APPROVED | NEEDS_REVISION | BLOCKED"
216
+ sign_off_gate: "{blocked — pending: fe_team, app_team, sa | ready}"
155
217
  ```
156
218
 
157
219
  ## Report
@@ -164,9 +226,17 @@ UC: {UC-ID} | Domain: {domain}
164
226
  Findings: {total} | 🔴 Critical: {N} | 🟡 Major: {N} | 🟢 Minor: {N}
165
227
  Auto-fixable: {N} | Needs human decision: {N}
166
228
 
229
+ Sign-off gate (system BDD only):
230
+ be_team : {done | pending}
231
+ fe_team : {done | pending} ← {name / "needs sign-off" }
232
+ app_team : {done | pending | n/a}
233
+ sa : {done | pending}
234
+ Gate : {🔒 BLOCKED — pending: fe_team, sa | ✅ READY}
235
+
167
236
  Findings file: {paths.refinement_dir}/{uc-id}-tech-review-findings.yaml
168
237
  Next: Open in Review Board → Accept/Modify/Reject each finding
169
238
  Then run: /review-tech-docs --resume {tech-design-file}
239
+ After all sign-offs collected → update @trace.sign_off in tech doc, re-run review
170
240
  ```
171
241
 
172
242
  ---
@@ -201,7 +271,10 @@ Review Board "Modify" note. Apply exactly what the note says. Do not invent the
201
271
 
202
272
  Edit the tech-doc file directly:
203
273
  1. Find `@trace.revision:` in the header — increment its integer value by 1.
204
- 2. Find `@trace.status:` in the header — set its value to `draft`.
274
+ 2. Find `@trace.status:` in the header:
275
+ - If sign_off_gate = `ready` (all sign-offs done) → set to `approved`
276
+ - Otherwise → set to `in-review` (blocks `/generate-code`)
277
+ 3. If `@trace.sign_off` block is absent and this is a system BDD tech doc → add it with all values `pending`.
205
278
 
206
279
  Write both changes to the file.
207
280
 
@@ -223,8 +296,13 @@ Changes:
223
296
  - {change 2}
224
297
 
225
298
  Revision : {old} → {new}
226
- Status : reset to draft (re-approval required)
299
+ Status : {approved | in-review}
300
+
301
+ Sign-off : {✅ All done — status set to approved
302
+ | 🔒 Pending: fe_team, sa — status set to in-review
303
+ Update @trace.sign_off in tech doc when each team confirms, then re-run /review-tech-docs}
227
304
 
228
305
  Re-run /review-tech-docs {file} to confirm 0 remaining critical findings.
229
- Next: /generate-code {feature-file}
306
+ Next: {/generate-code {feature-file} ← only if status = approved
307
+ | Collect pending sign-offs → update @trace.sign_off → re-run /review-tech-docs}
230
308
  ```
@@ -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
 
@@ -317,6 +369,31 @@ Use it to select the correct run command and error analysis table below.
317
369
 
318
370
  ---
319
371
 
372
+ ## Submodule Working Directory
373
+
374
+ *Skip this section if `service_root` is not set (single-service mode).*
375
+
376
+ When running in **umbrella/submodule mode** (`service_root` was resolved in context-loader Step 1.6):
377
+
378
+ - All commands in the **Run** section below must execute from within `{service_root}/`
379
+ - `conventions.test_command` was loaded from `{service_root}/.agent/project-context.yaml` — already service-specific
380
+ - Prefix every shell command with `cd {service_root} &&`:
381
+
382
+ ```bash
383
+ cd {service_root}
384
+
385
+ # Then run any of the commands in the Run section below, e.g.:
386
+ {conventions.test_command}
387
+ mvn test -Dtest={ClassName} # java-spring
388
+ go test ./... -run Test{FunctionName} # golang
389
+ npx vitest run src/... # web-frontend
390
+ flutter test test/{domain}/... # flutter
391
+ ```
392
+
393
+ > **Why cd?** Claude Code session is opened at umbrella root. Each service submodule has its own build tool, test runner, and dependency tree — tests must run from inside the service directory.
394
+
395
+ ---
396
+
320
397
  ## Run
321
398
 
322
399
  ### If `platform_type = backend`
@@ -494,6 +571,11 @@ Suggest the logical next command based on workflow phase:
494
571
  | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
495
572
  | /fix-bug | Create PR and link to ticket |
496
573
  | /debug | `/fix-bug {ticket-id}` if fix needed |
574
+ | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
575
+ | /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
576
+ | /learn | Continue working — lesson applies on next command |
577
+ | /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
578
+ | /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
497
579
 
498
580
  Format the footer as:
499
581
  ```
@@ -17,6 +17,31 @@ Use it to select the correct run command and error analysis table below.
17
17
 
18
18
  ---
19
19
 
20
+ ## Submodule Working Directory
21
+
22
+ *Skip this section if `service_root` is not set (single-service mode).*
23
+
24
+ When running in **umbrella/submodule mode** (`service_root` was resolved in context-loader Step 1.6):
25
+
26
+ - All commands in the **Run** section below must execute from within `{service_root}/`
27
+ - `conventions.test_command` was loaded from `{service_root}/.agent/project-context.yaml` — already service-specific
28
+ - Prefix every shell command with `cd {service_root} &&`:
29
+
30
+ ```bash
31
+ cd {service_root}
32
+
33
+ # Then run any of the commands in the Run section below, e.g.:
34
+ {conventions.test_command}
35
+ mvn test -Dtest={ClassName} # java-spring
36
+ go test ./... -run Test{FunctionName} # golang
37
+ npx vitest run src/... # web-frontend
38
+ flutter test test/{domain}/... # flutter
39
+ ```
40
+
41
+ > **Why cd?** Claude Code session is opened at umbrella root. Each service submodule has its own build tool, test runner, and dependency tree — tests must run from inside the service directory.
42
+
43
+ ---
44
+
20
45
  ## Run
21
46
 
22
47
  ### If `platform_type = backend`
@@ -417,6 +417,11 @@ Suggest the logical next command based on workflow phase:
417
417
  | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
418
418
  | /fix-bug | Create PR and link to ticket |
419
419
  | /debug | `/fix-bug {ticket-id}` if fix needed |
420
+ | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
421
+ | /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
422
+ | /learn | Continue working — lesson applies on next command |
423
+ | /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
424
+ | /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
420
425
 
421
426
  Format the footer as:
422
427
  ```
@@ -453,11 +458,16 @@ Next:
453
458
  - Update services[].path to match actual submodule directory names
454
459
  - Update services domain keys to match @trace.domain in your PRD files
455
460
  - Confirm spec_source path is correct
456
- 2. Ensure spec submodule is initialized:
457
- git submodule update --init --recursive
458
- 3. Pull latest specs from PO before generating:
459
- git submodule update --remote {spec_source}
460
- 4. Start generating:
461
+
462
+ 2. Run /sync one command that handles everything else:
463
+ /sync
464
+ git pull + submodule init + spec submodule update
465
+ → Auto-create .agent/project-context.yaml for each service submodule
466
+ (detects module from pom.xml / go.mod / package.json / pubspec.yaml etc.)
467
+ → Sync Living Docs panel
468
+ → Refresh spec-manifest.yaml
469
+
470
+ 3. Start generating:
461
471
  /generate-bdd {spec_source}/specs/prd/{domain}/TICKET-ID-prd.md
462
472
  ```
463
473
 
@@ -317,11 +317,16 @@ Next:
317
317
  - Update services[].path to match actual submodule directory names
318
318
  - Update services domain keys to match @trace.domain in your PRD files
319
319
  - Confirm spec_source path is correct
320
- 2. Ensure spec submodule is initialized:
321
- git submodule update --init --recursive
322
- 3. Pull latest specs from PO before generating:
323
- git submodule update --remote {spec_source}
324
- 4. Start generating:
320
+
321
+ 2. Run /sync one command that handles everything else:
322
+ /sync
323
+ git pull + submodule init + spec submodule update
324
+ → Auto-create .agent/project-context.yaml for each service submodule
325
+ (detects module from pom.xml / go.mod / package.json / pubspec.yaml etc.)
326
+ → Sync Living Docs panel
327
+ → Refresh spec-manifest.yaml
328
+
329
+ 3. Start generating:
325
330
  /generate-bdd {spec_source}/specs/prd/{domain}/TICKET-ID-prd.md
326
331
  ```
327
332
 
@@ -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
 
@@ -548,6 +600,11 @@ Suggest the logical next command based on workflow phase:
548
600
  | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
549
601
  | /fix-bug | Create PR and link to ticket |
550
602
  | /debug | `/fix-bug {ticket-id}` if fix needed |
603
+ | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
604
+ | /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
605
+ | /learn | Continue working — lesson applies on next command |
606
+ | /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
607
+ | /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
551
608
 
552
609
  Format the footer as:
553
610
  ```