@anhth2/spec-driven-dev-plugin 0.7.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 (96) hide show
  1. package/ARCHITECTURE.md +6 -2
  2. package/bin/index.js +105 -0
  3. package/commands/debug.md +189 -1
  4. package/commands/debug.tmpl +16 -0
  5. package/commands/define-product.md +94 -1
  6. package/commands/fix-bug.md +190 -1
  7. package/commands/fix-bug.tmpl +17 -0
  8. package/commands/generate-bdd.md +314 -14
  9. package/commands/generate-bdd.tmpl +220 -13
  10. package/commands/generate-code.md +191 -3
  11. package/commands/generate-code.tmpl +97 -2
  12. package/commands/generate-design-spec.md +811 -0
  13. package/commands/generate-design-spec.tmpl +399 -0
  14. package/commands/generate-prd.md +133 -1
  15. package/commands/generate-prd.tmpl +39 -0
  16. package/commands/generate-spec-manifest.md +576 -0
  17. package/commands/generate-spec-manifest.tmpl +164 -0
  18. package/commands/generate-tech-docs.md +116 -2
  19. package/commands/generate-tech-docs.tmpl +22 -1
  20. package/commands/generate-tests.md +94 -1
  21. package/commands/learn.md +554 -0
  22. package/commands/learn.tmpl +63 -0
  23. package/commands/propose-scenario.md +521 -0
  24. package/commands/propose-scenario.tmpl +109 -0
  25. package/commands/refine-prd.md +94 -1
  26. package/commands/report-bug.md +543 -0
  27. package/commands/report-bug.tmpl +131 -0
  28. package/commands/review-code.md +190 -1
  29. package/commands/review-code.tmpl +17 -0
  30. package/commands/review-context.md +134 -1
  31. package/commands/review-context.tmpl +40 -0
  32. package/commands/review-tech-docs.md +176 -5
  33. package/commands/review-tech-docs.tmpl +82 -4
  34. package/commands/run-tests.md +119 -1
  35. package/commands/run-tests.tmpl +25 -0
  36. package/commands/setup-ai-first.md +142 -4
  37. package/commands/setup-ai-first.tmpl +135 -3
  38. package/commands/smoke-test.md +94 -1
  39. package/commands/sync.md +405 -0
  40. package/commands/sync.tmpl +345 -0
  41. package/commands/update-framework.md +211 -0
  42. package/commands/update-framework.tmpl +151 -0
  43. package/commands/validate-traces.md +152 -3
  44. package/commands/validate-traces.tmpl +58 -2
  45. package/core/FRAMEWORK_VERSION +1 -1
  46. package/core/commands/debug.md +189 -1
  47. package/core/commands/define-product.md +94 -1
  48. package/core/commands/fix-bug.md +190 -1
  49. package/core/commands/generate-bdd.md +314 -14
  50. package/core/commands/generate-code.md +191 -3
  51. package/core/commands/generate-design-spec.md +811 -0
  52. package/core/commands/generate-prd.md +133 -1
  53. package/core/commands/generate-spec-manifest.md +576 -0
  54. package/core/commands/generate-tech-docs.md +116 -2
  55. package/core/commands/generate-tests.md +94 -1
  56. package/core/commands/learn.md +554 -0
  57. package/core/commands/propose-scenario.md +521 -0
  58. package/core/commands/refine-prd.md +94 -1
  59. package/core/commands/report-bug.md +543 -0
  60. package/core/commands/review-code.md +190 -1
  61. package/core/commands/review-context.md +134 -1
  62. package/core/commands/review-tech-docs.md +176 -5
  63. package/core/commands/run-tests.md +119 -1
  64. package/core/commands/setup-ai-first.md +142 -4
  65. package/core/commands/smoke-test.md +94 -1
  66. package/core/commands/sync.md +405 -0
  67. package/core/commands/update-framework.md +211 -0
  68. package/core/commands/validate-traces.md +152 -3
  69. package/core/skills/code/SKILL.md +101 -2
  70. package/core/skills/debug/SKILL.md +108 -3
  71. package/core/skills/design-spec/SKILL.md +507 -0
  72. package/core/skills/discovery/SKILL.md +94 -1
  73. package/core/skills/prd/SKILL.md +14 -2
  74. package/core/skills/setup-ai-first/SKILL.md +7 -1
  75. package/core/skills/spec/SKILL.md +14 -2
  76. package/core/skills/test/SKILL.md +195 -3
  77. package/core/steps/capture-lesson.md +79 -0
  78. package/core/steps/context-loader.md +87 -0
  79. package/core/steps/report-footer.md +7 -1
  80. package/core/templates/design-spec.template.md +209 -0
  81. package/core/templates/project-context.yaml +40 -0
  82. package/package.json +1 -1
  83. package/skills/code/SKILL.md +101 -2
  84. package/skills/debug/SKILL.md +108 -3
  85. package/skills/design-spec/SKILL.md +507 -0
  86. package/skills/design-spec/SKILL.tmpl +95 -0
  87. package/skills/discovery/SKILL.md +94 -1
  88. package/skills/prd/SKILL.md +14 -2
  89. package/skills/setup-ai-first/SKILL.md +7 -1
  90. package/skills/spec/SKILL.md +14 -2
  91. package/skills/test/SKILL.md +195 -3
  92. package/steps/capture-lesson.md +79 -0
  93. package/steps/context-loader.md +87 -0
  94. package/steps/report-footer.md +7 -1
  95. package/templates/design-spec.template.md +209 -0
  96. package/templates/project-context.yaml +40 -0
