@anhth2/spec-driven-dev-plugin 0.10.0 → 0.12.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 (207) hide show
  1. package/commands/debug.md +43 -8
  2. package/commands/define-product.md +43 -8
  3. package/commands/dev-gen-test.md +44 -9
  4. package/commands/dev-gen-test.tmpl +1 -1
  5. package/commands/dev-run-test.md +48 -10
  6. package/commands/dev-run-test.tmpl +5 -2
  7. package/commands/dev-smoke-test.md +43 -8
  8. package/commands/fix-bug.md +79 -14
  9. package/commands/fix-bug.tmpl +36 -6
  10. package/commands/generate-bdd.md +49 -10
  11. package/commands/generate-bdd.tmpl +6 -2
  12. package/commands/generate-code.md +44 -9
  13. package/commands/generate-code.tmpl +1 -1
  14. package/commands/generate-design-spec.md +43 -8
  15. package/commands/generate-prd.md +43 -8
  16. package/commands/generate-spec-manifest.md +43 -8
  17. package/commands/generate-tech-docs.md +43 -8
  18. package/commands/learn.md +43 -8
  19. package/commands/propose-scenario.md +74 -19
  20. package/commands/propose-scenario.tmpl +31 -11
  21. package/commands/qc-analyze.md +534 -0
  22. package/commands/qc-analyze.tmpl +86 -0
  23. package/commands/qc-design-test.md +515 -0
  24. package/commands/qc-design-test.tmpl +67 -0
  25. package/commands/qc-plan.md +497 -0
  26. package/commands/qc-plan.tmpl +49 -0
  27. package/commands/qc-report.md +508 -0
  28. package/commands/qc-report.tmpl +60 -0
  29. package/commands/qc-review.md +501 -0
  30. package/commands/qc-review.tmpl +53 -0
  31. package/commands/qc-run-test.md +549 -0
  32. package/commands/qc-run-test.tmpl +83 -0
  33. package/commands/refine-prd.md +43 -8
  34. package/commands/report-bug.md +59 -10
  35. package/commands/report-bug.tmpl +16 -2
  36. package/commands/review-code.md +43 -8
  37. package/commands/review-context.md +43 -8
  38. package/commands/review-tech-docs.md +43 -8
  39. package/commands/setup-ai-first.md +7 -0
  40. package/commands/sync.md +19 -9
  41. package/commands/sync.tmpl +12 -9
  42. package/commands/update-framework.md +7 -0
  43. package/commands/validate-traces.md +67 -12
  44. package/commands/validate-traces.tmpl +24 -4
  45. package/core/FRAMEWORK_VERSION +1 -1
  46. package/core/commands/debug.md +43 -8
  47. package/core/commands/define-product.md +43 -8
  48. package/core/commands/dev-gen-test.md +44 -9
  49. package/core/commands/dev-run-test.md +48 -10
  50. package/core/commands/dev-smoke-test.md +43 -8
  51. package/core/commands/fix-bug.md +79 -14
  52. package/core/commands/generate-bdd.md +49 -10
  53. package/core/commands/generate-code.md +44 -9
  54. package/core/commands/generate-design-spec.md +43 -8
  55. package/core/commands/generate-prd.md +43 -8
  56. package/core/commands/generate-spec-manifest.md +43 -8
  57. package/core/commands/generate-tech-docs.md +43 -8
  58. package/core/commands/learn.md +43 -8
  59. package/core/commands/propose-scenario.md +74 -19
  60. package/core/commands/qc-analyze.md +534 -0
  61. package/core/commands/qc-design-test.md +515 -0
  62. package/core/commands/qc-plan.md +497 -0
  63. package/core/commands/qc-report.md +508 -0
  64. package/core/commands/qc-review.md +501 -0
  65. package/core/commands/qc-run-test.md +549 -0
  66. package/core/commands/refine-prd.md +43 -8
  67. package/core/commands/report-bug.md +59 -10
  68. package/core/commands/review-code.md +43 -8
  69. package/core/commands/review-context.md +43 -8
  70. package/core/commands/review-tech-docs.md +43 -8
  71. package/core/commands/setup-ai-first.md +7 -0
  72. package/core/commands/sync.md +19 -9
  73. package/core/commands/update-framework.md +7 -0
  74. package/core/commands/validate-traces.md +67 -12
  75. package/core/modules/qc-playwright/stack-profile.yaml +65 -0
  76. package/core/skills/code/SKILL.md +50 -8
  77. package/core/skills/debug/SKILL.md +57 -8
  78. package/core/skills/design-spec/SKILL.md +43 -8
  79. package/core/skills/discovery/SKILL.md +43 -8
  80. package/core/skills/prd/SKILL.md +14 -0
  81. package/core/skills/qc/qa-analyst/DOC_GAPS.template.md +63 -0
  82. package/core/skills/qc/qa-analyst/acceptance-criteria.md +60 -0
  83. package/core/skills/qc/qa-analyst/business-rules.md +59 -0
  84. package/core/skills/qc/qa-analyst/data-flow.md +64 -0
  85. package/core/skills/qc/qa-analyst/spec-breakdown.md +61 -0
  86. package/core/skills/qc/qa-designer/e2e/journey.md +41 -0
  87. package/core/skills/qc/qa-designer/exploratory/charter.md +68 -0
  88. package/core/skills/qc/qa-designer/exploratory/explore-to-functional.md +43 -0
  89. package/core/skills/qc/qa-designer/functional/api.md +45 -0
  90. package/core/skills/qc/qa-designer/functional/gui-feature.md +46 -0
  91. package/core/skills/qc/qa-designer/functional/gui-screen.md +52 -0
  92. package/core/skills/qc/qa-designer/integration/api.md +42 -0
  93. package/core/skills/qc/qa-designer/integration/db.md +39 -0
  94. package/core/skills/qc/qa-designer/integration/gui.md +40 -0
  95. package/core/skills/qc/qa-designer/integration/kafka.md +40 -0
  96. package/core/skills/qc/qa-designer/non-functional.md +40 -0
  97. package/core/skills/qc/qa-planner/test-plan.md +120 -0
  98. package/core/skills/qc/qa-reviewer/script/e2e.md +87 -0
  99. package/core/skills/qc/qa-reviewer/script/exploratory.md +45 -0
  100. package/core/skills/qc/qa-reviewer/script/functional.md +101 -0
  101. package/core/skills/qc/qa-reviewer/script/integration.md +91 -0
  102. package/core/skills/qc/qa-reviewer/script/non-functional.md +126 -0
  103. package/core/skills/qc/qa-reviewer/test-case/e2e.md +73 -0
  104. package/core/skills/qc/qa-reviewer/test-case/exploratory.md +43 -0
  105. package/core/skills/qc/qa-reviewer/test-case/functional.md +76 -0
  106. package/core/skills/qc/qa-reviewer/test-case/integration.md +69 -0
  107. package/core/skills/qc/qa-reviewer/test-case/non-functional.md +73 -0
  108. package/core/skills/qc/qa-runner/e2e.md +49 -0
  109. package/core/skills/qc/qa-runner/exploratory/session.md +36 -0
  110. package/core/skills/qc/qa-runner/functional/api.md +35 -0
  111. package/core/skills/qc/qa-runner/functional/gui-feature.md +51 -0
  112. package/core/skills/qc/qa-runner/functional/gui-screen.md +55 -0
  113. package/core/skills/qc/qa-runner/integration.md +47 -0
  114. package/core/skills/qc/qa-runner/non-functional.md +49 -0
  115. package/core/skills/qc/qa-runner/report/report.md +37 -0
  116. package/core/skills/setup-ai-first/SKILL.md +7 -0
  117. package/core/skills/spec/SKILL.md +14 -0
  118. package/core/skills/test/SKILL.md +93 -16
  119. package/core/steps/context-loader.md +36 -8
  120. package/core/steps/report-footer.md +7 -0
  121. package/core/templates/project-context.yaml +27 -1
  122. package/docs/01-getting-started/README.md +19 -0
  123. package/docs/01-getting-started/core-concepts.md +102 -0
  124. package/docs/01-getting-started/installation.md +156 -0
  125. package/docs/01-getting-started/quickstart.md +85 -0
  126. package/docs/02-guides/README.md +27 -0
  127. package/docs/02-guides/developer/README.md +46 -0
  128. package/docs/02-guides/developer/bdd-and-trace.md +123 -0
  129. package/docs/02-guides/developer/commands.md +76 -0
  130. package/docs/02-guides/developer/pr-checklist.md +15 -0
  131. package/docs/02-guides/developer/scenarios.md +448 -0
  132. package/docs/02-guides/developer/workflow.md +61 -0
  133. package/docs/02-guides/product-owner/README.md +77 -0
  134. package/docs/02-guides/product-owner/commands.md +30 -0
  135. package/docs/02-guides/product-owner/handoff-checklist.md +42 -0
  136. package/docs/02-guides/product-owner/prd-writing-rules.md +45 -0
  137. package/docs/02-guides/product-owner/scenarios.md +357 -0
  138. package/docs/02-guides/qc-automation.md +157 -0
  139. package/docs/02-guides/tester/README.md +74 -0
  140. package/docs/02-guides/tester/bug-reporting.md +117 -0
  141. package/docs/02-guides/tester/reading-specs.md +79 -0
  142. package/docs/02-guides/tester/scenarios.md +186 -0
  143. package/docs/02-guides/tester/spec-manifest.md +124 -0
  144. package/docs/02-guides/tester/test-checklist.md +31 -0
  145. package/docs/02-guides/tester/workflow.md +80 -0
  146. package/docs/03-concepts/README.md +19 -0
  147. package/docs/03-concepts/architecture.md +245 -0
  148. package/docs/03-concepts/pipeline.md +262 -0
  149. package/docs/03-concepts/traceability.md +149 -0
  150. package/docs/04-operations/README.md +33 -0
  151. package/docs/04-operations/bug-flow.md +362 -0
  152. package/docs/04-operations/publishing.md +137 -0
  153. package/docs/04-operations/sync-and-update.md +365 -0
  154. package/docs/05-reference/README.md +29 -0
  155. package/docs/05-reference/commands.md +229 -0
  156. package/docs/05-reference/modules.md +110 -0
  157. package/docs/05-reference/trace-schema.md +152 -0
  158. package/docs/README.md +51 -0
  159. package/modules/qc-playwright/stack-profile.yaml +65 -0
  160. package/package.json +2 -2
  161. package/skills/code/SKILL.md +50 -8
  162. package/skills/debug/SKILL.md +57 -8
  163. package/skills/design-spec/SKILL.md +43 -8
  164. package/skills/discovery/SKILL.md +43 -8
  165. package/skills/prd/SKILL.md +14 -0
  166. package/skills/qc/qa-analyst/DOC_GAPS.template.md +63 -0
  167. package/skills/qc/qa-analyst/acceptance-criteria.md +60 -0
  168. package/skills/qc/qa-analyst/business-rules.md +59 -0
  169. package/skills/qc/qa-analyst/data-flow.md +64 -0
  170. package/skills/qc/qa-analyst/spec-breakdown.md +61 -0
  171. package/skills/qc/qa-designer/e2e/journey.md +41 -0
  172. package/skills/qc/qa-designer/exploratory/charter.md +68 -0
  173. package/skills/qc/qa-designer/exploratory/explore-to-functional.md +43 -0
  174. package/skills/qc/qa-designer/functional/api.md +45 -0
  175. package/skills/qc/qa-designer/functional/gui-feature.md +46 -0
  176. package/skills/qc/qa-designer/functional/gui-screen.md +52 -0
  177. package/skills/qc/qa-designer/integration/api.md +42 -0
  178. package/skills/qc/qa-designer/integration/db.md +39 -0
  179. package/skills/qc/qa-designer/integration/gui.md +40 -0
  180. package/skills/qc/qa-designer/integration/kafka.md +40 -0
  181. package/skills/qc/qa-designer/non-functional.md +40 -0
  182. package/skills/qc/qa-planner/test-plan.md +120 -0
  183. package/skills/qc/qa-reviewer/script/e2e.md +87 -0
  184. package/skills/qc/qa-reviewer/script/exploratory.md +45 -0
  185. package/skills/qc/qa-reviewer/script/functional.md +101 -0
  186. package/skills/qc/qa-reviewer/script/integration.md +91 -0
  187. package/skills/qc/qa-reviewer/script/non-functional.md +126 -0
  188. package/skills/qc/qa-reviewer/test-case/e2e.md +73 -0
  189. package/skills/qc/qa-reviewer/test-case/exploratory.md +43 -0
  190. package/skills/qc/qa-reviewer/test-case/functional.md +76 -0
  191. package/skills/qc/qa-reviewer/test-case/integration.md +69 -0
  192. package/skills/qc/qa-reviewer/test-case/non-functional.md +73 -0
  193. package/skills/qc/qa-runner/e2e.md +49 -0
  194. package/skills/qc/qa-runner/exploratory/session.md +36 -0
  195. package/skills/qc/qa-runner/functional/api.md +35 -0
  196. package/skills/qc/qa-runner/functional/gui-feature.md +51 -0
  197. package/skills/qc/qa-runner/functional/gui-screen.md +55 -0
  198. package/skills/qc/qa-runner/integration.md +47 -0
  199. package/skills/qc/qa-runner/non-functional.md +49 -0
  200. package/skills/qc/qa-runner/report/report.md +37 -0
  201. package/skills/setup-ai-first/SKILL.md +7 -0
  202. package/skills/spec/SKILL.md +14 -0
  203. package/skills/test/SKILL.md +93 -16
  204. package/steps/context-loader.md +36 -8
  205. package/steps/report-footer.md +7 -0
  206. package/templates/project-context.yaml +27 -1
  207. package/ARCHITECTURE.md +0 -258
