@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
@@ -176,7 +176,7 @@ If `services` section is present:
176
176
  - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
177
177
 
178
178
  **2. Route to service** — if active domain matches a key in `services`:
179
- - Override `paths.specs_dir` → `services.{domain}.specs_dir`
179
+ - 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.
180
180
  - 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.
181
181
  - Store `active_service` = `services.{domain}.path`
182
182
  - Store `active_service_module` = `services.{domain}.module`
@@ -187,6 +187,7 @@ If `services` section is present:
187
187
  - Set `active_service = unresolved`
188
188
 
189
189
  **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
190
+ - 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`.)*
190
191
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
191
192
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
192
193
  - 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.)*
@@ -196,8 +197,9 @@ If `services` section is present:
196
197
  - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
197
198
  - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
198
199
  - Override `paths.prd_change_requests_dir` → `{spec_source}/feedback/prd-change-requests`
200
+ - 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`.)*
199
201
 
200
- > **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.
202
+ > **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.
201
203
 
202
204
  ---
203
205
 
@@ -217,12 +219,12 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
217
219
  |----------|--------|
218
220
  | `conventions.test_command` | service's `conventions.test_command` |
219
221
  | `conventions.build_command` | service's `conventions.build_command` |
220
- | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` default: `{active_service}/.trace` |
221
- | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
222
+ | `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`). |
223
+ | `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. |
222
224
 
223
225
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
224
226
  - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
225
- - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
227
+ - **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/`).
226
228
 
227
229
  **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).
228
230
 
@@ -502,6 +504,36 @@ Output Artifacts:
502
504
 
503
505
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
504
506
 
507
+ ## Pipeline Position
508
+
509
+ Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
510
+ so the user always sees where this command sits in the end-to-end flow:
511
+
512
+ ```
513
+ Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
514
+ ```
515
+
516
+ Find the current command in this phase legend and mark **its** phase in the map above:
517
+
518
+ | Phase | Commands |
519
+ |-------|----------|
520
+ | Discovery | `/define-product` |
521
+ | PRD | `/generate-prd` · `/refine-prd` · `/review-context` (PRD) |
522
+ | Design Spec | `/generate-design-spec` |
523
+ | BDD | `/generate-bdd` · `/review-context` (BDD) |
524
+ | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
525
+ | Code | `/generate-code` · `/review-code` |
526
+ | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
527
+ | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
528
+ | Trace Audit | `/validate-traces` |
529
+
530
+ For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
531
+ `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
532
+
533
+ **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
534
+ `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline —
535
+ **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
536
+
505
537
  ## Next Command Suggestion
506
538
 
507
539
  Suggest the logical next command based on workflow phase:
@@ -543,10 +575,13 @@ Suggest the logical next command based on workflow phase:
543
575
  Format the footer as:
544
576
  ```
545
577
  ---
546
- Status : {badge}
578
+ Status : {badge}
547
579
  {Output Artifacts block}
