@anhth2/spec-driven-dev-plugin 0.12.0 → 0.14.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 (130) hide show
  1. package/commands/debug.md +42 -7
  2. package/commands/define-product.md +42 -7
  3. package/commands/dev-gen-test.md +60 -17
  4. package/commands/dev-run-test.md +61 -18
  5. package/commands/dev-run-test.tmpl +1 -1
  6. package/commands/dev-smoke-test.md +42 -7
  7. package/commands/fix-bug.md +42 -7
  8. package/commands/generate-bdd.md +67 -21
  9. package/commands/generate-bdd.tmpl +7 -4
  10. package/commands/generate-code.md +113 -35
  11. package/commands/generate-code.tmpl +53 -18
  12. package/commands/generate-design-spec.md +42 -7
  13. package/commands/generate-prd.md +42 -7
  14. package/commands/generate-spec-manifest.md +42 -7
  15. package/commands/generate-tech-docs.md +229 -20
  16. package/commands/generate-tech-docs.tmpl +187 -13
  17. package/commands/learn.md +42 -7
  18. package/commands/map-testids.md +564 -0
  19. package/commands/map-testids.tmpl +81 -0
  20. package/commands/propose-scenario.md +42 -7
  21. package/commands/qc-analyze.md +42 -7
  22. package/commands/qc-design-test.md +44 -8
  23. package/commands/qc-design-test.tmpl +2 -1
  24. package/commands/qc-plan.md +42 -7
  25. package/commands/qc-report.md +42 -7
  26. package/commands/qc-review.md +42 -7
  27. package/commands/qc-run-test.md +62 -18
  28. package/commands/qc-run-test.tmpl +2 -1
  29. package/commands/refine-prd.md +42 -7
  30. package/commands/report-bug.md +42 -7
  31. package/commands/review-code.md +42 -7
  32. package/commands/review-context.md +42 -7
  33. package/commands/review-tech-docs.md +45 -9
  34. package/commands/review-tech-docs.tmpl +3 -2
  35. package/commands/setup-ai-first.md +37 -4
  36. package/commands/setup-ai-first.tmpl +2 -2
  37. package/commands/sync.md +35 -2
  38. package/commands/update-framework.md +35 -2
  39. package/commands/validate-traces.md +85 -40
  40. package/commands/validate-traces.tmpl +43 -33
  41. package/core/FRAMEWORK_VERSION +1 -1
  42. package/core/commands/debug.md +42 -7
  43. package/core/commands/define-product.md +42 -7
  44. package/core/commands/dev-gen-test.md +60 -17
  45. package/core/commands/dev-run-test.md +61 -18
  46. package/core/commands/dev-smoke-test.md +42 -7
  47. package/core/commands/fix-bug.md +42 -7
  48. package/core/commands/generate-bdd.md +67 -21
  49. package/core/commands/generate-code.md +113 -35
  50. package/core/commands/generate-design-spec.md +42 -7
  51. package/core/commands/generate-prd.md +42 -7
  52. package/core/commands/generate-spec-manifest.md +42 -7
  53. package/core/commands/generate-tech-docs.md +229 -20
  54. package/core/commands/learn.md +42 -7
  55. package/core/commands/map-testids.md +564 -0
  56. package/core/commands/propose-scenario.md +42 -7
  57. package/core/commands/qc-analyze.md +42 -7
  58. package/core/commands/qc-design-test.md +44 -8
  59. package/core/commands/qc-plan.md +42 -7
  60. package/core/commands/qc-report.md +42 -7
  61. package/core/commands/qc-review.md +42 -7
  62. package/core/commands/qc-run-test.md +62 -18
  63. package/core/commands/refine-prd.md +42 -7
  64. package/core/commands/report-bug.md +42 -7
  65. package/core/commands/review-code.md +42 -7
  66. package/core/commands/review-context.md +42 -7
  67. package/core/commands/review-tech-docs.md +45 -9
  68. package/core/commands/setup-ai-first.md +37 -4
  69. package/core/commands/sync.md +35 -2
  70. package/core/commands/update-framework.md +35 -2
  71. package/core/commands/validate-traces.md +85 -40
  72. package/core/modules/qc-playwright/stack-profile.yaml +1 -0
  73. package/core/skills/code/SKILL.md +77 -9
  74. package/core/skills/debug/SKILL.md +112 -11
  75. package/core/skills/design-spec/SKILL.md +42 -7
  76. package/core/skills/discovery/SKILL.md +42 -7
  77. package/core/skills/prd/SKILL.md +70 -4
  78. package/core/skills/setup-ai-first/SKILL.md +35 -2
  79. package/core/skills/spec/SKILL.md +70 -4
  80. package/core/skills/test/SKILL.md +119 -16
  81. package/core/steps/context-loader.md +7 -5
  82. package/core/steps/report-footer.md +35 -2
  83. package/core/steps/trace-mirror.md +18 -10
  84. package/core/templates/project-context.yaml +8 -5
  85. package/docs/01-getting-started/core-concepts.md +7 -7
  86. package/docs/01-getting-started/installation.md +2 -2
  87. package/docs/01-getting-started/quickstart.md +1 -1
  88. package/docs/02-guides/README.md +1 -2
  89. package/docs/02-guides/developer/README.md +1 -1
  90. package/docs/02-guides/developer/bdd-and-trace.md +10 -8
  91. package/docs/02-guides/developer/commands.md +3 -3
  92. package/docs/02-guides/developer/scenarios.md +26 -14
  93. package/docs/02-guides/developer/workflow.md +80 -20
  94. package/docs/02-guides/product-owner/README.md +6 -4
  95. package/docs/02-guides/product-owner/commands.md +1 -1
  96. package/docs/02-guides/product-owner/scenarios.md +80 -1
  97. package/docs/02-guides/tester/README.md +12 -11
  98. package/docs/02-guides/tester/bug-reporting.md +1 -1
  99. package/docs/02-guides/{qc-automation.md → tester/qc-automation.md} +14 -6
  100. package/docs/02-guides/tester/reading-specs.md +4 -4
  101. package/docs/02-guides/tester/scenarios.md +5 -5
  102. package/docs/02-guides/tester/spec-manifest.md +17 -12
  103. package/docs/02-guides/tester/test-checklist.md +3 -3
  104. package/docs/02-guides/tester/workflow.md +8 -11
  105. package/docs/03-concepts/architecture.md +5 -4
  106. package/docs/03-concepts/pipeline.md +18 -6
  107. package/docs/03-concepts/traceability.md +17 -17
  108. package/docs/04-operations/README.md +1 -1
  109. package/docs/04-operations/bug-flow.md +4 -4
  110. package/docs/04-operations/sync-and-update.md +163 -38
  111. package/docs/05-reference/README.md +3 -0
  112. package/docs/05-reference/command-cheatsheet.md +147 -0
  113. package/docs/05-reference/commands.md +72 -69
  114. package/docs/05-reference/modules.md +2 -2
  115. package/docs/05-reference/trace-schema.md +15 -14
  116. package/docs/README.md +3 -5
  117. package/modules/qc-playwright/stack-profile.yaml +1 -0
  118. package/package.json +1 -1
  119. package/skills/code/SKILL.md +77 -9
  120. package/skills/debug/SKILL.md +112 -11
  121. package/skills/design-spec/SKILL.md +42 -7
  122. package/skills/discovery/SKILL.md +42 -7
  123. package/skills/prd/SKILL.md +70 -4
  124. package/skills/setup-ai-first/SKILL.md +35 -2
  125. package/skills/spec/SKILL.md +70 -4
  126. package/skills/test/SKILL.md +119 -16
  127. package/steps/context-loader.md +7 -5
  128. package/steps/report-footer.md +35 -2
  129. package/steps/trace-mirror.md +18 -10
  130. package/templates/project-context.yaml +8 -5