@@ -135,6 +135,7 @@ Read `.agent/project-context.yaml`. Extract and store:
135
135
  - `paths.core_entities` → path to core-entities.md
136
136
  - `paths.tech_docs_dir` → technical documentation root
137
137
  - `paths.trace_dir` → trace state directory
138
+ - `paths.design_spec_dir` → Design Spec documents root (FE/App only)
138
139
 
139
140
  If `paths` section is absent, use these defaults:
140
141
  - `specs_dir` = `specs/bdd`
@@ -146,11 +147,75 @@ If `paths` section is absent, use these defaults:
146
147
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
147
148
  - `tech_docs_dir` = `specs/tech-docs`
148
149
  - `trace_dir` = `.trace`
150
+ - `design_spec_dir` = `specs/design-spec`
149
151
 
150
152
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
151
153
 
152
154
  ---
153
155
 
156
+ ## Step 1.5 — [SERVICE ROUTING] Resolve service paths (umbrella mode)
157
+
158
+ *Skip this step entirely if `setup.mode` is not `"umbrella"` and `services` section is absent from project-context.yaml.*
159
+
160
+ If `services` section is present:
161
+
162
+ **1. Detect active domain** (in priority order):
163
+ - Read `@trace.domain` from target file frontmatter (if Gate loaded a target file)
164
+ - Extract from target file path: segment immediately after `prd_dir` base path
165
+ *(e.g., `specs/prd/user/FEAT-01.md` → domain = `user`)*
166
+ - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
167
+
168
+ **2. Route to service** — if active domain matches a key in `services`:
169
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir`
170
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
171
+ - Store `active_service` = `services.{domain}.path`
172
+ - Store `active_service_module` = `services.{domain}.module`
173
+ - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
174
+
175
+ **3. Fallback** — if domain not detected or no matching service key:
176
+ - Keep default paths from Step 1
177
+ - Set `active_service = unresolved`
178
+
179
+ **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
180
+ - Override `paths.prd_dir` → `{spec_source}/specs/prd`
181
+ - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
182
+ - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
183
+ - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
184
+ - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
185
+ - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
186
+ - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
187
+
188
+ > **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.
189
+
190
+ ---
191
+
192
+ ## Step 1.6 — [SERVICE CONVENTIONS] Load service-specific conventions (umbrella mode)
193
+
194
+ *Skip this step entirely if `active_service` is `"unresolved"` or context is single-service mode.*
195
+
196
+ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-service/`):
197
+
198
+ **1. Locate service config** — try in priority order:
199
+ - `{active_service}/.agent/project-context.yaml`
200
+ - `{active_service}/project-context.yaml`
201
+
202
+ **2. If found, override with service-specific values:**
203
+
204
+ | Variable | Source |
205
+ |----------|--------|
206
+ | `conventions.test_command` | service's `conventions.test_command` |
207
+ | `conventions.build_command` | service's `conventions.build_command` |
208
+ | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` — default: `{active_service}/.trace` |
209
+ | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
210
+
211
+ **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
212
+ - Shell commands (`/run-tests`, `/generate-tests`) run **from within** `service_root`
213
+ - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
214
+
215
+ **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).
216
+
217
+ ---
218
+
154
219
  ## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
155
220
 
156
221
  If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
@@ -241,6 +306,25 @@ These two variables (`active_module`, `platform_type`) are the canonical source
241
306
 
242
307
  ---
243
308
 
309
+ ## Step 6.7 — [GUARDRAILS] Load Project Lessons (conditional)
310
+
311
+ *Accumulated mistakes the AI must not repeat in this project. These are added over time via `/learn`
312
+ or accepted during `/review-code`, `/fix-bug`, `/debug`.*
313
+
314
+ Resolve the lessons file path:
315
+ - Use `paths.lessons_file` if set (may be service-overridden in umbrella mode, Step 1.6)
316
+ - Else default `specs/domain-knowledge/lessons-learned.md`
317
+ - In umbrella/service mode (when `service_root` is set), if `paths.lessons_file` is unset, default to `{service_root}/.agent/project-lessons.md`
318
+
319
+ If the file exists, read it and store ALL lessons as **ACTIVE GUARDRAILS** for the session:
320
+ - Treat each lesson's **Rule** as a hard constraint — same priority as CLAUDE.md coding standards (Step 3).
321
+ - 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).
322
+ - If a generated output would violate a lesson → correct it **before** presenting, and note which lesson (`L-NNN`) was applied.
323
+
324
+ If the file does not exist → skip silently (no lessons captured yet).
325
+
326
+ ---
327
+
244
328
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
245
329
 
246
330
  After loading all context, synthesize and output a compact summary block.
@@ -256,6 +340,9 @@ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Ser
256
340
  Ticket : {ticket_prefix}-
257
341
  Dict : {loaded — N canonical terms, M banned terms | missing}
258
342
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
343
+ Lessons : {loaded — N guardrails | none yet}
344
+ Service : {active_service} ({active_service_module}) | single-service
345
+ Svc Root : {service_root} — conventions + trace_dir loaded from service config | —
259
346
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
260
347
  ```