@@ -0,0 +1,262 @@
1
+ [📚 Docs](../README.md) › [Concepts](README.md) › Pipeline
2
+
3
+ # Pipeline
4
+
5
+ Vòng đời feature đi qua các phase, mỗi transition có một **AI review gate**:
6
+ **Discovery → PRD → Design-Spec → BDD → Tech-Docs → Code → Dev self-check → QC automation → Tester feedback.** Phần sau mô tả từng phase và **step-architecture model** đằng sau mỗi command.
7
+
8
+ ## Mục lục
9
+
10
+ - [Phase overview](#phase-overview)
11
+ - [Workflow chi tiết](#workflow-chi-tiết)
12
+ - [QC automation pipeline (Phase 5b)](#qc-automation-pipeline-phase-5b)
13
+ - [Command internals — step architecture](#command-internals--step-architecture)
14
+ - [gate.md — universal entry](#gatemd--universal-entry)
15
+ - [context-loader.md — context loading sequence](#context-loadermd--context-loading-sequence)
16
+ - [spawn-agent.md — sub-agent orchestration](#spawn-agentmd--sub-agent-orchestration)
17
+ - [report-footer.md — standard output format](#report-footermd--standard-output-format)
18
+
19
+ ---
20
+
21
+ ## Phase overview
22
+
23
+ | Phase | Who | Commands | Output |
24
+ |-------|-----|----------|--------|
25
+ | **0. Setup** *(one-time)* | Tech Lead | `/setup-ai-first`, `/sync`, `/sync-figma-*` | Config files, submodules, component catalog |
26
+ | **1. Discovery** | PO + AI | `/define-product` | `specs/product-definition/{TICKET-ID}-{slug}.md` |
27
+ | **2. PRD** | AI → SA/PO review | `/generate-prd`, `/refine-prd`, `/review-context` | `specs/prd/{domain}/{TICKET-ID}-{slug}.md` |
28
+ | **2b. Design Spec** *(FE/App only)* | AI → Designer/PO sign-off | `/generate-design-spec` | `specs/design-spec/{domain}/{TICKET-ID}-design-spec-{platform}.md` |
29
+ | **3. BDD Spec** | AI → SA/Dev review | `/generate-bdd`, `/review-context` | `specs/bdd/{domain}/{UC-ID}.feature` |
30
+ | **4. Tech Design** | AI → SA/Lead review | `/generate-tech-docs`, `/review-tech-docs` | `tech-docs/{domain}/{UC-ID}-tech-design.md` |
31
+ | **5. Code** | AI → Dev review | `/generate-code` *(FE: `--phase=ui`/`--phase=integration`)*, `/review-code` | `src/...` |
32
+ | **6. Dev Self-Check** | Dev (own code) | `/dev-gen-test`, `/dev-run-test`, `/dev-smoke-test` | `src/test/...` — dev smoke (`dev_selftest`), tách khỏi QC suite |
33
+ | **6b. QC Automation** *(official QC suite)* | QC | `/qc-analyze` → `/qc-plan` → `/qc-design-test` → `/qc-review` → `/qc-run-test` → `/qc-report` | QC test designs + run results — set `qc_status` (`qc-playwright` module) |
34
+ | **7. Trace** | Tech Lead | `/validate-traces` | Coverage matrix + drift report |
35
+ | **8. Tester Feedback** | QA → PO/Dev | `/report-bug`, `/propose-scenario` → `/sync` surfaces | `{spec}/feedback/...` → bug fix / new scenario / PRD update |
36
+ | **Cross-cutting** | Any role | `/sync`, `/learn`, `/update-framework` | Synced repo · project guardrails · upgraded tooling |
37
+
38
+ > **PRD là platform-agnostic (Option C):** Một PRD phục vụ mọi platform — chỉ mô tả business outcome, không UI/API. FE/App: PRD → Design Spec (2b) → BDD. BE: PRD → BDD (skip 2b). Thêm platform sau không cần đổi PRD.
39
+
40
+ ---
41
+
42
+ ## Workflow chi tiết
43
+
44
+ ```
45
+ Phase 1: Discovery
46
+ /define-product ──────────→ specs/product-definition/{slug}.md
47
+ (7 phase Q&A: knowledge sync → feature def → user flow → clarify →
48
+ business rules → business logic → AC → validation matrix)
49
+
50
+ Phase 2: PRD
51
+ /generate-prd ────────────→ specs/prd/{domain}/{slug}.md
52
+ /refine-prd ──────────────→ .agent/review/{prd-slug}-findings.yaml
53
+ [Review Board: Accept/Modify/Reject]
54
+ /refine-prd --resume → apply + bump version
55
+ /review-context {prd} ────→ .agent/review/{prd-slug}-review-context-findings.yaml
56
+ --fix (auto-fixable) | Review Board → --resume (apply + bump)
57
+ Checks: banned terms (P1) · ambiguity AC/BR (P2) · conflicts (P3) · completeness (P4)
58
+ ✅ APPROVED → Phase 3 · ❌ NEEDS_FIX → fix + re-run
59
+
60
+ Phase 2b/3: Design Spec & BDD
61
+ /generate-design-spec ────→ specs/design-spec/{domain}/{TICKET-ID}-design-spec-{platform}.md
62
+ (FE/App only — PO supplies node-level Figma link ?node-id= per screen;
63
+ AI fetches each frame via Figma MCP. Screen with no readable link → ❌ Missing;
64
+ sign-off + /generate-bdd blocked tới khi mọi screen có link)
65
+ [Designer review + PO sign-off]
66
+ /generate-bdd ────────────→ specs/bdd/{domain}/{UC-ID}.feature
67
+ (apply platform vocabulary: web "clicks" / mobile "taps" / backend "submits a request")
68
+ /review-context {feature} → .agent/review/{uc-id}-review-bdd-findings.yaml
69
+ Checks: PRD coverage (mỗi AC + BR bullet → ≥1 scenario) · Gherkin R1–R10 · compliance C1–C5
70
+ ✅ APPROVED → Phase 4
71
+
72
+ Phase 4: Tech Design
73
+ /generate-tech-docs ──────→ tech-docs/{domain}/{UC-ID}-tech-design.md
74
+ (đọc @trace.module → chọn template theo platform; brownfield: reverse-document mode)
75
+ /review-tech-docs ────────→ .agent/review/{uc-id}-tech-review-findings.yaml
76
+ [Review Board] → --resume (apply + bump revision)
77
+ ✅ APPROVED → Phase 5
78
+
79
+ Phase 5: Code
80
+ /generate-code ───────────→ src/... (@trace.implements tags)
81
+ FE: --phase=ui (UI + mock adapter, tester-ready) → --phase=integration (real API after sign-off)
82
+ (component enforcement: ✅ existing / ⚠️ TODO blocked / ❌ NEW confirm)
83
+ /review-code ─────────────→ Report: Critical / Major / Minor → fix CRITICAL/MAJOR
84
+
85
+ Phase 5 (cont): Dev Self-Check (dev verifies their OWN code — NOT the official QC suite)
86
+ /dev-gen-test ────────────→ src/test/... (@trace.verifies tags)
87
+ /dev-run-test ────────────→ records dev_selftest (pass/fail/not_run) + dev_selftest_at in trace
88
+ /dev-smoke-test ──────────→ live endpoint check (optional)
89
+ /validate-traces {domain} → coverage matrix + drift detection
90
+
91
+ Phase 5b: QC Automation (the OFFICIAL QC suite — see below)
92
+
93
+ Phase 6: Tester / QC Feedback (QA/QC → PO/Dev, closes the loop)
94
+ /report-bug {UC-ID} ──────→ {spec}/feedback/bug-reports/{BUG-ID}.md (State: Open) → push
95
+ /propose-scenario {UC-ID} → behavior ∈ AC → {spec}/feedback/bdd-proposals/{...}.md → push
96
+ behavior MỚI → {spec}/feedback/prd-change-requests/{...}.md → push
97
+ QC nguồn: /qc-run-test FAIL & /qc-analyze DOC_GAPS cũng route vào đây
98
+ PO/Dev: /sync → "📥 State: Open" → /fix-bug {BUG-ID} (Open→Fixed) · add BDD · update PRD
99
+ QC: /qc-run-test re-verify pass → bug Closed (qc_owner/qc_blocked_by clear)
100
+
101
+ Cross-cutting (any role, anytime)
102
+ /sync ────────────────────→ git pull + submodules + Living Docs + surface feedback
103
+ /learn "AI does X, should Y" → project guardrail (loaded vào mọi command)
104
+ /update-framework ────────→ upgrade framework tooling từ npm
105
+ ```
106
+
107
+ > **Large PRD (> 3 UC hoặc > 300 dòng):** `/generate-bdd`, `/generate-code`, `/dev-gen-test` tự chuyển sang **orchestration mode** — spawn 1 sub-agent/UC (xem [spawn-agent.md](#spawn-agentmd--sub-agent-orchestration)).
108
+
109
+ > **Phase 7 — `/validate-traces` statuses:** ✅ OK (code version khớp spec) · ⚠️ DRIFT (code gen từ PRD/BDD cũ → re-generate) · 🔴 GAP (scenario có trong spec nhưng không có code) · — UNTRACKED (scenario ghi nhận nhưng chưa code-gen). Chi tiết: [traceability.md](traceability.md).
110
+
111
+ ---
112
+
113
+ ## QC automation pipeline (Phase 5b)
114
+
115
+ Bộ test QC **chính thức** — native pipeline, chạy như một **branch sau khi BDD được approve** (`/review-context` (BDD) APPROVED), song song / sau khi dev `/generate-code`. 6 stage tuần tự, port từ agent của team QC (QC repo nay chỉ còn reference):
116
+
117
+ ```
118
+ BDD approved (specs/bdd/*.feature)
119
+
120
+ /qc-analyze → /qc-plan → /qc-design-test → /qc-review → /qc-run-test → /qc-report
121
+ (đọc UC/SC, phân tích) chạy test → set qc_status
122
+ ▼ ▼
123
+ QC analysis + test cases .trace/*.tsv: qc_status
124
+ → {qc_dir}/{UC-ID}/ (visible, mặc định docs/) (pass/fail/skip/not_run)
125
+ REQUIREMENT_ANALYSIS.md · DOC_GAPS.md · + qc_owner / qc_blocked_by
126
+ TEST_PLAN.md · test-cases/*.Test.md (skills load từ {qc_skills_dir})
127
+
128
+ ── Feedback loop về spec (đóng vòng) ───────────────────────────────────
129
+ /qc-analyze DOC_GAPS blocker (spec sai/mơ hồ) ┐
130
+ /qc-run-test FAIL = product-gap ├─▶ /report-bug · /propose-scenario
131
+ /qc-report tổng hợp gap → in sẵn lệnh ┘ │ (cùng flow tester)
132
+
133
+ feedback/ trong spec repo (State: Open)
134
+ → commit+push → PO/Dev thấy qua /sync (xem bug-flow.md)
135
+
136
+ Mapping: mỗi QC test → scenario qua @trace.verifies={UC-ID}-SC{N}
137
+ ```
138
+
139
+ - **Implementation module:** `qc-playwright` (Python + pytest-playwright + Page Object; Playwright Trace + pytest-html, KHÔNG dùng Allure). ĐỘC LẬP với dev implementation module — dùng bởi `/qc-run-test` & `/qc-report`.
140
+ - **Khác biệt với dev self-check:** dev self-check (`/dev-*`) → `dev_selftest` (smoke, dev tự kiểm); QC automation (`/qc-*`) → `qc_status` (coverage QC chính thức). Hai tín hiệu **orthogonal**, cả hai surface trong Living Docs → xem [traceability.md](traceability.md).
141
+
142
+ ---
143
+
144
+ ## Command internals — step architecture
145
+
146
+ Mỗi command trong `.agent/commands/` được compose từ các **step file** dùng chung trong `.agent/steps/`. Đây là nền tảng — mọi command gọi chúng theo thứ tự trước khi chạy logic riêng.
147
+
148
+ | File | Role | Called by |
149
+ |------|------|-----------|
150
+ | `gate.md` | Universal entry — model check, file resolution, context load, user checkpoint | Mọi command |
151
+ | `context-loader.md` | Multi-step context loading (stack → service routing → conventions → arch → safety → domain → UI → recap) | `gate.md` Step 2 |
152
+ | `spawn-agent.md` | Sub-agent orchestration cho PRD lớn | `generate-bdd`, `generate-code`, `dev-gen-test` |
153
+ | `capture-lesson.md` | Append/refine guardrail trong project lessons file | `learn`, `review-code`, `fix-bug`, `debug` |
154
+ | `report-footer.md` | Standard output format (status badge, artifact list, next command) | Mọi command |
155
+
156
+ ### gate.md — universal entry
157
+
158
+ Mọi command bắt đầu ở đây, theo thứ tự:
159
+
160
+ | Step | What it does |
161
+ |------|-------------|
162
+ | **Step 0** | Sub-agent mode check — nếu `$ARGUMENTS` là JSON payload với `_agent_mode: true`, skip Step 1–3, dùng slim context trực tiếp |
163
+ | **Step 0-B** | Model check — prompt switch sang `claude-opus` cho generation phức tạp; `S` để skip |
164
+ | **Step 1** | Resolve target file từ `$ARGUMENTS`; nếu thiếu, liệt kê candidate và hỏi user chọn |
165
+ | **Step 2** | Execute `context-loader.md` — load toàn bộ project context vào working memory |
166
+ | **Step 3** | CHECKPOINT — hiển thị summary (target file, stack, module, domains), chờ `Y` |
167
+
168
+ ```
169
+ CHECKPOINT
170
+ -----------
171
+ Target : specs/prd/auth/FEAT-042-login.md
172
+ Project : My App
173
+ Tech stack : TypeScript / React 18
174
+ Module : react
175
+ Domains : auth, profile
176
+
177
+ Proceed? (Y/N)
178
+ ```
179
+
180
+ ### context-loader.md — context loading sequence
181
+
182
+ Load toàn bộ project context vào working memory theo thứ tự ưu tiên nghiêm ngặt:
183
+
184
+ | Step | Priority | What loads |
185
+ |------|----------|-----------|
186
+ | 1 | PROJECT-CONFIG | `project-context.yaml` → stack, conventions, domains, services, paths |
187
+ | 1.5 | SERVICE ROUTING | *(umbrella only)* detect active domain, route `specs_dir`/`tech_docs_dir` tới service submodule, store `service_root` |
188
+ | 1.6 | SERVICE CONVENTIONS | *(umbrella only)* load `{service_root}/.agent/project-context.yaml` → override `test_command`, `build_command`, `paths.trace_dir` |
189
+ | 2 | PROJECT-CONFIG | `.agent/modules/{module}/stack-profile.yaml` → layer patterns |
190
+ | 3 | **CRITICAL** | `CLAUDE.md` → architecture layers, coding standards, naming |
191
+ | 4 | SAFETY | `.agent/rules/data-protection.md` → sensitive file patterns |
192
+ | 5 | DOMAIN | `business-dictionary.md` → canonical + banned terms |
193
+ | 6 | DOMAIN | `core-entities.md` → entity catalog |
194
+ | 6.7 | **GUARDRAILS** | `lessons_file` → mistakes tích lũy (via `/learn`) loaded như hard constraints |
195
+ | 6-B | UI COMPONENTS | `figma-components/{module}.md` → Figma name → code component + import path |
196
+ | 6-C | UI TOKENS | `figma-tokens.md` → design tokens |
197
+ | 7 | **RECAP** | `[CTX LOADED]` block — lock critical facts vào working memory |
198
+
199
+ **Anti-lost-in-middle:** critical facts (Step 3) load đầu tiên; RECAP (Step 7) restate ở cuối để fresh khi generation bắt đầu (recency effect).
200
+
201
+ ```
202
+ [CTX LOADED]
203
+ Stack : TypeScript / React 18 / PostgreSQL
204
+ Layers : Controller → Facade → Service → Repository
205
+ Services : 2 services: web-admin(react), api-backend(java-spring)
206
+ Svc Root : api-backend — conventions + trace_dir loaded from service config
207
+ Dict : loaded — 42 canonical terms, 8 banned terms
208
+ Entities : loaded — User, Order, Product
209
+ Lessons : loaded — 6 guardrails
210
+ Components : loaded — web-admin (react) — 23 components mapped
211
+ Tokens : loaded — colors: 18, spacing: 12, typography: 6
212
+ Status : FULL
213
+ ```
214
+
215
+ Status values: `FULL` · `PARTIAL — missing: {list}` · `MINIMAL` (chỉ project-context.yaml).
216
+
217
+ ### spawn-agent.md — sub-agent orchestration
218
+
219
+ Khi PRD vượt ngưỡng phức tạp, `generate-bdd`, `generate-code`, `dev-gen-test` tự chuyển từ single-session sang orchestration mode.
220
+
221
+ **Complexity thresholds:**
222
+
223
+ | Signal | Threshold | Action |
224
+ |--------|-----------|--------|
225
+ | UC count trong PRD | > 3 UC | Spawn 1 sub-agent / UC |
226
+ | PRD length | > 300 dòng | Spawn agents bất kể UC count |
227
+
228
+ **Orchestration flow:**
229
+
230
+ ```
231
+ Main session (orchestrator)
232
+ ├─ Step A: Build slim context JSON (stack + active_service + active_module + paths + arch summary + banned_terms)
233
+ ├─ Step B: Scan PRD → extract UC list [{uc_id, line_start, line_end}]
234
+ ├─ Step C: Announce plan → "Spawning N sub-agents..."
235
+ ├─ Step D: Spawn 1 sub-agent / UC (parallel)
236
+ │ mỗi agent nhận: { _agent_mode: true, uc_id, target_file, uc_section, context }
237
+ │ mỗi agent đọc CHỈ UC section của mình (không phải full PRD)
238
+ └─ Step E: Collect results → merge → { uc_id, files_created, status, errors }
239
+ ```
240
+
241
+ **Tiết kiệm context window:**
242
+
243
+ | Mode | What loads per agent |
244
+ |------|---------------------|
245
+ | Single session (≤ 3 UC) | Full context + full PRD + all UCs |
246
+ | Orchestrator | Slim context + UC heading list only |
247
+ | Each sub-agent | Slim context + **1 UC section only** |
248
+
249
+ ### report-footer.md — standard output format
250
+
251
+ Mọi command kết thúc với footer này:
252
+
253
+ ```
254
+ ---
255
+ Status : ✅ Complete
256
+ Output Artifacts:
257
+ created specs/bdd/auth/FEAT-042-UC1-login.feature (3 scenarios)
258
+ updated .trace/FEAT-042.tsv
259
+ Next : /review-context specs/bdd/auth/FEAT-042-UC1-login.feature
260
+ ```
261
+
262
+ **Status badges:** `✅ Complete` · `⚠️ Warnings` · `❌ Failed`. Field **Next** luôn gợi ý command tiếp theo hợp lý — không phải tra cứu.
@@ -0,0 +1,149 @@
1
+ [📚 Docs](../README.md) › [Concepts](README.md) › Traceability
2
+
3
+ # Traceability & Living Docs
4
+
5
+ Mỗi artifact link tới mọi artifact khác qua `@trace.*` tags, và trạng thái coverage/drift được tổng hợp vào **trace TSV** rồi surface trong **Living Docs**. Đây là cách framework đảm bảo *mọi dòng code trace về một scenario*, và phân biệt hai tín hiệu test độc lập: **`dev_selftest`** (dev tự kiểm) vs **`qc_status`** (QC chính thức).
6
+
7
+ ## Mục lục
8
+
9
+ - [Artifact chain & @trace tags](#artifact-chain--trace-tags)
10
+ - [Trace TSV — coverage & drift](#trace-tsv--coverage--drift)
11
+ - [Hai tín hiệu test: dev_selftest vs qc_status](#hai-tín-hiệu-test-dev_selftest-vs-qc_status)
12
+ - [Living Docs — canonical trong spec-module + panel mirror](#living-docs--canonical-trong-spec-module--panel-mirror)
13
+ - [/validate-traces](#validate-traces)
14
+
15
+ > Schema TSV đầy đủ (mọi cột) và full danh sách trace tag: xem [../05-reference/trace-schema.md](../05-reference/trace-schema.md). Trang này tập trung vào **khái niệm** và cách hai tín hiệu hoạt động.
16
+
17
+ ---
18
+
19
+ ## Artifact chain & @trace tags
20
+
21
+ Mỗi artifact mang `@trace.*` metadata liên kết về artifact trước nó:
22
+
23
+ ```
24
+ product-definition.md
25
+ └─► PRD.md (Service, Module trong metadata; @trace.domain, @trace.status)
26
+ └─► {UC-ID}.feature (@trace.service, @trace.module, @trace.prd_version)
27
+ └─► tech-design.md (@trace.bdd_version)
28
+ └─► src/ code (@trace.implements, @trace.prd_version, @trace.bdd_version)
29
+ └─► src/test/ (@trace.verifies, @trace.service)
30
+ └─► .trace/{UC-ID}.tsv (drift tracking)
31
+ ```
32
+
33
+ **Các trace field quan trọng:**
34
+
35
+ | Field | Vị trí | Ý nghĩa |
36
+ |-------|--------|---------|
37
+ | `@trace.domain` | PRD frontmatter | Domain của feature (auth, payment, …) — route vào đúng service submodule |
38
+ | `@trace.status` | PRD frontmatter | `draft` / `approved` — dev team chỉ code khi `approved` |
39
+ | `@trace.service` / `@trace.module` | BDD / Tech Doc header | Service + module sẽ implement |
40
+ | `@trace.prd_version` / `@trace.bdd_version` | BDD / code / test | Version của spec mà artifact được sinh từ — base cho drift detection |
41
+ | `@trace.implements` | Code comment | Scenario mà code này implement: `={UC-ID}-SC{N}` |
42
+ | `@trace.verifies` | Test / QC test | Scenario mà test này verify: `={UC-ID}` hoặc `={UC-ID}-SC{N}` |
43
+ | `@trace.api_source: existing` | BDD header | Brownfield — API đã tồn tại, contract lấy từ PRD |
44
+
45
+ Ví dụ tags trong `.feature`, code, và test:
46
+
47
+ ```gherkin
48
+ # @trace.id: FEAT-001-UC1
49
+ # @trace.service: web-admin
50
+ # @trace.module: react
51
+ # @trace.prd_version: 1.2
52
+ # @trace.bdd_version: 3
53
+ ```
54
+ ```java
55
+ // @trace.implements=FEAT-001-UC1-SC2 // @trace.verifies=FEAT-001-UC1
56
+ // @trace.prd_version=1.2 // @trace.service=api-backend
57
+ // @trace.bdd_version=3 // @trace.test_type=integration
58
+ // @trace.tech_doc_revision=2
59
+ ```
60
+
61
+ ---
62
+
63
+ ## Trace TSV — coverage & drift
64
+
65
+ `.trace/{UC-ID}.tsv` là nguồn sự thật per-scenario về trạng thái implement/test. Được **ghi** bởi `/generate-bdd`, `/generate-code`, `/dev-gen-test`, `/qc-run-test`, và **update** bởi `/validate-traces`. File `.trace/*.tsv` authoritative **được commit** trong chính service submodule (không phải mirror).
66
+
67
+ Status coverage per scenario:
68
+
69
+ | Status | Meaning |
70
+ |--------|---------|
71
+ | ✅ OK | Code version khớp spec version |
72
+ | ⚠️ DRIFT | Code gen từ PRD/BDD cũ hơn — re-generate |
73
+ | 🔴 GAP | Scenario có trong spec nhưng không tìm thấy code implement |
74
+ | — UNTRACKED | Scenario ghi nhận nhưng chưa code-gen |
75
+
76
+ ---
77
+
78
+ ## Hai tín hiệu test: dev_selftest vs qc_status
79
+
80
+ Trace TSV mang **hai cột độc lập**, cả hai **orthogonal** với cột `status` (coverage) ở trên:
81
+
82
+ | Cột | Set bởi | Giá trị | Ý nghĩa |
83
+ |-----|---------|---------|---------|
84
+ | `dev_selftest` (+ `dev_selftest_at`) | `/dev-run-test` | `pass` / `fail` / `not_run` | **Dev self-check** — dev tự chạy bộ self-check test của mình trên scenario đó. **KHÔNG** phải coverage QC chính thức. |
85
+ | `qc_status` (+ `qc_run_at`) | `/qc-run-test` | `pass` / `fail` / `skip` / `not_run` | **QC chính thức** — kết quả native QC pipeline (do QC chạy, không phải dev), keyed theo `@trace.verifies={UC-ID}-SC{N}`. |
86
+
87
+ - **`dev_selftest`** là tín hiệu để QC **thấy** rằng developer đã smoke/self-check qua scenario đó. `dev_selftest: pass` chỉ nghĩa "dev đã tự kiểm" — không phải tuyên bố coverage.
88
+ - **`qc_status`** là coverage QC chính thức từ pipeline `/qc-analyze → … → /qc-run-test → /qc-report` (xem [pipeline.md](pipeline.md#qc-automation-pipeline-phase-5b)). `/qc-run-test` dùng stack module `qc-playwright`, độc lập với dev implementation module.
89
+ - Hai tín hiệu **sit side by side** trong Living Docs để dễ phân biệt hai luồng. Tester vẫn nên verify độc lập theo BDD + PRD ở phần chưa được automation cover.
90
+
91
+ > Phân biệt rõ: `/dev-*` (dev self-check, `dev_selftest`) ≠ `/qc-*` (official QC suite, `qc_status`). Đừng coi output của `/dev-*` là coverage chính thức.
92
+
93
+ ---
94
+
95
+ ## Living Docs — canonical trong spec-module + panel mirror
96
+
97
+ Living Docs (VS Code panel) đọc trace TSV và hiển thị traceability health toàn dự án:
98
+
99
+ ```
100
+ ┌──────────────────────────────────────────────────────────────────┐
101
+ │ PRDs Use Cases Scenarios Code Cov. Test Cov. Drift Gap │
102
+ │ 19 86 1077 93% 89% 212 93 │
103
+ └──────────────────────────────────────────────────────────────────┘
104
+ ```
105
+
106
+ - Drill down: PRD → UC → per-scenario table (Spec ver, Gen ver, Code, Tests, **Dev Self-Check**, **QC Status**, **Waiting on**, Status)
107
+ - **Waiting on** (cột `qc_owner` + `qc_blocked_by`): cho PO/PM thấy case chưa pass đang **chờ dev** (product-gap → `BUG-{id}`) hay **chờ PO** confirm/clarify (spec gap → `GAP-{id}`). Aggregates `waiting_dev` / `waiting_po` ở header dashboard.
108
+ - Status badges: ✅ OK · ⚠️ DRIFT · 🔴 GAP · — UNTRACKED · filter theo domain/PRD status/doc status · search theo UC/SC ID.
109
+
110
+ **Ba nơi chứa trace data — phân biệt authoritative vs mirror:**
111
+
112
+ | Vị trí | Vai trò | Commit? |
113
+ |--------|---------|---------|
114
+ | `{service}/.trace/*.tsv` | **Authoritative** — nguồn sự thật per-service | ✅ Committed trong service submodule |
115
+ | `{spec_source}/.living-docs/` (`trace-report.json` + TSV mirror namespaced) | **Canonical report** — tổng hợp cross-team, regenerate bởi `/sync` hoặc `/validate-traces` | ❌ Gitignored |
116
+ | `./.trace` của workspace hiện tại | **Panel mirror** — giữ Living Docs panel không trống kể cả khi mở Claude Code/VS Code bên trong một service submodule đơn lẻ | ❌ Gitignored |
117
+
118
+ **Vì sao canonical nằm ở spec module?** Spec module được mount vào mọi umbrella/service workspace, nên nó là nơi chung luôn resolve được cho cross-team dashboard. Vấn đề trước đây: panel mở ở umbrella root (hoặc một service submodule đơn lẻ) sẽ TRỐNG nếu không có mirror — vì TSV authoritative nằm rải rác trong từng service submodule. Panel mirror `./.trace` giải quyết case mở single service.
119
+
120
+ Thêm vào `.gitignore` (cả hai là mirror read-only, không commit):
121
+ ```
122
+ # spec module
123
+ .living-docs/
124
+ # workspace / umbrella root (mirror)
125
+ .trace/
126
+ ```
127
+
128
+ > **Prerequisite cho data chính xác:** mỗi service submodule cần `.agent/project-context.yaml` với `paths.trace_dir` configure đúng. Thiếu → framework không biết ghi trace TSV về đâu → panel thiếu data.
129
+
130
+ ---
131
+
132
+ ## /validate-traces
133
+
134
+ Chạy `/validate-traces {domain}` bất cứ lúc nào (đặc biệt **sau mỗi codegen session trong umbrella mode**) để:
135
+
136
+ ```
137
+ /validate-traces {domain}
138
+ → Reads .trace/*.tsv authoritative (committed) trong từng service:
139
+ user-service/.trace/, order-service/.trace/, ...
140
+ → Writes canonical trace-report.json + TSV mirror → {spec_source}/.living-docs/ (gitignored)
141
+ → Writes panel mirror → ./.trace của workspace hiện tại (non-empty khi mở single service)
142
+ → Living Docs panel cập nhật ngay
143
+ ```
144
+
145
+ Báo cáo: scenario nào chưa có code (GAP) · code nào gen từ PRD/BDD cũ (DRIFT) · broken links / orphan BDD (không có PRD) / dead code traces · coverage % per domain.
146
+
147
+ **Khi nào chạy:** sau refactor đổi tên file/function · sau khi PO cập nhật PRD (version mới) · trước PR lớn · khi CI báo trace validation fail · sau mỗi codegen session (umbrella).
148
+
149
+ > **Nguyên tắc:** không merge code khi traces broken — fix traces trước. `/sync` cũng regenerate Living Docs như một bước phụ; `/validate-traces` là lệnh chuyên trách kiểm tra trace chain.
@@ -0,0 +1,33 @@
1
+ [📚 Docs](../README.md) › Operations
2
+
3
+ # 04 · Operations
4
+
5
+ > Vận hành hằng ngày với framework: đồng bộ nội dung & nâng cấp framework, quy trình xử lý bug, và publish package lên npm.
6
+
7
+ Mục này dành cho cả team (PO · Dev · Tester · QC) và người maintain framework.
8
+
9
+ ---
10
+
11
+ ## Trong mục này
12
+
13
+ | Trang | Nội dung |
14
+ |-------|----------|
15
+ | [Sync & Update](sync-and-update.md) | `/sync` vs `/update-framework`, umbrella mode, đồng bộ Living Docs, workflow hằng ngày theo role |
16
+ | [Bug Flow](bug-flow.md) | Phân loại bug theo spec layer (Code/BDD/PRD/Design/Env), 6 case, format thông báo, checklist đóng bug |
17
+ | [Publishing](publishing.md) | Build + publish `@anhth2/spec-driven-dev-plugin` lên npm, versioning, transfer ownership |
18
+
19
+ ---
20
+
21
+ ## Hai loại "update" — đừng nhầm
22
+
23
+ | | `/sync` | `/update-framework` |
24
+ |---|---|---|
25
+ | Update cái gì | Nội dung dự án: code/specs trong submodule + Living Docs | Bản thân framework: commands, steps, modules |
26
+ | Nguồn | Git remote của submodule | npm registry |
27
+ | Tần suất | Mỗi sáng / trước khi work | Khi có version framework mới (hiếm) |
28
+
29
+ Chi tiết: [Sync & Update](sync-and-update.md).
30
+
31
+ ---
32
+
33
+ *Xem thêm:* [02 · Guides](../02-guides/) (theo vai trò) · [03 · Concepts](../03-concepts/) (kiến trúc) · [05 · Reference](../05-reference/) (tra cứu lệnh).