548
- Next : {suggested command with example arguments}
580
+ Pipeline : Discovery PRD [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
581
+ (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
582
+ Next : {suggested command with example arguments}
549
583
  ```
584
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
550
585
 
551
586
 
552
587
  ```
@@ -174,7 +174,7 @@ If `services` section is present:
174
174
  - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
175
175
 
176
176
  **2. Route to service** — if active domain matches a key in `services`:
177
- - Override `paths.specs_dir` → `services.{domain}.specs_dir`
177
+ - 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.
178
178
  - 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.
179
179
  - Store `active_service` = `services.{domain}.path`
180
180
  - Store `active_service_module` = `services.{domain}.module`
@@ -185,6 +185,7 @@ If `services` section is present:
185
185
  - Set `active_service = unresolved`
186
186
 
187
187
  **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
188
+ - 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`.)*
188
189
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
189
190
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
190
191
  - 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.)*
@@ -194,8 +195,9 @@ If `services` section is present:
194
195
  - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
195
196
  - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
196
197
  - Override `paths.prd_change_requests_dir` → `{spec_source}/feedback/prd-change-requests`
198
+ - 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`.)*
197
199
 
198
- > **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.
200
+ > **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.
199
201
 
200
202
  ---
201
203
 
@@ -215,12 +217,12 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
215
217
  |----------|--------|
216
218
  | `conventions.test_command` | service's `conventions.test_command` |
217
219
  | `conventions.build_command` | service's `conventions.build_command` |
218
- | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` default: `{active_service}/.trace` |
219
- | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
220
+ | `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`). |
221
+ | `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. |
220
222
 
221
223
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
222
224
  - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
223
- - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
225
+ - **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/`).
224
226
 
225
227
  **4. If service config not found** — keep umbrella defaults, still set `service_root = {active_service}` (path anchor is always needed even without a config override).
226
228
 
@@ -477,6 +479,36 @@ Output Artifacts:
477
479
 
478
480
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
479
481
 
482
+ ## Pipeline Position
483
+
484
+ Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
485
+ so the user always sees where this command sits in the end-to-end flow:
486
+
487
+ ```
488
+ Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
489
+ ```
490
+
491
+ Find the current command in this phase legend and mark **its** phase in the map above:
492
+
493
+ | Phase | Commands |
494
+ |-------|----------|
495
+ | Discovery | `/define-product` |
496
+ | PRD | `/generate-prd` · `/refine-prd` · `/review-context` (PRD) |
497
+ | Design Spec | `/generate-design-spec` |
498
+ | BDD | `/generate-bdd` · `/review-context` (BDD) |
499
+ | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
500
+ | Code | `/generate-code` · `/review-code` |
501
+ | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
502
+ | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
503
+ | Trace Audit | `/validate-traces` |
504
+
505
+ For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
506
+ `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
507
+
508
+ **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
509
+ `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline —
510
+ **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
511
+
480
512
  ## Next Command Suggestion
481
513
 
482
514
  Suggest the logical next command based on workflow phase:
@@ -518,10 +550,13 @@ Suggest the logical next command based on workflow phase:
518
550
  Format the footer as:
519
551
  ```
520
552
  ---
521
- Status : {badge}
553
+ Status : {badge}
522
554
  {Output Artifacts block}
523
- Next : {suggested command with example arguments}
555
+ Pipeline : Discovery PRD [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
556
+ (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
557
+ Next : {suggested command with example arguments}
524
558
  ```
559
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
525
560
 
526
561
 
527
562
  ```
@@ -92,7 +92,7 @@ Wait for explicit "Y" or "N" from the user before continuing.
92
92
  - "N" → stop and ask what the user wants to change.
93
93
 
94
94
 
95
- *Note: For this command, the target in Step 1 is a UC-ID. Read the qc-analyze + qc-plan outputs (`REQUIREMENT_ANALYSIS.md`, `DOC_GAPS.md`, `TEST_PLAN.md`) from `{paths.qc_dir}/{UC-ID}/` and the official `.feature` (with `@trace.scenario` per scenario).*
95
+ *Note: For this command, the target in Step 1 is a UC-ID. Read the qc-analyze + qc-plan outputs (`REQUIREMENT_ANALYSIS.md`, `DOC_GAPS.md`, `TEST_PLAN.md`) from `{paths.qc_dir}/{UC-ID}/` and the official `.feature` (with `@trace.scenario` per scenario). For GUI layers, also read the FE tech-design §2b **Test Selectors** table at `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design-{platform}.md` (if present) — the stable test-ids QC will locate by.*
96
96
 
97
97
  ## Context
98
98
  # Context Loader — Load All Project Context
@@ -174,7 +174,7 @@ If `services` section is present:
174
174
  - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
175
175
 
176
176
  **2. Route to service** — if active domain matches a key in `services`:
177
- - Override `paths.specs_dir` → `services.{domain}.specs_dir`
177
+ - 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.
178
178
  - 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.
179
179
  - Store `active_service` = `services.{domain}.path`
180
180
  - Store `active_service_module` = `services.{domain}.module`
@@ -185,6 +185,7 @@ If `services` section is present:
185
185
  - Set `active_service = unresolved`
186
186
 
187
187
  **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
188
+ - 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`.)*
188
189
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
189
190
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
190
191
  - 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.)*
@@ -194,8 +195,9 @@ If `services` section is present:
194
195
  - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
195
196
  - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
196
197
  - Override `paths.prd_change_requests_dir` → `{spec_source}/feedback/prd-change-requests`
198
+ - 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`.)*
197
199
 
198
- > **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.
200
+ > **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.
199
201
 
200
202
  ---
201
203
 
@@ -215,12 +217,12 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
215
217
  |----------|--------|
216
218
  | `conventions.test_command` | service's `conventions.test_command` |
217
219
  | `conventions.build_command` | service's `conventions.build_command` |
218
- | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` default: `{active_service}/.trace` |
219
- | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
220
+ | `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`). |
221
+ | `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. |
220
222
 
221
223
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
222
224
  - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
223
- - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
225
+ - **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/`).
224
226
 
225
227
  **4. If service config not found** — keep umbrella defaults, still set `service_root = {active_service}` (path anchor is always needed even without a config override).
226
228
 
@@ -423,6 +425,7 @@ qc-review. You do **not** write Python.
423
425
  - TC ID `TC_<FEATURE>_<NNN>`; split happy/negative; one assertion concern per TC; concrete expected values.
424
426
  - Priority `P0/P1/P2`; Tags (`smoke regression happy-path negative ui …`); Status `Draft → In Progress → Pass/Fail/Skip`.
425
427
  - A TC blocked by a gap is still written + marked `🚫 Block: GAP-xx`.
428
+ - **Reference test-ids, not visual cues.** For each GUI step that acts on an element, cite the stable test-id from the FE tech-design §2b table (e.g. "click `ft001-login-submit-btn`") so qc-run-test builds the locator from the contract. If an actionable element has no test-id in §2b, note it (qc-run-test will fall back to a slower role/text locator).
426
429
  - End-of-file: Trace matrix + blocked-TC table.
427
430
 
428
431
  ## Trace mapping (mandatory)
@@ -460,6 +463,36 @@ Output Artifacts:
460
463
 
461
464
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
462
465
 
466
+ ## Pipeline Position
467
+
468
+ Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
469
+ so the user always sees where this command sits in the end-to-end flow:
470
+
471
+ ```
472
+ Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
473
+ ```
474
+
475
+ Find the current command in this phase legend and mark **its** phase in the map above:
476
+
477
+ | Phase | Commands |
478
+ |-------|----------|
479
+ | Discovery | `/define-product` |
480
+ | PRD | `/generate-prd` · `/refine-prd` · `/review-context` (PRD) |
481
+ | Design Spec | `/generate-design-spec` |
482
+ | BDD | `/generate-bdd` · `/review-context` (BDD) |
483
+ | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
484
+ | Code | `/generate-code` · `/review-code` |
485
+ | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
486
+ | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
487
+ | Trace Audit | `/validate-traces` |
488
+
489
+ For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
490
+ `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
491
+
492
+ **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
493
+ `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline —
494
+ **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
495
+
463
496
  ## Next Command Suggestion
464
497
 
465
498
  Suggest the logical next command based on workflow phase:
@@ -501,10 +534,13 @@ Suggest the logical next command based on workflow phase:
501
534
  Format the footer as:
502
535
  ```
503
536
  ---
504
- Status : {badge}
537
+ Status : {badge}
505
538
  {Output Artifacts block}
506
- Next : {suggested command with example arguments}
539
+ Pipeline : Discovery PRD [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
540
+ (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
541
+ Next : {suggested command with example arguments}
507
542
  ```
543
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
508
544
 
509
545
 
510
546
  ```
@@ -174,7 +174,7 @@ If `services` section is present:
174
174
  - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
175
175
 
176
176
  **2. Route to service** — if active domain matches a key in `services`:
177
- - Override `paths.specs_dir` → `services.{domain}.specs_dir`
177
+ - 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.
178
178
  - 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.
179
179
  - Store `active_service` = `services.{domain}.path`
180
180
  - Store `active_service_module` = `services.{domain}.module`
@@ -185,6 +185,7 @@ If `services` section is present:
185
185
  - Set `active_service = unresolved`
186
186
 
187
187
  **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
188
+ - 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`.)*
188
189
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
189
190
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
190
191
  - 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.)*
@@ -194,8 +195,9 @@ If `services` section is present:
194
195
  - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
195
196
  - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
196
197
  - Override `paths.prd_change_requests_dir` → `{spec_source}/feedback/prd-change-requests`
198
+ - 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`.)*
197
199
 
198
- > **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.
200
+ > **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.
199
201
 
200
202
  ---
201
203
 
@@ -215,12 +217,12 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
215
217
  |----------|--------|
216
218
  | `conventions.test_command` | service's `conventions.test_command` |
217
219
  | `conventions.build_command` | service's `conventions.build_command` |
218
- | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` default: `{active_service}/.trace` |
219
- | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
220
+ | `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`). |
221
+ | `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. |
220
222
 
221
223
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
222
224
  - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
223
- - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
225
+ - **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/`).
224
226
 
225
227
  **4. If service config not found** — keep umbrella defaults, still set `service_root = {active_service}` (path anchor is always needed even without a config override).
226
228
 
@@ -442,6 +444,36 @@ Output Artifacts:
442
444
 
443
445
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
444
446
 
447
+ ## Pipeline Position
448
+
449
+ Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
450
+ so the user always sees where this command sits in the end-to-end flow:
451
+
452
+ ```
453
+ Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
454
+ ```
455
+
456
+ Find the current command in this phase legend and mark **its** phase in the map above:
457
+
458
+ | Phase | Commands |
459
+ |-------|----------|
460
+ | Discovery | `/define-product` |
461
+ | PRD | `/generate-prd` · `/refine-prd` · `/review-context` (PRD) |
462
+ | Design Spec | `/generate-design-spec` |
463
+ | BDD | `/generate-bdd` · `/review-context` (BDD) |
464
+ | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
465
+ | Code | `/generate-code` · `/review-code` |
466
+ | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
467
+ | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
468
+ | Trace Audit | `/validate-traces` |
469
+
470
+ For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
471
+ `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
472
+
473
+ **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
474
+ `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline —
475
+ **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
476
+
445
477
  ## Next Command Suggestion
446
478
 
447
479
  Suggest the logical next command based on workflow phase:
@@ -483,10 +515,13 @@ Suggest the logical next command based on workflow phase:
483
515
  Format the footer as:
484
516
  ```
485
517
  ---
486
- Status : {badge}
518
+ Status : {badge}
487
519
  {Output Artifacts block}
488
- Next : {suggested command with example arguments}
520
+ Pipeline : Discovery PRD [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
521
+ (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
522
+ Next : {suggested command with example arguments}
489
523
  ```
524
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
490
525
 
491
526
 
492
527
  ```
@@ -174,7 +174,7 @@ If `services` section is present:
174
174
  - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
175
175
 
176
176
  **2. Route to service** — if active domain matches a key in `services`:
177
- - Override `paths.specs_dir` → `services.{domain}.specs_dir`
177
+ - 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.
178
178
  - 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.
179
179
  - Store `active_service` = `services.{domain}.path`
180
180
  - Store `active_service_module` = `services.{domain}.module`
@@ -185,6 +185,7 @@ If `services` section is present:
185
185
  - Set `active_service = unresolved`
186
186
 
187
187
  **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
188
+ - 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`.)*
188
189
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
189
190
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
190
191
  - 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.)*
@@ -194,8 +195,9 @@ If `services` section is present:
194
195
  - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
195
196
  - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
196
197
  - Override `paths.prd_change_requests_dir` → `{spec_source}/feedback/prd-change-requests`
198
+ - 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`.)*
197
199
 
198
- > **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.
200
+ > **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.
199
201
 
200
202
  ---
201
203
 
@@ -215,12 +217,12 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
215
217
  |----------|--------|
216
218
  | `conventions.test_command` | service's `conventions.test_command` |
217
219
  | `conventions.build_command` | service's `conventions.build_command` |
218
- | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` default: `{active_service}/.trace` |
219
- | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
220
+ | `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`). |
221
+ | `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. |
220
222
 
221
223
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
222
224
  - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
223
- - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
225
+ - **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/`).
224
226
 
225
227
  **4. If service config not found** — keep umbrella defaults, still set `service_root = {active_service}` (path anchor is always needed even without a config override).
226
228
 
@@ -447,6 +449,36 @@ Output Artifacts:
447
449
 
448
450
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
449
451
 
452
+ ## Pipeline Position
453
+
454
+ Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
455
+ so the user always sees where this command sits in the end-to-end flow:
456
+
457
+ ```
458
+ Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
459
+ ```
460
+
461
+ Find the current command in this phase legend and mark **its** phase in the map above:
462
+
463
+ | Phase | Commands |
464
+ |-------|----------|
465
+ | Discovery | `/define-product` |
466
+ | PRD | `/generate-prd` · `/refine-prd` · `/review-context` (PRD) |
467
+ | Design Spec | `/generate-design-spec` |
468
+ | BDD | `/generate-bdd` · `/review-context` (BDD) |
469
+ | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
470
+ | Code | `/generate-code` · `/review-code` |
471
+ | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
472
+ | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
473
+ | Trace Audit | `/validate-traces` |
474
+
475
+ For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
476
+ `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
477
+
478
+ **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
479
+ `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline —
480
+ **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
481
+
450
482
  ## Next Command Suggestion
451
483
 
452
484
  Suggest the logical next command based on workflow phase:
@@ -488,10 +520,13 @@ Suggest the logical next command based on workflow phase:
488
520
  Format the footer as:
489
521
  ```
490
522
  ---
491
- Status : {badge}
523
+ Status : {badge}
492
524
  {Output Artifacts block}
493
- Next : {suggested command with example arguments}
525
+ Pipeline : Discovery PRD [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
526
+ (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
527
+ Next : {suggested command with example arguments}
494
528
  ```
529
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
495
530
 
496
531
 
497
532
  ```