261
348
 
@@ -387,6 +474,59 @@ Check all standard sections are present and non-empty:
387
474
 
388
475
  → All T6 missing-section findings are **auto-fixable**: AI adds skeleton section with prompts.
389
476
 
477
+ ### T7 — Cross-Team API Contract Review
478
+
479
+ *Only applies when ALL of the following are true:*
480
+ *1. Source BDD has `@trace.platform: system`.*
481
+ *2. Tech-doc header does NOT have `@trace.api_source: existing`.*
482
+
483
+ *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.*
484
+
485
+ This dimension ensures FE, App, and BE teams all agree on the API contract before implementation starts.
486
+
487
+ **Step 1 — Check sign-off status in tech-doc header:**
488
+
489
+ Read the `@trace.sign_off` block in the tech doc header. If absent → add it as a finding (auto-fixable: add skeleton).
490
+
491
+ ```yaml
492
+ # @trace.sign_off:
493
+ # be_team: pending # author — set to "done" when BE satisfied with design
494
+ # fe_team: pending # FE/Web — must confirm contract matches web BDD expectations
495
+ # app_team: pending # App — must confirm contract matches app BDD expectations (if applicable)
496
+ # sa: pending # SA/Tech Lead — final approval
497
+ ```
498
+
499
+ **Step 2 — Contract vs BDD cross-check:**
500
+
501
+ 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).
502
+
503
+ For each platform BDD, verify the tech doc's API contract satisfies the BDD's `Then` clauses:
504
+
505
+ | Check | Severity |
506
+ |---|---|
507
+ | Response fields in API contract don't cover what web BDD `Then` expects | Critical |
508
+ | Response fields in API contract don't cover what app BDD `Then` expects | Critical |
509
+ | Error response shape doesn't match what platform BDDs expect | Major |
510
+ | System BDD `@system.resolution` annotation contradicts the API contract design | Critical |
511
+
512
+ **Step 3 — Pending sign-off report:**
513
+
514
+ After the review, list which sign-offs are still `pending`:
515
+
516
+ ```
517
+ ⏳ Pending sign-offs before tech docs can be approved:
518
+ fe_team — FE/Web team must confirm API contract matches web BDD expectations
519
+ app_team — App team must confirm API contract matches app BDD expectations
520
+ sa — SA/Tech Lead final approval
521
+
522
+ Once sign-offs are collected → update @trace.sign_off in tech doc header, then re-run /review-tech-docs.
523
+ Tech docs cannot be set to "approved" while any required sign-off is pending.
524
+ ```
525
+
526
+ **Approval gate:**
527
+ - 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`
528
+ - Otherwise → `@trace.status` stays `in-review` — `generate-code` is blocked
529
+
390
530
  ---
391
531
 
392
532
  ## Write Findings File
@@ -400,10 +540,18 @@ domain: "{domain}"
400
540
  generated_at: "{ISO datetime}"
401
541
  review_type: "tech-design"
402
542
  status: "pending_review"
543
+ is_system_bdd: {true | false} # true if source BDD has @trace.platform: system
544
+
545
+ sign_off: # only present when is_system_bdd: true
546
+ be_team: pending # read from @trace.sign_off in tech-doc header
547
+ fe_team: pending
548
+ app_team: pending # "n/a" if project has no app platform
549
+ sa: pending
550
+ sign_off_gate: blocked # blocked | ready — "ready" only when all required are "done"
403
551
 
404
552
  findings:
405
553
  - id: "F001"
406
- check_id: "T1" # T1–T6
554
+ check_id: "T1" # T1–T7
407
555
  severity: "critical" # critical | major | minor
408
556
  section: "{section heading or component name where issue was found}"
409
557
  finding: "{clear description of the violation or gap}"
@@ -417,6 +565,7 @@ summary:
417
565
  auto_fixable: {N}
418
566
  requires_human_decision: {N}
419
567
  recommendation: "APPROVED | NEEDS_REVISION | BLOCKED"
568
+ sign_off_gate: "{blocked — pending: fe_team, app_team, sa | ready}"
420
569
  ```