@@ -173,7 +173,7 @@ If `services` section is present:
173
173
  - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
174
174
 
175
175
  **2. Route to service** — if active domain matches a key in `services`:
176
- - Override `paths.specs_dir` → `services.{domain}.specs_dir`
176
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir` — **only if `setup.spec_source` is NOT set.** When `spec_source` IS set, ALL BDD (web/app/**system**) is a shared cross-team artifact → leave `specs_dir` for step 4 to route to the spec repo; do NOT pin it per-service here.
177
177
  - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir` — **only if `setup.spec_source` is NOT set.** When `spec_source` IS set, the tech-design (API contract) is a cross-team artifact and must live in the shared spec repo (handled in step 4), so leave `tech_docs_dir` for step 4 to route — do NOT pin it per-service here.
178
178
  - Store `active_service` = `services.{domain}.path`
179
179
  - Store `active_service_module` = `services.{domain}.module`
@@ -184,6 +184,7 @@ If `services` section is present:
184
184
  - Set `active_service = unresolved`
185
185
 
186
186
  **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
187
+ - Override `paths.specs_dir` → `{spec_source}/specs/bdd` — **always when `spec_source` is set.** All BDD (web/app/**system**) lives in the shared spec repo so every umbrella (FE/App/BE) reads the same scenarios; the FE tech-design gate + `/generate-code --phase=ui`/`--phase=integration` resolve the `system/` BDD here. *(Per-service `specs/bdd` only when there is no `spec_source`.)*
187
188
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
188
189
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
189
190
  - Override `paths.tech_docs_dir` → `{spec_source}/specs/tech-docs` — **always when `spec_source` is set** (step 2 no longer pins tech-docs per-service in this case). The tech-design IS the cross-team API contract: BE authors it here, and FE/App read it from the same spec submodule at `/generate-code --phase=integration`. *(Per-service tech-docs only happen when there is no `spec_source` — a pure multi-service BE repo with no shared spec module.)*
@@ -193,8 +194,9 @@ If `services` section is present:
193
194
  - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
194
195
  - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
195
196
  - Override `paths.prd_change_requests_dir` → `{spec_source}/feedback/prd-change-requests`
197
+ - Override `paths.trace_dir` → `{spec_source}/.trace` — **always when `spec_source` is set.** Trace TSVs are consolidated in the spec repo (single authoritative location, no per-service split) so the PM/PO has one place to manage status. Code-side commands (`/generate-code`, `/dev-run-test`, `/qc-run-test`) run from `service_root` but **write their trace row into `{spec_source}/.trace`** — like they already push `feedback/` there. *(Per-service `.trace` only when there is no `spec_source`.)*
196
198
 
197
- > **Why under `spec_source`:** PRD, design-spec, domain knowledge, the **API contract (tech-docs)**, and tester feedback are all **cross-team artifacts** — they must live in the **shared spec repo** so every umbrella (FE/App/BE) reads the same source via `/sync`. Tech-docs specifically: BE authors the tech-design (API contract), commits + pushes it into the spec submodule (2-layer commit), and FE/App pull it on their next `/sync` to wire the real API in `/generate-code --phase=integration`. In single-service mode (no `spec_source`), these default under the repo root — still shared, same repo.
199
+ > **Why under `spec_source`:** PRD, design-spec, domain knowledge, **all BDD (web/app/system)**, the **API contract (tech-docs)**, tester feedback, **and the `.trace/` coverage state** are all **cross-team artifacts** — they live in the **shared spec repo** so every umbrella (FE/App/BE) and the PM read one source via `/sync`. The service submodule holds only **code** (+ build/test tooling). `.trace/` and `feedback/` are the dev/QC **write areas** in the spec repo (the PRD/BDD/design-spec/tech-docs there stay read-only for dev/QC only PO edits those). In single-service mode (no `spec_source`), everything defaults under the repo root — still one repo.
198
200
 
199
201
  ---
200
202
 
@@ -214,12 +216,12 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
214
216
  |----------|--------|
215
217
  | `conventions.test_command` | service's `conventions.test_command` |
216
218
  | `conventions.build_command` | service's `conventions.build_command` |
217
- | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` default: `{active_service}/.trace` |
218
- | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
219
+ | `paths.trace_dir` | **If `spec_source` is set → keep the Step 4 spec-repo route (`{spec_source}/.trace`); ignore any service-level `trace_dir`.** Only when there is no `spec_source`: `{active_service}/{service paths.trace_dir}` (default `{active_service}/.trace`). |
220
+ | `paths.specs_dir` | **If `spec_source` is set → keep the Step 4 spec-repo route (`{spec_source}/specs/bdd`); ignore any service-level `specs_dir`** (BDD is cross-team, never per-service in this mode). Only when there is no `spec_source`: `{active_service}/{service paths.specs_dir}` if set, else the Step 1.5 override. |
219
221
 
220
222
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
221
223
  - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
222
- - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
224
+ - **Source/test files** are written relative to `service_root`; **trace TSVs** are written to `{paths.trace_dir}` (the spec repo when `spec_source` is set — a cross-repo write, committed/pushed to the spec submodule like `feedback/`).
223
225
 
224
226
  **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).
225
227
 
@@ -793,6 +795,36 @@ Output Artifacts:
793
795
 
794
796
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
795
797
 
798
+ ## Pipeline Position
799
+
800
+ Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
801
+ so the user always sees where this command sits in the end-to-end flow:
802
+
803
+ ```
804
+ Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
805
+ ```
806
+
807
+ Find the current command in this phase legend and mark **its** phase in the map above:
808
+
809
+ | Phase | Commands |
810
+ |-------|----------|
811
+ | Discovery | `/define-product` |
812
+ | PRD | `/generate-prd` · `/refine-prd` · `/review-context` (PRD) |
813
+ | Design Spec | `/generate-design-spec` |
814
+ | BDD | `/generate-bdd` · `/review-context` (BDD) |
815
+ | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
816
+ | Code | `/generate-code` · `/review-code` |
817
+ | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
818
+ | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
819
+ | Trace Audit | `/validate-traces` |
820
+
821
+ For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
822
+ `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
823
+
824
+ **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
825
+ `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline —
826
+ **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
827
+
796
828
  ## Next Command Suggestion
797
829
 
798
830
  Suggest the logical next command based on workflow phase:
@@ -834,10 +866,13 @@ Suggest the logical next command based on workflow phase:
834
866
  Format the footer as:
835
867
  ```
836
868
  ---
837
- Status : {badge}
869
+ Status : {badge}
838
870
  {Output Artifacts block}
839
- Next : {suggested command with example arguments}
871
+ Pipeline : Discovery PRD [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
872
+ (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
873
+ Next : {suggested command with example arguments}
840
874
  ```
875
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
841
876
 
842
877
 
843
878
  ```
@@ -170,7 +170,7 @@ If `services` section is present:
170
170
  - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
171
171
 
172
172
  **2. Route to service** — if active domain matches a key in `services`:
173
- - Override `paths.specs_dir` → `services.{domain}.specs_dir`
173
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir` — **only if `setup.spec_source` is NOT set.** When `spec_source` IS set, ALL BDD (web/app/**system**) is a shared cross-team artifact → leave `specs_dir` for step 4 to route to the spec repo; do NOT pin it per-service here.
174
174
  - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir` — **only if `setup.spec_source` is NOT set.** When `spec_source` IS set, the tech-design (API contract) is a cross-team artifact and must live in the shared spec repo (handled in step 4), so leave `tech_docs_dir` for step 4 to route — do NOT pin it per-service here.
175
175
  - Store `active_service` = `services.{domain}.path`
176
176
  - Store `active_service_module` = `services.{domain}.module`
@@ -181,6 +181,7 @@ If `services` section is present:
181
181
  - Set `active_service = unresolved`
182
182
 
183
183
  **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
184
+ - Override `paths.specs_dir` → `{spec_source}/specs/bdd` — **always when `spec_source` is set.** All BDD (web/app/**system**) lives in the shared spec repo so every umbrella (FE/App/BE) reads the same scenarios; the FE tech-design gate + `/generate-code --phase=ui`/`--phase=integration` resolve the `system/` BDD here. *(Per-service `specs/bdd` only when there is no `spec_source`.)*
184
185
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
185
186
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
186
187
  - Override `paths.tech_docs_dir` → `{spec_source}/specs/tech-docs` — **always when `spec_source` is set** (step 2 no longer pins tech-docs per-service in this case). The tech-design IS the cross-team API contract: BE authors it here, and FE/App read it from the same spec submodule at `/generate-code --phase=integration`. *(Per-service tech-docs only happen when there is no `spec_source` — a pure multi-service BE repo with no shared spec module.)*
@@ -190,8 +191,9 @@ If `services` section is present:
190
191
  - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
191
192
  - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
192
193
  - Override `paths.prd_change_requests_dir` → `{spec_source}/feedback/prd-change-requests`
194
+ - Override `paths.trace_dir` → `{spec_source}/.trace` — **always when `spec_source` is set.** Trace TSVs are consolidated in the spec repo (single authoritative location, no per-service split) so the PM/PO has one place to manage status. Code-side commands (`/generate-code`, `/dev-run-test`, `/qc-run-test`) run from `service_root` but **write their trace row into `{spec_source}/.trace`** — like they already push `feedback/` there. *(Per-service `.trace` only when there is no `spec_source`.)*
193
195
 
194
- > **Why under `spec_source`:** PRD, design-spec, domain knowledge, the **API contract (tech-docs)**, and tester feedback are all **cross-team artifacts** — they must live in the **shared spec repo** so every umbrella (FE/App/BE) reads the same source via `/sync`. Tech-docs specifically: BE authors the tech-design (API contract), commits + pushes it into the spec submodule (2-layer commit), and FE/App pull it on their next `/sync` to wire the real API in `/generate-code --phase=integration`. In single-service mode (no `spec_source`), these default under the repo root — still shared, same repo.
196
+ > **Why under `spec_source`:** PRD, design-spec, domain knowledge, **all BDD (web/app/system)**, the **API contract (tech-docs)**, tester feedback, **and the `.trace/` coverage state** are all **cross-team artifacts** — they live in the **shared spec repo** so every umbrella (FE/App/BE) and the PM read one source via `/sync`. The service submodule holds only **code** (+ build/test tooling). `.trace/` and `feedback/` are the dev/QC **write areas** in the spec repo (the PRD/BDD/design-spec/tech-docs there stay read-only for dev/QC only PO edits those). In single-service mode (no `spec_source`), everything defaults under the repo root — still one repo.
195
197
 
196
198
  ---
197
199
 
@@ -211,12 +213,12 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
211
213
  |----------|--------|
212
214
  | `conventions.test_command` | service's `conventions.test_command` |
213
215
  | `conventions.build_command` | service's `conventions.build_command` |
214
- | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` default: `{active_service}/.trace` |
215
- | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
216
+ | `paths.trace_dir` | **If `spec_source` is set → keep the Step 4 spec-repo route (`{spec_source}/.trace`); ignore any service-level `trace_dir`.** Only when there is no `spec_source`: `{active_service}/{service paths.trace_dir}` (default `{active_service}/.trace`). |
217
+ | `paths.specs_dir` | **If `spec_source` is set → keep the Step 4 spec-repo route (`{spec_source}/specs/bdd`); ignore any service-level `specs_dir`** (BDD is cross-team, never per-service in this mode). Only when there is no `spec_source`: `{active_service}/{service paths.specs_dir}` if set, else the Step 1.5 override. |
216
218
 
217
219
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
218
220
  - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
219
- - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
221
+ - **Source/test files** are written relative to `service_root`; **trace TSVs** are written to `{paths.trace_dir}` (the spec repo when `spec_source` is set — a cross-repo write, committed/pushed to the spec submodule like `feedback/`).
220
222
 
221
223
  **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).
222
224
 
@@ -628,6 +630,36 @@ Output Artifacts:
628
630
 
629
631
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
630
632
 
633
+ ## Pipeline Position
634
+
635
+ Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
636
+ so the user always sees where this command sits in the end-to-end flow:
637
+
638
+ ```
639
+ Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
640
+ ```
641
+
642
+ Find the current command in this phase legend and mark **its** phase in the map above:
643
+
644
+ | Phase | Commands |
645
+ |-------|----------|
646
+ | Discovery | `/define-product` |
647
+ | PRD | `/generate-prd` · `/refine-prd` · `/review-context` (PRD) |
648
+ | Design Spec | `/generate-design-spec` |
649
+ | BDD | `/generate-bdd` · `/review-context` (BDD) |
650
+ | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
651
+ | Code | `/generate-code` · `/review-code` |
652
+ | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
653
+ | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
654
+ | Trace Audit | `/validate-traces` |
655
+
656
+ For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
657
+ `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
658
+
659
+ **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
660
+ `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline —
661
+ **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
662
+
631
663
  ## Next Command Suggestion
632
664
 
633
665
  Suggest the logical next command based on workflow phase:
@@ -669,10 +701,13 @@ Suggest the logical next command based on workflow phase:
669
701
  Format the footer as:
670
702
  ```
671
703
  ---
672
- Status : {badge}
704
+ Status : {badge}
673
705
  {Output Artifacts block}
674
- Next : {suggested command with example arguments}
706
+ Pipeline : Discovery PRD [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
707
+ (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
708
+ Next : {suggested command with example arguments}
675
709
  ```
710
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
676
711
 
677
712
 
678
713
  ```
@@ -733,8 +768,9 @@ Edit the tech-doc file directly:
733
768
 
734
769
  Write both changes to the file.
735
770
 
736
- Then update `{paths.trace_dir}/{UC-ID}.tsv`:
737
- - Set `tech_doc_revision` column to the new `@trace.revision` integer for all rows of this UC.
771
+ Then update `{paths.trace_dir}/{UC-ID}.tsv` — pick the column by which tech-doc was reviewed (read the filename):
772
+ - **BE contract** (`{UC-ID}-tech-design.md`) → set `tech_doc_revision` to the new `@trace.revision` integer for all rows of this UC.
773
+ - **FE tech-design** (`{UC-ID}-tech-design-{platform}.md`) → set `fe_tech_doc_revision` instead, for the rows of this UC on that platform (leave `tech_doc_revision` untouched).
738
774
  - Set `last_updated` to today's date (`YYYY-MM-DD`) for all rows of this UC.
739
775
 
740
776
  Print the report after all file writes are complete.
@@ -166,8 +166,8 @@ Create these directories (skip if they exist):
166
166
  | project_type | Create | Skip |
167
167
  |---|---|---|
168
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/` |
169
+ | **2 — Umbrella** | `.agent/review/` only (at umbrella root) | Everything else — **all specs live in the spec submodule (`spec_source`)**; service submodules hold only **code + `.trace/`** |
170
+ | **3 — PO Spec repo** | `specs/prd/`, `specs/design-spec/`, `specs/product-definition/`, `specs/domain-knowledge/`, **`specs/bdd/`**, **`specs/tech-docs/`**, **`feedback/`**, `.agent/review/` | `.trace/` (per-service, lives beside code in each service submodule) |
171
171
 
172
172
  ## Step 2 — Create CLAUDE.md
173
173
 
@@ -392,6 +392,36 @@ Output Artifacts:
392
392
 
393
393
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
394
394
 
395
+ ## Pipeline Position
396
+
397
+ Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
398
+ so the user always sees where this command sits in the end-to-end flow:
399
+
400
+ ```
401
+ Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
402
+ ```
403
+
404
+ Find the current command in this phase legend and mark **its** phase in the map above:
405
+
406
+ | Phase | Commands |
407
+ |-------|----------|
408
+ | Discovery | `/define-product` |
409
+ | PRD | `/generate-prd` · `/refine-prd` · `/review-context` (PRD) |
410
+ | Design Spec | `/generate-design-spec` |
411
+ | BDD | `/generate-bdd` · `/review-context` (BDD) |
412
+ | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
413
+ | Code | `/generate-code` · `/review-code` |
414
+ | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
415
+ | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
416
+ | Trace Audit | `/validate-traces` |
417
+
418
+ For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
419
+ `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
420
+
421
+ **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
422
+ `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline —
423
+ **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
424
+
395
425
  ## Next Command Suggestion
396
426
 
397
427
  Suggest the logical next command based on workflow phase:
@@ -433,10 +463,13 @@ Suggest the logical next command based on workflow phase:
433
463
  Format the footer as:
434
464
  ```
435
465
  ---
436
- Status : {badge}
466
+ Status : {badge}
437
467
  {Output Artifacts block}
438
- Next : {suggested command with example arguments}
468
+ Pipeline : Discovery PRD [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
469
+ (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
470
+ Next : {suggested command with example arguments}
439
471
  ```
472
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
440
473
 
441
474
 
442
475
  ```
@@ -324,6 +324,36 @@ Output Artifacts:
324
324
 
325
325
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
326
326
 
327
+ ## Pipeline Position
328
+
329
+ Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
330
+ so the user always sees where this command sits in the end-to-end flow:
331
+
332
+ ```
333
+ Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
334
+ ```
335
+
336
+ Find the current command in this phase legend and mark **its** phase in the map above:
337
+
338
+ | Phase | Commands |
339
+ |-------|----------|
340
+ | Discovery | `/define-product` |
341
+ | PRD | `/generate-prd` · `/refine-prd` · `/review-context` (PRD) |
342
+ | Design Spec | `/generate-design-spec` |
343
+ | BDD | `/generate-bdd` · `/review-context` (BDD) |
344
+ | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
345
+ | Code | `/generate-code` · `/review-code` |
346
+ | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
347
+ | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
348
+ | Trace Audit | `/validate-traces` |
349
+
350
+ For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
351
+ `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
352
+
353
+ **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
354
+ `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline —
355
+ **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
356
+
327
357
  ## Next Command Suggestion
328
358
 
329
359
  Suggest the logical next command based on workflow phase:
@@ -365,10 +395,13 @@ Suggest the logical next command based on workflow phase:
365
395
  Format the footer as:
366
396
  ```
367
397
  ---
368
- Status : {badge}
398
+ Status : {badge}
369
399
  {Output Artifacts block}
370
- Next : {suggested command with example arguments}
400
+ Pipeline : Discovery PRD [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
401
+ (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
402
+ Next : {suggested command with example arguments}
371
403
  ```
404
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
372
405
 
373
406
 
374
407
  ```
@@ -147,6 +147,36 @@ Output Artifacts:
147
147
 
148
148
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
149
149
 
150
+ ## Pipeline Position
151
+
152
+ Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
153
+ so the user always sees where this command sits in the end-to-end flow:
154
+
155
+ ```
156
+ Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
157
+ ```
158
+
159
+ Find the current command in this phase legend and mark **its** phase in the map above:
160
+
161
+ | Phase | Commands |
162
+ |-------|----------|
163
+ | Discovery | `/define-product` |
164
+ | PRD | `/generate-prd` · `/refine-prd` · `/review-context` (PRD) |
165
+ | Design Spec | `/generate-design-spec` |
166
+ | BDD | `/generate-bdd` · `/review-context` (BDD) |
167
+ | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
168
+ | Code | `/generate-code` · `/review-code` |
169
+ | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
170
+ | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
171
+ | Trace Audit | `/validate-traces` |
172
+
173
+ For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
174
+ `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
175
+
176
+ **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
177
+ `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline —
178
+ **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
179
+
150
180
  ## Next Command Suggestion
151
181
 
152
182
  Suggest the logical next command based on workflow phase:
@@ -188,10 +218,13 @@ Suggest the logical next command based on workflow phase:
188
218
  Format the footer as:
189
219
  ```
190
220
  ---
191
- Status : {badge}
221
+ Status : {badge}
192
222
  {Output Artifacts block}
193
- Next : {suggested command with example arguments}
223
+ Pipeline : Discovery PRD [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
224
+ (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
225
+ Next : {suggested command with example arguments}
194
226
  ```
227
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
195
228
 
196
229
 
197
230
  ```
@@ -168,7 +168,7 @@ If `services` section is present:
168
168
  - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
169
169
 
170
170
  **2. Route to service** — if active domain matches a key in `services`:
171
- - Override `paths.specs_dir` → `services.{domain}.specs_dir`
171
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir` — **only if `setup.spec_source` is NOT set.** When `spec_source` IS set, ALL BDD (web/app/**system**) is a shared cross-team artifact → leave `specs_dir` for step 4 to route to the spec repo; do NOT pin it per-service here.
172
172
  - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir` — **only if `setup.spec_source` is NOT set.** When `spec_source` IS set, the tech-design (API contract) is a cross-team artifact and must live in the shared spec repo (handled in step 4), so leave `tech_docs_dir` for step 4 to route — do NOT pin it per-service here.
173
173
  - Store `active_service` = `services.{domain}.path`
174
174
  - Store `active_service_module` = `services.{domain}.module`
@@ -179,6 +179,7 @@ If `services` section is present:
179
179
  - Set `active_service = unresolved`
180
180
 
181
181
  **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
182
+ - Override `paths.specs_dir` → `{spec_source}/specs/bdd` — **always when `spec_source` is set.** All BDD (web/app/**system**) lives in the shared spec repo so every umbrella (FE/App/BE) reads the same scenarios; the FE tech-design gate + `/generate-code --phase=ui`/`--phase=integration` resolve the `system/` BDD here. *(Per-service `specs/bdd` only when there is no `spec_source`.)*
182
183
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
183
184
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
184
185
  - Override `paths.tech_docs_dir` → `{spec_source}/specs/tech-docs` — **always when `spec_source` is set** (step 2 no longer pins tech-docs per-service in this case). The tech-design IS the cross-team API contract: BE authors it here, and FE/App read it from the same spec submodule at `/generate-code --phase=integration`. *(Per-service tech-docs only happen when there is no `spec_source` — a pure multi-service BE repo with no shared spec module.)*
@@ -188,8 +189,9 @@ If `services` section is present:
188
189
  - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
189
190
  - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
190
191
  - Override `paths.prd_change_requests_dir` → `{spec_source}/feedback/prd-change-requests`
192
+ - Override `paths.trace_dir` → `{spec_source}/.trace` — **always when `spec_source` is set.** Trace TSVs are consolidated in the spec repo (single authoritative location, no per-service split) so the PM/PO has one place to manage status. Code-side commands (`/generate-code`, `/dev-run-test`, `/qc-run-test`) run from `service_root` but **write their trace row into `{spec_source}/.trace`** — like they already push `feedback/` there. *(Per-service `.trace` only when there is no `spec_source`.)*
191
193
 
192
- > **Why under `spec_source`:** PRD, design-spec, domain knowledge, the **API contract (tech-docs)**, and tester feedback are all **cross-team artifacts** — they must live in the **shared spec repo** so every umbrella (FE/App/BE) reads the same source via `/sync`. Tech-docs specifically: BE authors the tech-design (API contract), commits + pushes it into the spec submodule (2-layer commit), and FE/App pull it on their next `/sync` to wire the real API in `/generate-code --phase=integration`. In single-service mode (no `spec_source`), these default under the repo root — still shared, same repo.
194
+ > **Why under `spec_source`:** PRD, design-spec, domain knowledge, **all BDD (web/app/system)**, the **API contract (tech-docs)**, tester feedback, **and the `.trace/` coverage state** are all **cross-team artifacts** — they live in the **shared spec repo** so every umbrella (FE/App/BE) and the PM read one source via `/sync`. The service submodule holds only **code** (+ build/test tooling). `.trace/` and `feedback/` are the dev/QC **write areas** in the spec repo (the PRD/BDD/design-spec/tech-docs there stay read-only for dev/QC only PO edits those). In single-service mode (no `spec_source`), everything defaults under the repo root — still one repo.
193
195
 
194
196
  ---
195
197
 
@@ -209,12 +211,12 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
209
211
  |----------|--------|
210
212
  | `conventions.test_command` | service's `conventions.test_command` |
211
213
  | `conventions.build_command` | service's `conventions.build_command` |
212
- | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` default: `{active_service}/.trace` |
213
- | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
214
+ | `paths.trace_dir` | **If `spec_source` is set → keep the Step 4 spec-repo route (`{spec_source}/.trace`); ignore any service-level `trace_dir`.** Only when there is no `spec_source`: `{active_service}/{service paths.trace_dir}` (default `{active_service}/.trace`). |
215
+ | `paths.specs_dir` | **If `spec_source` is set → keep the Step 4 spec-repo route (`{spec_source}/specs/bdd`); ignore any service-level `specs_dir`** (BDD is cross-team, never per-service in this mode). Only when there is no `spec_source`: `{active_service}/{service paths.specs_dir}` if set, else the Step 1.5 override. |
214
216
 
215
217
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
216
218
  - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
217
- - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
219
+ - **Source/test files** are written relative to `service_root`; **trace TSVs** are written to `{paths.trace_dir}` (the spec repo when `spec_source` is set — a cross-repo write, committed/pushed to the spec submodule like `feedback/`).
218
220
 
219
221
  **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).
220
222
 
@@ -400,16 +402,15 @@ Proceed to the next step of the calling command.
400
402
  Check whether `services` array exists in `project-context.yaml`.
401
403
 
402
404
  **If `services` exists (umbrella mode):**
403
- - Resolve the trace dir for each service:
404
- - Use `services[N].trace_dir` if explicitly set
405
- - Otherwise default to `{services[N].path}/.trace`
406
- - Set `all_trace_dirs = [ dir1, dir2, ... ]` — one per service
407
- - Step 1 will read TSVs from ALL dirs in `all_trace_dirs`, tagged by service name
408
- - **Resolve the Living Docs home (canonical report location):**
405
+ - Resolve the trace dir(s):
406
+ - **If `setup.spec_source` is set (consolidated trace):** `all_trace_dirs = [ {spec_source}/.trace ]` — a **single** authoritative location in the spec repo. Scenarios carry their owning service via the `@trace.service` field, so no per-service split is needed. This is the common case.
407
+ - **Else (no spec_source — legacy per-service trace):** one dir per service — `services[N].trace_dir` if set, else `{services[N].path}/.trace`; `all_trace_dirs = [ dir1, dir2, … ]`, tagged by service name on read.
408
+ - Step 1 reads TSVs from `all_trace_dirs`.
409
+ - **Resolve the Living Docs home (generated report location):**
409
410
  - If `setup.spec_source` is set → `living_docs_dir = {spec_source}/.living-docs`
410
411
  *(the shared specs module — mounted inside every service/umbrella workspace, so the panel resolves it no matter which submodule the dev is standing in)*
411
412
  - Else (umbrella without a separate spec repo) → `living_docs_dir = .living-docs` at umbrella root
412
- - **Resolve the panel mirror:** `panel_mirror = ./.trace` at the **current workspace root** (wherever this command runs). The VS Code panel reads `.trace/trace-report.json` from the open workspace — writing the merged report here is what makes the view non-empty when a dev opens a service submodule directly.
413
+ - **Resolve the panel mirror:** `panel_mirror = ./.trace` at the **current workspace root** (wherever this command runs). The VS Code panel reads `.trace/trace-report.json` from the open workspace — writing the report here is what makes the view non-empty when a dev opens a service submodule directly.
413
414
 
414
415
  **If no `services` key (single-service mode):**
415
416
  - Set `all_trace_dirs = [ {paths.trace_dir} ]`
@@ -461,11 +462,14 @@ If any layer is behind current PRD version → flag `PRD_DRIFT` and extract chan
461
462
 
462
463
  ### Step 5 — Tech-doc revision drift check
463
464
 
464
- For each UC that has a tech-doc, compare:
465
- - Current `@trace.revision` in `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md`
466
- - `tech_doc_revision` stored in `.tsv` (revision at time of codegen)
465
+ For each UC that has a tech-doc, compare the stored revision against the current doc — for **both** tech-doc kinds:
467
466
 
468
- If code was generated from an older revision flag `TECHDOC_DRIFT`.
467
+ - **BE contract:** `@trace.revision` in `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md` vs `tech_doc_revision` in `.tsv`.
468
+ Code generated from an older revision → flag `TECHDOC_DRIFT`.
469
+ - **FE tech-design:** `@trace.revision` in `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design-{platform}.md` vs `fe_tech_doc_revision` in `.tsv` (per platform row).
470
+ FE code generated from an older revision → flag `FE_TECHDOC_DRIFT`.
471
+
472
+ Skip whichever kind has no doc / no stored revision (`—`).
469
473
 
470
474
  ### Step 6 — Write status back to TSV
471
475
 
@@ -572,6 +576,7 @@ Schema:
572
576
  "prd_version": "<prd version when BDD was generated>",
573
577
  "bdd_version": "<bdd version when code was generated>",
574
578
  "tech_doc_revision": 0,
579
+ "fe_tech_doc_revision": 0,
575
580
  "status": "OK | DRIFT | GAP | UNTRACKED",
576
581
  "last_updated": "<YYYY-MM-DD>"
577
582
  }
@@ -621,6 +626,15 @@ Schema:
621
626
  "current_revision": 0,
622
627
  "fix": "/generate-code <UC-ID>"
623
628
  }
629
+ ],
630
+ "fe_techdoc_drift": [
631
+ {
632
+ "uc_id": "<UC-ID>",
633
+ "platform": "web | app",
634
+ "code_revision": 0,
635
+ "current_revision": 0,
636
+ "fix": "/generate-code <UC-ID> --phase=integration"
637
+ }
624
638
  ]
625
639
  }
626
640
  }
@@ -630,44 +644,42 @@ Schema:
630
644
  - `implemented_by`: use `null` (not `"—"`) in JSON when no value
631
645
  - `test_count`: use integer `0` (not `"—"`) when no tests
632
646
  - `test_classes`: use `[]` (not `"—"`) when no test classes
633
- - `tech_doc_revision`: use integer; `0` if not yet generated
647
+ - `tech_doc_revision` / `fe_tech_doc_revision`: use integer; `0` if not yet generated
634
648
  - `code_coverage_pct` / `test_coverage_pct`: round to nearest integer (0–100)
635
649
  - 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
636
- - **TSV `"—"` mapping**: when reading TSV files, map dash values to JSON types: `implemented_by: "—"` → `null`; `test_count: "—"` → `0`; `test_classes: "—"` → `[]`; `tech_doc_revision: "—"` → `0`; `dev_selftest: "—"` → `"not_run"`; `dev_selftest_at: "—"` → `null`; `qc_status: "—"` → `"not_run"`; `qc_run_at: "—"` → `null`; `qc_owner: "—"` → `null`; `qc_blocked_by: "—"` → `null`
637
- - **Backward-compat (older 19-col TSV):** if `qc_owner` / `qc_blocked_by` columns are **absent** from the header (a pre-upgrade TSV), treat them as `null` do not error. The next `/generate-bdd` re-gen upgrades the header to include them.
650
+ - **TSV `"—"` mapping**: when reading TSV files, map dash values to JSON types: `implemented_by: "—"` → `null`; `test_count: "—"` → `0`; `test_classes: "—"` → `[]`; `tech_doc_revision: "—"` → `0`; `fe_tech_doc_revision: "—"` → `0`; `dev_selftest: "—"` → `"not_run"`; `dev_selftest_at: "—"` → `null`; `qc_status: "—"` → `"not_run"`; `qc_run_at: "—"` → `null`; `qc_owner: "—"` → `null`; `qc_blocked_by: "—"` → `null`
651
+ - **Backward-compat:** older TSVs may be missing newer columns from the header — treat any absent column as its empty value (do not error): `qc_owner`/`qc_blocked_by` (pre-19-col) `null`; `fe_tech_doc_revision` (pre-22-col) `0`. The next `/generate-bdd` re-gen upgrades the header to the current 22-column layout.
638
652
 
639
653
  ### Step 8b — Living Docs Sync *(umbrella mode only)*
640
654
 
641
655
  *Skip this step in single-service mode.*
642
656
 
643
- Authoritative trace state stays in each service submodule's `.trace/` (committed there).
644
- This step publishes the merged report to the **canonical Living Docs home** (the specs
645
- module) and drops a local mirror so the panel is never empty.
657
+ **With `spec_source` set,** the authoritative trace TSVs already live in **one** place —
658
+ `{spec_source}/.trace/` (committed in the spec repo). There is **no per-service merge**:
659
+ each scenario row carries its owning service via `@trace.service`. This step just
660
+ (re)generates the report and refreshes the local panel.
646
661
 
647
- 1. **Write canonical merged report** to `{living_docs_dir}/` (`mkdir -p` it first):
648
- - `{living_docs_dir}/trace-report.json` merge every per-service `trace-report.json`
649
- into one document, add a `"service"` field per scenario row, recalc summary aggregates.
650
- - `{living_docs_dir}/{service-name}/{UC-ID}.tsv` copy each service's TSVs, namespaced
651
- by service. Overwrite; don't delete TSVs whose service source is gone (prior runs).
662
+ 1. **Write the report** to `{living_docs_dir}/trace-report.json` (`mkdir -p` first) — built
663
+ directly from `{spec_source}/.trace/*.tsv`, with a `"service"` field per scenario row and
664
+ the summary aggregates. *(Legacy no-`spec_source` umbrellas still merge every per-service
665
+ `trace-report.json` into one document, namespaced by service.)*
652
666
 
653
667
  2. **Mirror to the panel location** `{panel_mirror}` (`./.trace` at the current workspace
654
- root) so a dev who opened *this* repo (umbrella **or** a single service submodule) sees
655
- data immediately: copy `{living_docs_dir}/trace-report.json` → `{panel_mirror}/trace-report.json`
656
- (and the namespaced TSVs). If `panel_mirror` already resolves to `living_docs_dir`, skip.
668
+ root) so a dev who opened *this* repo sees data immediately: copy
669
+ `{living_docs_dir}/trace-report.json` (+ the `{UC-ID}.tsv` files) → `{panel_mirror}/`.
670
+ If `panel_mirror` already resolves to `{spec_source}/.trace`, skip.
657
671
 
658
672
  3. **Print sync summary:**
659
673
  ```
660
- Living Docs → {living_docs_dir}/ (canonical, in specs module)
661
- user-service : {N} TSV files
662
- order-service : {N} TSV files
663
- trace-report.json: merged ({total} scenarios across {S} services)
674
+ Living Docs → {living_docs_dir}/trace-report.json ({total} scenarios across {S} services)
675
+ Trace (authoritative) → {spec_source}/.trace/ (committed in spec repo)
664
676
  Panel mirror → {panel_mirror}/trace-report.json (current workspace)
665
677
  ```
666
678
 
667
- > **Note both locations are generated, gitignored mirrors.** Add `.living-docs/` to the
668
- > **specs module's** `.gitignore` and `.trace/` to the current repo's `.gitignore`. The only
669
- > committed, authoritative trace state is each service submodule's own `.trace/`. The report
670
- > is regenerated by `/validate-traces` or `/sync` — never commit it.
679
+ > **Note:** the committed, authoritative trace state is `{spec_source}/.trace/*.tsv` (in the
680
+ > spec repo one place for the PM). The report (`.living-docs/`) and the panel mirror
681
+ > (`./.trace` at a workspace that is not the spec repo) are **generated** — gitignore them;
682
+ > they are regenerated by `/validate-traces` or `/sync`.
671
683
 
672
684
  ## Output
673
685
 
@@ -693,6 +705,36 @@ Output Artifacts:
693
705
 
694
706
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
695
707
 
708
+ ## Pipeline Position
709
+
710
+ Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
711
+ so the user always sees where this command sits in the end-to-end flow:
712
+
713
+ ```
714
+ Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
715
+ ```
716
+
717
+ Find the current command in this phase legend and mark **its** phase in the map above:
718
+
719
+ | Phase | Commands |
720
+ |-------|----------|
721
+ | Discovery | `/define-product` |
722
+ | PRD | `/generate-prd` · `/refine-prd` · `/review-context` (PRD) |
723
+ | Design Spec | `/generate-design-spec` |
724
+ | BDD | `/generate-bdd` · `/review-context` (BDD) |
725
+ | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
726
+ | Code | `/generate-code` · `/review-code` |
727
+ | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
728
+ | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
729
+ | Trace Audit | `/validate-traces` |
730
+
731
+ For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
732
+ `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
733
+
734
+ **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
735
+ `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline —
736
+ **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
737
+
696
738
  ## Next Command Suggestion
697
739
 
698
740
  Suggest the logical next command based on workflow phase:
@@ -734,10 +776,13 @@ Suggest the logical next command based on workflow phase:
734
776
  Format the footer as:
735
777
  ```
736
778
  ---
737
- Status : {badge}
779
+ Status : {badge}
738
780
  {Output Artifacts block}
739
- Next : {suggested command with example arguments}
781
+ Pipeline : Discovery PRD [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
782
+ (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
783
+ Next : {suggested command with example arguments}
740
784
  ```
785
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
741
786
 
742
787
 
743
788
  ```