421
570
 
422
571
  ## Report
@@ -453,7 +602,8 @@ Suggest the logical next command based on workflow phase:
453
602
  | /define-product | `/generate-prd {product-definition-file}` |
454
603
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
455
604
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
456
- | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
605
+ | /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 |
606
+ | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
457
607
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
458
608
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
459
609
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
@@ -467,6 +617,11 @@ Suggest the logical next command based on workflow phase:
467
617
  | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
468
618
  | /fix-bug | Create PR and link to ticket |
469
619
  | /debug | `/fix-bug {ticket-id}` if fix needed |
620
+ | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
621
+ | /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
622
+ | /learn | Continue working — lesson applies on next command |
623
+ | /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
624
+ | /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
470
625
 
471
626
  Format the footer as:
472
627
  ```
@@ -483,9 +638,17 @@ UC: {UC-ID} | Domain: {domain}
483
638
  Findings: {total} | 🔴 Critical: {N} | 🟡 Major: {N} | 🟢 Minor: {N}
484
639
  Auto-fixable: {N} | Needs human decision: {N}
485
640
 
641
+ Sign-off gate (system BDD only):
642
+ be_team : {done | pending}
643
+ fe_team : {done | pending} ← {name / "needs sign-off" }
644
+ app_team : {done | pending | n/a}
645
+ sa : {done | pending}
646
+ Gate : {🔒 BLOCKED — pending: fe_team, sa | ✅ READY}
647
+
486
648
  Findings file: {paths.refinement_dir}/{uc-id}-tech-review-findings.yaml
487
649
  Next: Open in Review Board → Accept/Modify/Reject each finding
488
650
  Then run: /review-tech-docs --resume {tech-design-file}
651
+ After all sign-offs collected → update @trace.sign_off in tech doc, re-run review
489
652
  ```
490
653
 
491
654
  ---
@@ -520,7 +683,10 @@ Review Board "Modify" note. Apply exactly what the note says. Do not invent the
520
683
 
521
684
  Edit the tech-doc file directly:
522
685
  1. Find `@trace.revision:` in the header — increment its integer value by 1.
523
- 2. Find `@trace.status:` in the header — set its value to `draft`.
686
+ 2. Find `@trace.status:` in the header:
687
+ - If sign_off_gate = `ready` (all sign-offs done) → set to `approved`
688
+ - Otherwise → set to `in-review` (blocks `/generate-code`)
689
+ 3. If `@trace.sign_off` block is absent and this is a system BDD tech doc → add it with all values `pending`.
524
690
 
525
691
  Write both changes to the file.
526
692
 
@@ -542,8 +708,13 @@ Changes:
542
708
  - {change 2}
543
709
 
544
710
  Revision : {old} → {new}
545
- Status : reset to draft (re-approval required)
711
+ Status : {approved | in-review}
712
+
713
+ Sign-off : {✅ All done — status set to approved
714
+ | 🔒 Pending: fe_team, sa — status set to in-review
715
+ Update @trace.sign_off in tech doc when each team confirms, then re-run /review-tech-docs}
546
716
 
547
717
  Re-run /review-tech-docs {file} to confirm 0 remaining critical findings.
548
- Next: /generate-code {feature-file}
718
+ Next: {/generate-code {feature-file} ← only if status = approved
719
+ | Collect pending sign-offs → update @trace.sign_off → re-run /review-tech-docs}
549
720
  ```
@@ -131,6 +131,7 @@ Read `.agent/project-context.yaml`. Extract and store:
131
131
  - `paths.core_entities` → path to core-entities.md
132
132
  - `paths.tech_docs_dir` → technical documentation root
133
133
  - `paths.trace_dir` → trace state directory
134
+ - `paths.design_spec_dir` → Design Spec documents root (FE/App only)
134
135
 
135
136
  If `paths` section is absent, use these defaults:
136
137
  - `specs_dir` = `specs/bdd`
@@ -142,11 +143,75 @@ If `paths` section is absent, use these defaults:
142
143
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
143
144
  - `tech_docs_dir` = `specs/tech-docs`
144
145
  - `trace_dir` = `.trace`
146
+ - `design_spec_dir` = `specs/design-spec`
145
147
 
146
148
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
147
149
 
148
150
  ---
149
151
 
152
+ ## Step 1.5 — [SERVICE ROUTING] Resolve service paths (umbrella mode)
153
+
154
+ *Skip this step entirely if `setup.mode` is not `"umbrella"` and `services` section is absent from project-context.yaml.*
155
+
156
+ If `services` section is present:
157
+
158
+ **1. Detect active domain** (in priority order):
159
+ - Read `@trace.domain` from target file frontmatter (if Gate loaded a target file)
160
+ - Extract from target file path: segment immediately after `prd_dir` base path
161
+ *(e.g., `specs/prd/user/FEAT-01.md` → domain = `user`)*
162
+ - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
163
+
164
+ **2. Route to service** — if active domain matches a key in `services`:
165
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir`
166
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
167
+ - Store `active_service` = `services.{domain}.path`
168
+ - Store `active_service_module` = `services.{domain}.module`
169
+ - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
170
+
171
+ **3. Fallback** — if domain not detected or no matching service key:
172
+ - Keep default paths from Step 1
173
+ - Set `active_service = unresolved`
174
+
175
+ **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
176
+ - Override `paths.prd_dir` → `{spec_source}/specs/prd`
177
+ - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
178
+ - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
179
+ - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
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).
212
+
213
+ ---
214
+
150
215
  ## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
151
216
 
152
217
  If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
@@ -237,6 +302,25 @@ These two variables (`active_module`, `platform_type`) are the canonical source
237
302
 
238
303
  ---
239
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
+
240
324
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
241
325
 
242
326
  After loading all context, synthesize and output a compact summary block.
@@ -252,6 +336,9 @@ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Ser
252
336
  Ticket : {ticket_prefix}-
253
337
  Dict : {loaded — N canonical terms, M banned terms | missing}
254
338
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
339
+ Lessons : {loaded — N guardrails | none yet}
340
+ Service : {active_service} ({active_service_module}) | single-service
341
+ Svc Root : {service_root} — conventions + trace_dir loaded from service config | —
255
342
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
256
343
  ```
257
344
 
@@ -282,6 +369,31 @@ Use it to select the correct run command and error analysis table below.
282
369
 
283
370
  ---
284
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
+
285
397
  ## Run
286
398
 
287
399
  ### If `platform_type = backend`
@@ -444,7 +556,8 @@ Suggest the logical next command based on workflow phase:
444
556
  | /define-product | `/generate-prd {product-definition-file}` |
445
557
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
446
558
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
447
- | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
559
+ | /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 |
560
+ | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
448
561
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
449
562
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
450
563
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
@@ -458,6 +571,11 @@ Suggest the logical next command based on workflow phase:
458
571
  | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
459
572
  | /fix-bug | Create PR and link to ticket |
460
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 |
461
579
 
462
580
  Format the footer as:
463
581
  ```
@@ -98,6 +98,51 @@ Check if already set up:
98
98
  - Y → continue (existing files will be preserved — each step will offer merge/skip)
99
99
  - If only `specs/` exists or only partial setup detected → continue normally (safe to re-run)
100
100
 
101
+ ## Step 0.5 — Project Type
102
+
103
+ Ask the user:
104
+
105
+ ```
106
+ What type of project is this?
107
+ 1. Single-service — one codebase, one platform (standard setup)
108
+ 2. Umbrella repo — this repo contains multiple service submodules (microservices / multi-app)
109
+ 3. PO Spec repo — docs only, no runnable code (PRD + design-spec only)
110
+ ```
111
+
112
+ Store the answer as `project_type`. Default to `1` if user does not answer.
113
+
114
+ Based on answer:
115
+
116
+ **project_type = 1 (Single-service):** Continue standard setup below.
117
+
118
+ **project_type = 2 (Umbrella):** Ask two follow-up questions:
119
+ - "Path to spec submodule (e.g. `free-trial-specs`)? Press Enter to skip."
120
+ - "List services as `domain:module` pairs, comma-separated
121
+ (e.g. `user:java-spring,order:java-spring`). Press Enter to skip."
122
+
123
+ Then:
124
+ - Skip creating `specs/prd/`, `specs/design-spec/`, `specs/domain-knowledge/` (those live in spec submodule)
125
+ - Create only: `specs/bdd/`, `specs/tech-docs/`, `.trace/`, `.agent/review/` at umbrella level
126
+ *(Unless user explicitly asks to create the full structure)*
127
+ - Generate `.agent/project-context.yaml` in umbrella mode with the services and spec_source provided
128
+ - Skip creating `CLAUDE.md` (umbrella has no single tech stack)
129
+ - After setup, remind: "Open each service submodule separately in Claude Code to install the framework there if needed."
130
+
131
+ **project_type = 3 (PO Spec repo):**
132
+ - Create: `specs/prd/`, `specs/design-spec/`, `specs/product-definition/`, `specs/domain-knowledge/`, `.agent/review/`
133
+ - Skip: `specs/bdd/`, `specs/tech-docs/`, `.trace/`
134
+ - Generate minimal `CLAUDE.md` with only §1 (project overview) and §7 (git conventions)
135
+ - Ask the user: **"List your business domains (e.g. auth, payment, loyalty):"** — store as domain list for `project-context.yaml` and remind PO these names must be used consistently as `@trace.domain` in every PRD
136
+ - Inform:
137
+ - Commands for PO repo: `/define-product`, `/generate-prd`, `/review-context`, `/generate-design-spec`
138
+ - **Critical for dev team handoff:** Every PRD must have `@trace.domain: {domain}` in its frontmatter. Dev team uses this to route generated BDD/code to the correct service submodule. Inconsistent domain names will break routing.
139
+ - Recommended PRD frontmatter:
140
+ ```
141
+ @trace.domain: {domain} ← must match a key in dev team's services config
142
+ @trace.id: {TICKET-ID}
143
+ @trace.status: draft | approved
144
+ ```
145
+
101
146
  ## Step 1 — Create Directory Structure
102
147
 
103
148
  Create these directories (skip if they exist):
@@ -108,6 +153,7 @@ Create these directories (skip if they exist):
108
153
  │ ├── product-definition/
109
154
  │ ├── prd/
110
155
  │ ├── bdd/
156
+ │ ├── design-spec/ ← Design Spec documents (FE/App platforms only)
111
157
  │ ├── tech-docs/ ← technical design documents
112
158
  │ └── domain-knowledge/ ← business dictionary & domain context
113
159
  ├── .trace/
@@ -115,8 +161,19 @@ Create these directories (skip if they exist):
115
161
  └── review/
116
162
  ```
117
163
 
164
+ *Directory structure varies by `project_type` set in Step 0.5:*
165
+
166
+ | project_type | Create | Skip |
167
+ |---|---|---|
168
+ | **1 — Single-service** | Full structure above | — |
169
+ | **2 — Umbrella** | `.agent/review/` only (at umbrella root) | Everything else — `specs/` dirs live inside service submodules |
170
+ | **3 — PO Spec repo** | `specs/prd/`, `specs/design-spec/`, `specs/product-definition/`, `specs/domain-knowledge/`, `.agent/review/` | `specs/bdd/`, `specs/tech-docs/`, `.trace/` |
171
+
118
172
  ## Step 2 — Create CLAUDE.md
119
173
 
174
+ *Skip this step entirely if `project_type = 2` (Umbrella) — umbrella has no single tech stack.*
175
+ *For `project_type = 3` (PO Spec repo) — create a minimal CLAUDE.md with only §1 (project overview) and §7 (git conventions). Skip §2–§6.*
176
+
120
177
  Check if `CLAUDE.md` exists:
121
178
  - Yes → ask "Merge template or skip?"
122
179
  - No → create from the template below
@@ -173,12 +230,19 @@ commit_feature: "feat({{TICKET_PREFIX}}-{N}): {description}"
173
230
 
174
231
  ## Step 3 — Create project-context.yaml
175
232
 
233
+ *For `project_type = 2` (Umbrella):*
234
+ - *If `.agent/project-context.yaml` was already generated by `--init --umbrella` → open it and verify/edit the `services` section (domain keys, paths, modules). Skip template copy below.*
235
+ - *If not yet generated → ask: "Spec submodule path?" and "Services (domain:module pairs)?" then generate umbrella config (see Step 0.5 for format).*
236
+
176
237
  Create `.agent/project-context.yaml` using `.agent/templates/project-context.yaml` as the source template.
177
238
 
178
239
  Copy the template and instruct: "Open `.agent/project-context.yaml` and fill in all `{{PLACEHOLDER}}` values. The `paths` section is pre-configured with sensible defaults — adjust if your project uses different directory names."
179
240
 
180
241
  ## Step 4 — Create business-dictionary.md
181
242
 
243
+ *Skip Steps 4 and 5 if `project_type = 2` (Umbrella) — business dictionary and core entities live in the spec submodule and are managed by the PO team. Dev team reads them from `{spec_source}/specs/domain-knowledge/`.*
244
+
245
+
182
246
  Create `specs/domain-knowledge/business-dictionary.md` if it does not exist:
183
247
 
184
248
  ```markdown
@@ -272,8 +336,12 @@ Or: VS Code → `Ctrl+Shift+P` → **"Extensions: Install from Marketplace"**
272
336
 
273
337
  ## Step 7 — Verify
274
338
 
339
+ Checklist varies by `project_type`:
340
+
341
+ **project_type = 1 (Single-service):**
275
342
  - [ ] `specs/` exists
276
343
  - [ ] `specs/bdd/` exists
344
+ - [ ] `specs/design-spec/` exists *(skip if backend-only project)*
277
345
  - [ ] `specs/tech-docs/` exists
278
346
  - [ ] `specs/domain-knowledge/` exists
279
347
  - [ ] `.trace/` exists
@@ -282,6 +350,24 @@ Or: VS Code → `Ctrl+Shift+P` → **"Extensions: Install from Marketplace"**
282
350
  - [ ] `specs/domain-knowledge/business-dictionary.md` exists
283
351
  - [ ] `specs/domain-knowledge/core-entities.md` exists
284
352
 
353
+ **project_type = 2 (Umbrella):**
354
+ - [ ] `.agent/project-context.yaml` exists with `setup.mode: umbrella`
355
+ - [ ] `services` section has at least one entry with correct domain keys
356
+ - [ ] `spec_source` path exists (e.g., `my-project-specs/` directory is present)
357
+ - [ ] `.agent/review/` exists
358
+ - [ ] Spec submodule initialized: `git submodule status` shows no `-` prefix
359
+
360
+ **project_type = 3 (PO Spec repo):**
361
+ - [ ] `specs/prd/` exists
362
+ - [ ] `specs/design-spec/` exists
363
+ - [ ] `specs/product-definition/` exists
364
+ - [ ] `specs/domain-knowledge/` exists
365
+ - [ ] `.agent/review/` exists
366
+ - [ ] `.agent/project-context.yaml` exists
367
+ - [ ] `CLAUDE.md` exists (minimal)
368
+ - [ ] `specs/domain-knowledge/business-dictionary.md` exists
369
+ - [ ] `specs/domain-knowledge/core-entities.md` exists
370
+
285
371
  ## Output
286
372
 
287
373
  # Report Footer — Standard Command Output Format
@@ -316,7 +402,8 @@ Suggest the logical next command based on workflow phase:
316
402
  | /define-product | `/generate-prd {product-definition-file}` |
317
403
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
318
404
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
319
- | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
405
+ | /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 |
406
+ | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
320
407
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
321
408
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
322
409
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
@@ -330,6 +417,11 @@ Suggest the logical next command based on workflow phase:
330
417
  | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
331
418
  | /fix-bug | Create PR and link to ticket |
332
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 |
333
425
 
334
426
  Format the footer as:
335
427
  ```
@@ -342,13 +434,59 @@ Next : {suggested command with example arguments}
342
434
 
343
435
  ```
344
436
  /setup-ai-first Complete ✅
437
+ ```
438
+
439
+ Output varies by `project_type`:
440
+
441
+ **Single-service:**
442
+ ```
345
443
  Next:
346
444
  1. Fill CLAUDE.md (replace {{PLACEHOLDER}} values)
347
445
  2. Fill .agent/project-context.yaml
348
- 3. Fill specs/domain-knowledge/business-dictionary.md ← terminology rules
349
- 4. Fill specs/domain-knowledge/core-entities.md ← entity glossary for code gen
446
+ 3. Fill specs/domain-knowledge/business-dictionary.md
447
+ 4. Fill specs/domain-knowledge/core-entities.md
350
448
  5. git add and commit those 4 files
351
- 6. Install VS Code extension (if not yet installed):
449
+ 6. Install VS Code extension:
352
450
  code --install-extension edupia-team.spec-driven-dev-team
353
451
  7. /define-product to start your first feature
354
452
  ```
453
+
454
+ **Umbrella:**
455
+ ```
456
+ Next:
457
+ 1. Review .agent/project-context.yaml:
458
+ - Update services[].path to match actual submodule directory names
459
+ - Update services domain keys to match @trace.domain in your PRD files
460
+ - Confirm spec_source path is correct
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:
471
+ /generate-bdd {spec_source}/specs/prd/{domain}/TICKET-ID-prd.md
472
+ ```
473
+
474
+ **PO Spec repo:**
475
+ ```
476
+ Next:
477
+ 1. Fill .agent/project-context.yaml:
478
+ - domains: [list all business domains — these become @trace.domain values in PRDs]
479
+ - project.name, project.description
480
+ 2. Fill specs/domain-knowledge/business-dictionary.md ← canonical terms
481
+ 3. Fill specs/domain-knowledge/core-entities.md ← entity glossary
482
+ 4. git add and commit those files
483
+ 5. Install VS Code extension:
484
+ code --install-extension edupia-team.spec-driven-dev-team
485
+ 6. /define-product to start your first feature
486
+
487
+ ⚠️ Dev team handoff reminder:
488
+ - Each PRD must have @trace.domain matching one of your domains list
489
+ - When dev team sets up their umbrella repo, they map these domain names
490
+ to service submodule paths in their project-context.yaml services section
491
+ - Share domain names with dev team before they configure their umbrellas
492
+ ```