@edupia-tutor/spec-driven-docs 0.14.0 → 0.14.2

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 (162) hide show
  1. package/bin/index.js +12 -1
  2. package/commands/debug.md +436 -436
  3. package/commands/debug.tmpl +111 -111
  4. package/commands/define-product.md +350 -345
  5. package/commands/define-product.tmpl +69 -64
  6. package/commands/dev-gen-test.md +365 -365
  7. package/commands/dev-gen-test.tmpl +63 -63
  8. package/commands/dev-run-test.md +376 -376
  9. package/commands/dev-run-test.tmpl +74 -74
  10. package/commands/dev-smoke-test.md +341 -341
  11. package/commands/dev-smoke-test.tmpl +60 -60
  12. package/commands/fix-bug.md +403 -403
  13. package/commands/fix-bug.tmpl +78 -78
  14. package/commands/generate-bdd.md +513 -513
  15. package/commands/generate-bdd.tmpl +211 -211
  16. package/commands/generate-code.md +481 -483
  17. package/commands/generate-code.tmpl +179 -181
  18. package/commands/generate-design-spec.md +497 -497
  19. package/commands/generate-design-spec.tmpl +220 -220
  20. package/commands/generate-prd.md +452 -400
  21. package/commands/generate-prd.tmpl +50 -200
  22. package/commands/generate-spec-manifest.md +340 -340
  23. package/commands/generate-spec-manifest.tmpl +59 -59
  24. package/commands/generate-tech-docs.md +365 -365
  25. package/commands/generate-tech-docs.tmpl +84 -84
  26. package/commands/learn.md +347 -347
  27. package/commands/learn.tmpl +22 -22
  28. package/commands/map-testids.md +322 -322
  29. package/commands/map-testids.tmpl +41 -41
  30. package/commands/propose-scenario.md +335 -335
  31. package/commands/propose-scenario.tmpl +54 -54
  32. package/commands/qc-analyze.md +323 -324
  33. package/commands/qc-analyze.tmpl +42 -43
  34. package/commands/qc-design-test.md +304 -304
  35. package/commands/qc-design-test.tmpl +23 -23
  36. package/commands/qc-plan.md +297 -297
  37. package/commands/qc-plan.tmpl +16 -16
  38. package/commands/qc-report.md +302 -302
  39. package/commands/qc-report.tmpl +21 -21
  40. package/commands/qc-review.md +298 -298
  41. package/commands/qc-review.tmpl +17 -17
  42. package/commands/qc-run-test.md +337 -337
  43. package/commands/qc-run-test.tmpl +35 -35
  44. package/commands/refine-prd.md +428 -430
  45. package/commands/refine-prd.tmpl +62 -62
  46. package/commands/report-bug.md +351 -351
  47. package/commands/report-bug.tmpl +70 -70
  48. package/commands/review-code.md +364 -364
  49. package/commands/review-code.tmpl +39 -39
  50. package/commands/review-context.md +578 -580
  51. package/commands/review-context.tmpl +212 -212
  52. package/commands/review-tech-docs.md +427 -427
  53. package/commands/review-tech-docs.tmpl +146 -146
  54. package/commands/setup-ai-first.md +239 -239
  55. package/commands/setup-ai-first.tmpl +133 -133
  56. package/commands/sync.md +145 -145
  57. package/commands/sync.tmpl +93 -93
  58. package/commands/update-framework.md +88 -88
  59. package/commands/update-framework.tmpl +36 -36
  60. package/commands/validate-traces.md +381 -381
  61. package/commands/validate-traces.tmpl +100 -100
  62. package/core/FRAMEWORK_VERSION +1 -1
  63. package/core/commands/debug.md +436 -436
  64. package/core/commands/define-product.md +350 -345
  65. package/core/commands/dev-gen-test.md +365 -365
  66. package/core/commands/dev-run-test.md +376 -376
  67. package/core/commands/dev-smoke-test.md +341 -341
  68. package/core/commands/fix-bug.md +403 -403
  69. package/core/commands/generate-bdd.md +513 -513
  70. package/core/commands/generate-code.md +481 -483
  71. package/core/commands/generate-design-spec.md +497 -497
  72. package/core/commands/generate-prd.md +452 -400
  73. package/core/commands/generate-spec-manifest.md +340 -340
  74. package/core/commands/generate-tech-docs.md +365 -365
  75. package/core/commands/learn.md +347 -347
  76. package/core/commands/map-testids.md +322 -322
  77. package/core/commands/propose-scenario.md +335 -335
  78. package/core/commands/qc-analyze.md +323 -324
  79. package/core/commands/qc-design-test.md +304 -304
  80. package/core/commands/qc-plan.md +297 -297
  81. package/core/commands/qc-report.md +302 -302
  82. package/core/commands/qc-review.md +298 -298
  83. package/core/commands/qc-run-test.md +337 -337
  84. package/core/commands/refine-prd.md +428 -430
  85. package/core/commands/report-bug.md +351 -351
  86. package/core/commands/review-code.md +364 -364
  87. package/core/commands/review-context.md +578 -580
  88. package/core/commands/review-tech-docs.md +427 -427
  89. package/core/commands/setup-ai-first.md +239 -239
  90. package/core/commands/sync.md +145 -145
  91. package/core/commands/update-framework.md +88 -88
  92. package/core/commands/validate-traces.md +381 -381
  93. package/core/skills/code/SKILL.md +389 -389
  94. package/core/skills/debug/SKILL.md +391 -391
  95. package/core/skills/design-spec/SKILL.md +318 -318
  96. package/core/skills/discovery/SKILL.md +7 -547
  97. package/core/skills/prd/SKILL.md +298 -394
  98. package/core/skills/setup-ai-first/SKILL.md +80 -80
  99. package/core/skills/spec/SKILL.md +178 -178
  100. package/core/skills/test/SKILL.md +604 -604
  101. package/core/steps/capture-lesson.md +44 -44
  102. package/core/steps/context-loader.md +175 -175
  103. package/core/steps/gate.md +54 -54
  104. package/core/steps/report-footer.md +52 -52
  105. package/core/steps/review-fanout.md +85 -87
  106. package/core/steps/spawn-agent.md +45 -45
  107. package/core/steps/trace-mirror.md +21 -21
  108. package/core/templates/architecture.template.md +37 -37
  109. package/core/templates/design-spec.template.md +77 -77
  110. package/core/templates/platform-guide.template.md +47 -47
  111. package/core/templates/prd.template.md +107 -232
  112. package/core/templates/product-definition.template.md +101 -88
  113. package/core/templates/project-context.yaml +2 -2
  114. package/docs/01-getting-started/core-concepts.md +1 -1
  115. package/docs/01-getting-started/quickstart.md +7 -7
  116. package/docs/02-guides/developer/bdd-and-trace.md +1 -1
  117. package/docs/02-guides/developer/scenarios.md +5 -5
  118. package/docs/02-guides/product-owner/handoff-checklist.md +1 -1
  119. package/docs/02-guides/product-owner/scenarios.md +23 -23
  120. package/docs/02-guides/tester/bug-reporting.md +2 -2
  121. package/docs/02-guides/tester/reading-specs.md +2 -2
  122. package/docs/02-guides/tester/scenarios.md +1 -1
  123. package/docs/02-guides/tester/spec-manifest.md +3 -3
  124. package/docs/02-guides/tester/workflow.md +1 -1
  125. package/docs/03-concepts/architecture.md +3 -3
  126. package/docs/03-concepts/pipeline.md +3 -3
  127. package/docs/04-operations/publishing.md +20 -3
  128. package/docs/04-operations/sync-and-update.md +5 -5
  129. package/docs/05-reference/command-cheatsheet.md +2 -2
  130. package/docs/05-reference/commands.md +8 -8
  131. package/package.json +1 -1
  132. package/scripts/migrate-specs.js +5 -3
  133. package/scripts/rename-prd-files.js +174 -0
  134. package/skills/code/SKILL.md +389 -389
  135. package/skills/code/SKILL.tmpl +56 -56
  136. package/skills/debug/SKILL.md +391 -391
  137. package/skills/debug/SKILL.tmpl +60 -60
  138. package/skills/design-spec/SKILL.md +318 -318
  139. package/skills/design-spec/SKILL.tmpl +37 -37
  140. package/skills/discovery/SKILL.md +7 -547
  141. package/skills/discovery/SKILL.tmpl +7 -140
  142. package/skills/prd/SKILL.md +298 -394
  143. package/skills/prd/SKILL.tmpl +40 -151
  144. package/skills/setup-ai-first/SKILL.md +80 -80
  145. package/skills/setup-ai-first/SKILL.tmpl +28 -28
  146. package/skills/spec/SKILL.md +178 -178
  147. package/skills/spec/SKILL.tmpl +20 -20
  148. package/skills/test/SKILL.md +604 -604
  149. package/skills/test/SKILL.tmpl +44 -44
  150. package/steps/capture-lesson.md +44 -44
  151. package/steps/context-loader.md +175 -175
  152. package/steps/gate.md +54 -54
  153. package/steps/report-footer.md +52 -52
  154. package/steps/review-fanout.md +85 -87
  155. package/steps/spawn-agent.md +45 -45
  156. package/steps/trace-mirror.md +21 -21
  157. package/templates/architecture.template.md +37 -37
  158. package/templates/design-spec.template.md +77 -77
  159. package/templates/platform-guide.template.md +47 -47
  160. package/templates/prd.template.md +107 -232
  161. package/templates/product-definition.template.md +101 -88
  162. package/templates/project-context.yaml +2 -2
@@ -1,496 +1,387 @@
1
1
  ---
2
- description: Generates a PRD from a product definition, or analyzes an existing PRD through 4 review lenses (QA, DEV, SA, PO) to find gaps and risks. Trigger when: "/generate-prd", "/refine-prd", "tạo PRD", "generate PRD", "phân tích PRD", "review PRD", "refine PRD", "PRD có vấn đề gì không", "check PRD quality".
2
+ description: Sinh PRD từ một product definition, hoặc phân tích một PRD sẵn qua 4 lăng kính review (QA, DEV, SA, PO) để tìm gap rủi ro. Trigger when: "/generate-prd", "/refine-prd", "tạo PRD", "generate PRD", "phân tích PRD", "review PRD", "refine PRD", "PRD có vấn đề gì không", "check PRD quality".
3
3
  ---
4
4
 
5
5
  # PRD Skills — Generate & Refine
6
6
 
7
- This skill handles two commands: `/generate-prd` to create a PRD, and `/refine-prd` to analyze it for gaps.
7
+ Skill này xử hai lệnh: `/generate-prd` để tạo PRD, `/refine-prd` để phân tích PRD tìm gap.
8
8
 
9
9
  ---
10
10
 
11
- ## /generate-prd — Generate Product Requirements Document
11
+ ## /generate-prd — Sinh Product Requirements Document
12
12
 
13
13
  ### Gate
14
14
 
15
- <!-- Directory: specs/product-definition/**/*.md -->
16
- # Gate — Universal Entry Procedure
15
+ <!-- Directory: {paths.product_definitions_dir}/**/*.md -->
16
+ # Gate — Quy trình vào chuẩn cho mọi lệnh
17
17
 
18
- Every command must execute this gate before proceeding with its specific logic.
18
+ Mọi lệnh PHẢI chạy gate này trước khi thực thi phần logic riêng của nó.
19
19
 
20
- ## Step 0 — Sub-Agent Mode Check
20
+ ## Bước 0 — Kiểm tra chế độ Sub-Agent
21
21
 
22
- Before anything else, check if `$ARGUMENTS` is a JSON payload from an orchestrator:
22
+ Trước tiên, kiểm tra xem `$ARGUMENTS` phải payload JSON từ một orchestrator hay không:
23
23
 
24
- 1. Attempt to parse `$ARGUMENTS` as JSON.
25
- 2. If it parses successfully **and** contains `"_agent_mode": true`:
26
- - **Skip Steps 1, 2, and 3 of this Gate entirely.**
27
- - Set target file = `payload.target_file`
28
- - Set loaded context = `payload.context` (do NOT run context-loader.md)
29
- - Set UC scope = `payload.uc_id` (process only this UC)
30
- - Set line range = `payload.uc_section` (read only that PRD section)
31
- - Proceed directly to the command-specific logic.
32
- 3. If `$ARGUMENTS` is not JSON or `_agent_mode` is absent continue to Step 1 (normal mode).
24
+ 1. Thử parse `$ARGUMENTS` dưới dạng JSON.
25
+ 2. Nếu parse thành công **và** chứa `"_agent_mode": true`:
26
+ - **Bỏ qua hoàn toàn Bước 1, 2 3 của Gate này.**
27
+ - Đặt target file = `payload.target_file`
28
+ - Đặt loaded context = `payload.context` (KHÔNG chạy context-loader.md)
29
+ - Đặt phạm vi UC = `payload.uc_id` (chỉ xử UC này)
30
+ - Đặt line range = `payload.uc_section` (chỉ đọc đúng section đó của PRD)
31
+ - Đi thẳng tới phần logic riêng của lệnh.
32
+ 3. Nếu `$ARGUMENTS` không phải JSON hoặc không có `_agent_mode` tiếp tục sang Bước 1 (chế độ thường).
33
33
 
34
- ## Step 0-B — Model Check
34
+ ## Bước 0-B — Kiểm tra Model
35
35
 
36
- *Skip this step if `_agent_mode: true` (sub-agent — orchestrator already validated).*
36
+ *Bỏ qua bước này nếu `_agent_mode: true` (sub-agent — orchestrator đã kiểm tra rồi).*
37
37
 
38
- Complex generation and review commands require strong reasoning.
39
- Using a smaller model risks missed edge cases, incomplete spec analysis, and architecture violations.
38
+ Các lệnh sinh nội dung và review phức tạp đòi hỏi khả năng suy luận mạnh.
39
+ Dùng model nhỏ hơn sẽ rủi ro: bỏ sót edge case, phân tích spec thiếu sót, vi phạm kiến trúc.
40
40
 
41
- Display and wait for response:
41
+ Hiển thị chờ phản hồi:
42
42
 
43
43
  ```
44
44
  ⚙️ MODEL CHECK
45
45
  ──────────────────────────────────────────────────────────────────
46
- Recommended : claude-opus-4 (or latest Opus model)
47
- Why needed : Spec analysis, architecture review, code generation
48
- require deep reasoning. Smaller models miss edge cases.
46
+ Recommended : claude-opus-4 (hoặc model Opus mới nhất)
47
+ Why needed : Phân tích spec, review kiến trúc, sinh code đòi hỏi
48
+ suy luận sâu. Model nhỏ hơn dễ bỏ sót edge case.
49
49
 
50
- To switch in Claude Code:
51
- • Settings → Model → select "claude-opus"
52
- or: /model → choose claude-opus
50
+ Cách đổi trong Claude Code:
51
+ • Settings → Model → chọn "claude-opus"
52
+ hoặc: /model → chọn claude-opus
53
53
 
54
- Running on claude-opus?
55
- Y — yes, on claude-opus → proceed
56
- S — skip check (I accept lower quality risk with current model)
54
+ Đang chạy claude-opus?
55
+ Y — đúng, đang dùng claude-opus → tiếp tục
56
+ S — bỏ qua kiểm tra (tôi chấp nhận rủi ro chất lượng thấp hơn với model hiện tại)
57
57
  ──────────────────────────────────────────────────────────────────
58
58
  ```
59
59
 
60
- - "Y" → proceed to Step 1.
61
- - "S" → proceed to Step 1 (user accepts risk, add ⚠️ to final report).
62
- - "N" or anything else → **STOP.** Output: "Please switch to claude-opus, then re-run this command."
60
+ - "Y" → tiếp tục sang Bước 1.
61
+ - "S" → tiếp tục sang Bước 1 (người dùng chấp nhận rủi ro, thêm ⚠️ vào report cuối).
62
+ - "N" hoặc bất kỳ giá trị nào khác → **DỪNG.** Xuất: "Vui lòng chuyển sang claude-opus rồi chạy lại lệnh này."
63
63
 
64
- ## Step 1 — Resolve Target File
64
+ ## Bước 1 — Xác định Target File
65
65
 
66
- 1. If `$ARGUMENTS` is provided and points to an existing file → use it directly as the target.
67
- 2. If `$ARGUMENTS` is a **bare UC-ID / ticket ID / partial name** (no path) → resolve it to a file by globbing the feature-package layout. The `{prd-slug}` is **not known yet**, so use a `*` wildcard for that segment, and a recursive `**` under `bdd/` so the platform subfolders (`bdd/web/`, `bdd/app/`, `bdd/system/`) are all covered:
68
- - **BDD commands** (target is a `.feature`): `{specs_dir}/{domain}/*/bdd/**/{UC-ID}*.feature` — or `{specs_dir}/*/*/bdd/**/{UC-ID}*.feature` if the domain is also unknown. If a platform/scope is implied by the command (e.g. a system tech-doc needs the `system/` BDD), prefer the match under that platform subfolder.
69
- - **PRD commands** (target is `prd.md`): `{specs_dir}/{domain}/*/prd.md` (match the feature folder whose id corresponds), else `{specs_dir}/*/*/prd.md`.
70
- - **tech-docs commands**: `{specs_dir}/{domain}/*/tech-docs/{UC-ID}*-tech-design*.md`.
71
- - **design-spec commands**: `{specs_dir}/{domain}/*/design-spec/{TICKET-ID}*.md`.
66
+ 1. Nếu `$ARGUMENTS` được cung cấp trỏ tới một file tồn tại dùng trực tiếp làm target.
67
+ 2. Nếu `$ARGUMENTS` một **UC-ID / ticket ID / tên rút gọn** (không path) → phân giải thành file bằng cách glob theo bố cục feature-package. `{prd-slug}` lúc này **chưa biết**, nên dùng wildcard `*` cho segment đó, `**` đệ quy dưới `bdd/` để phủ hết các thư mục con theo platform (`bdd/web/`, `bdd/app/`, `bdd/system/`):
68
+ - **Lệnh BDD** (target `.feature`): `{specs_dir}/{domain}/*/bdd/**/{UC-ID}*.feature` — hoặc `{specs_dir}/*/*/bdd/**/{UC-ID}*.feature` nếu domain cũng chưa biết. Nếu lệnh ngụ ý một platform/scope cụ thể (vd: system tech-doc cần BDD `system/`), ưu tiên kết quả trong thư mục con platform đó.
69
+ - **Lệnh PRD** (target file PRD `{TICKET-ID}-{prd-slug}.md` — file `.md` duy nhất ở gốc feature folder, cạnh `bdd/`): `{specs_dir}/{domain}/*/{TICKET-ID}*.md` nếu biết TICKET-ID; nếu không, `{specs_dir}/{domain}/*/*.md` (khớp feature folder id tương ứng), hoặc `{specs_dir}/*/*/*.md` nếu domain cũng chưa biết. *(Glob `*/*.md` ở cấp gốc folder chỉ khớp PRD — tech-docs/design-spec `.md` nằm sâu hơn trong thư mục con.)*
70
+ - **Lệnh tech-docs**: `{specs_dir}/{domain}/*/tech-docs/{UC-ID}*-tech-design*.md`.
71
+ - **Lệnh design-spec**: `{specs_dir}/{domain}/*/design-spec/{TICKET-ID}*.md`.
72
72
 
73
- Once a file matches: set it as the target **and** record `domain` + `prd_slug` from its path (per the extraction rule in `context-loader.md` Step 1 — `prd_slug` = first segment after `{specs_dir}/{domain}/`). Every path the command later reads or writes (sibling BDD/tech-docs/design-spec/trace) uses **that resolved `prd_slug`**, so all artifacts stay in one feature package. If several files match (e.g. multiple platforms), pick per the command's platform/scope or list them and ask.
74
- 3. If `$ARGUMENTS` is empty or no match found:
75
- - List files in the relevant directory for this command (e.g., `specs/*/*/prd.md` for PRD commands, `specs/*/*/bdd/**/*.feature` for BDD commands).
76
- - Present the list to the user and ask: "Which file do you want to work with? (Enter number or filename)"
77
- - Wait for user selection before continuing.
73
+ Khi một file khớp: đặt làm target **và** ghi lại `domain` + `prd_slug` từ path của nó (theo quy tắc trích xuất trong `context-loader.md` Bước 1 — `prd_slug` = segment đầu tiên sau `{specs_dir}/{domain}/`). Mọi path lệnh đọc/ghi về sau (BDD/tech-docs/design-spec/trace cùng cấp) đều dùng **`prd_slug` đã phân giải đó**, nên tất cả artifact nằm chung một feature package. Nếu nhiều file khớp (vd: nhiều platform), chọn theo platform/scope của lệnh hoặc liệt kê ra và hỏi.
74
+ 3. Nếu `$ARGUMENTS` rỗng hoặc không tìm thấy file khớp:
75
+ - Liệt các file trong thư mục liên quan của lệnh này (vd: `specs/*/*/*.md` file PRD ở gốc mỗi feature folder — cho lệnh PRD, `specs/*/*/bdd/**/*.feature` cho lệnh BDD).
76
+ - Hiển thị danh sách cho người dùng và hỏi: "Bạn muốn làm việc với file nào? (Nhập số thứ tự hoặc tên file)"
77
+ - Chờ người dùng chọn rồi mới tiếp tục.
78
78
 
79
- ## Step 2 — Execute Context Loader
79
+ ## Bước 2 — Chạy Context Loader
80
80
 
81
- Load all project context by following the procedure in `steps/context-loader.md`.
82
- Store all loaded context in memory for use throughout this command session.
81
+ Nạp toàn bộ context của dự án bằng cách làm theo quy trình trong `steps/context-loader.md`.
82
+ Lưu toàn bộ context đã nạp vào bộ nhớ để dùng xuyên suốt phiên làm việc của lệnh.
83
83
 
84
- ## Step 3 — CHECKPOINT
84
+ ## Bước 3 — CHECKPOINT
85
85
 
86
- After completing Steps 1 and 2, display a summary and wait for confirmation:
86
+ Sau khi hoàn thành Bước 1 2, hiển thị bản tóm tắt chờ xác nhận:
87
87
 
88
88
  ```
89
89
  CHECKPOINT
90
90
  -----------
91
91
  Target : {resolved file path}
92
- Project : {project.name from project-context.yaml}
92
+ Project : {project.name từ project-context.yaml}
93
93
  Tech stack : {language} / {framework}
94
- Module : {module if set, else "not configured"}
95
- Domains : {comma-separated domain list}
94
+ Module : {module nếu có, else "not configured"}
95
+ Domains : {danh sách domain, ngăn cách bởi dấu phẩy}
96
96
 
97
- Proceed? (Y/N)
97
+ Tiếp tục? (Y/N)
98
98
  ```
99
99
 
100
- Wait for explicit "Y" or "N" from the user before continuing.
101
- - "Y" → proceed to the command-specific steps below.
102
- - "N" → stop and ask what the user wants to change.
100
+ Chờ người dùng trả lời rõ ràng "Y" hoặc "N" rồi mới tiếp tục.
101
+ - "Y" → tiếp tục sang các bước riêng của lệnh bên dưới.
102
+ - "N" → dừng lại hỏi người dùng muốn thay đổi gì.
103
103
 
104
104
 
105
- ### Generate
105
+ ### Quy tắc nội dung — chống jargon kỹ thuật *(áp dụng cho mọi PRD sinh ra)*
106
106
 
107
- Write `specs/{domain}/{prd-slug}/prd.md`:
107
+ **1. PRD platform-agnostic — chỉ mô tả WHAT (nghiệp vụ), KHÔNG mô tả HOW (kỹ thuật).**
108
+ Viết AC / Business Rule / Business Logic theo *kết quả nghiệp vụ*, KHÔNG nhét chi tiết triển khai (API, JWT/token, endpoint, HTTP status, tên class/bảng/cột DB, query, spinner, animation…). Những thứ đó thuộc **Tech Docs** (kỹ thuật) hoặc **Design Spec** (giao diện).
108
109
 
109
- ```markdown
110
- # PRD — {Feature Name}
110
+ | ✅ Viết trong PRD (nghiệp vụ) | ❌ KHÔNG viết trong PRD |
111
+ |---|---|
112
+ | "Đăng nhập thành công → truy cập được tính năng" | "API trả về JWT token" ← Tech Docs |
113
+ | "Sai mật khẩu 5 lần → khoá tài khoản 30 phút" | "Click button → hiện toast" ← Design Spec |
114
+ | "Phiên hết hạn → yêu cầu xác thực lại" | "Hiển thị spinner khi loading" ← Design Spec |
111
115
 
112
- **Version**: 1.0
113
- **Status**: draft
114
- **Domain**: {domain}
115
- **Ticket**: {TICKET_PREFIX}-{N} (if available)
116
- **Date**: {date}
116
+ - Nếu PO đưa chi tiết UI (màu, layout, animation) → **nhắc**: *"Chi tiết UI này thuộc Design Spec, không thuộc PRD. Ghi nhận để tạo Design Spec sau."*
117
+ - Enum/thuật ngữ kỹ thuật ĐÃ chuẩn hoá trong domain-knowledge (vd `userType`, `TYPE_1`) thì giữ nguyên gốc — đây là từ vựng nghiệp vụ, KHÔNG phải jargon triển khai.
117
118
 
118
- ## 1. Problem Statement
119
- {from product-definition}
119
+ **2. Terminology — bám từ điển dự án.**
120
+ - Thay mọi **banned term** bằng canonical term (xem `business-dictionary.md` § Banned Terms); ghi chú việc thay ở mục **Giả định AI**.
121
+ - Status/Enum → lấy đúng giá trị trong `core-entities.md` (Enum Registry).
122
+ - **Thuật ngữ MỚI**: nếu input PO có từ chưa có trong `business-dictionary.md` và lặp ≥2 lần → **DỪNG, hỏi PO** (nghĩa là gì / canonical term / có thêm vào từ điển không) trước khi tiếp tục.
120
123
 
121
- ## 2. Goals & Non-Goals
124
+ **3. Cross-reference bắt buộc.** Mọi chỗ nhắc TICKET-ID khác → inline link `[TICKET-ID](./file.md)` nếu file PRD tồn tại; không để plain text.
122
125
 
123
- ### Goals
124
- - {goal 1}
126
+ ### Generate
125
127
 
126
- ### Non-Goals
127
- - {non-goal 1}
128
+ Sinh PRD theo đúng cấu trúc chuẩn dưới đây (template canonical: `templates/prd.template.md`). Quy ước bắt buộc:
129
+
130
+ - **Ngôn ngữ:** heading + nội dung viết tiếng Việt (giữ thuật ngữ kỹ thuật/Enum nguyên gốc).
131
+ - **Tiêu đề file:** `# {TICKET}-{N} {Feature Name}` — KHÔNG thêm tiền tố "PRD —".
132
+ - **Tên file ghi ra:** `specs/{domain}/{prd-slug}/{TICKET}-{prd-slug}.md` (vd `SEG01-segment-scoring-service.md` — KHÔNG đặt tên `prd.md`; bố cục feature-package — mọi artifact của feature nằm chung folder này, PRD là file `.md` duy nhất ở gốc folder).
133
+ - **Business Rule:** đặt BÊN TRONG từng Use Case (không gom thành mục phẳng), bảng 3 cột `ID | Business Rule | Business Logic`; ID theo dạng `{TICKET}-{N}-UC{n}-BR{m}` (đánh số BR liên tục xuyên suốt các UC, không reset mỗi UC).
134
+ - **Acceptance Criteria:** danh sách phẳng `**AC{n}:**`, văn xuôi — KHÔNG ép Given/When/Then.
135
+ - **Liên kết:** trỏ tới PRD/tài liệu liên quan bằng link tương đối; trỏ `core-entities` / `business-dictionary` ở mục Tài liệu tham khảo.
136
+ - **Giả định AI:** nếu phát hiện độ vênh/giả định chưa được PO chốt → liệt kê thành `Q1…Qn` để PO xác nhận; nếu mọi thứ đã rõ từ product-definition → ghi "Không có — toàn bộ nội dung đã được PO xác nhận".
137
+
138
+ Template (cấu trúc đầu ra — single-source từ `templates/prd.template.md`):
139
+
140
+ ````markdown
141
+ # {TICKET}-{N} {Feature Name}
142
+
143
+ <!--
144
+ Template này được sử dụng bởi workflow /generate-prd.
145
+ AI Agent sẽ điền các section dựa trên input từ PO.
146
+ Các placeholder {…} cần được thay thế bằng nội dung thực tế.
147
+
148
+ FORMAT CHUẨN: Business Rule = bảng 3 cột
149
+ ID | Business Rule | Business Logic (KHÔNG tách Business Logic ra khối riêng).
150
+
151
+ TERMINOLOGY:
152
+ - Tuân thủ 100% từ điển project: specs/domain-knowledge/business-dictionary.md
153
+ (KHÔNG dùng từ điển của project khác). Thay banned term bằng canonical term;
154
+ nếu phát hiện banned term trong input PO → thay + ghi chú trong "Giả định AI".
155
+ - Status/Enum values → tham chiếu core-entities.md (Enum Registry).
156
+
157
+ CROSS-REFERENCE (BẮT BUỘC): Bất kỳ chỗ nào nhắc đến một tính năng/ticket khác
158
+ (pre-condition, business rule, giả định, AC, hay bất kỳ section nào) → PHẢI gắn inline link:
159
+ [TICKET-ID khác](../{prd-slug-khác}/{TICKET-ID-khác}-{prd-slug-khác}.md)
160
+ Không để TICKET-ID dạng plain text nếu tồn tại file PRD tương ứng. (Mỗi PRD nằm trong feature-package riêng nên link trỏ sang folder anh em `../{prd-slug-khác}/`.)
161
+ Ngoài ra, ghi rõ quan hệ phụ thuộc trong "Tài liệu tham khảo" ở Appendix.
162
+
163
+ NEW TERM DETECTION: Nếu input PO xuất hiện thuật ngữ CHƯA CÓ trong business-dictionary.md
164
+ và lặp lại ≥ 2 lần → DỪNG lại, hỏi PO confirm trước khi tiếp tục:
165
+ + Thuật ngữ đó nghĩa gì trong ngữ cảnh hệ thống?
166
+ + English term chuẩn nên dùng là gì?
167
+ + Có cần bổ sung vào business-dictionary.md không?
168
+ Sau khi PO confirm → cập nhật business-dictionary.md (nếu PO đồng ý) rồi mới tiếp tục.
169
+
170
+ NUMBERING:
171
+ - UC ID: {TICKET}-{N}-UC{n} (n bắt đầu từ 1, tăng theo từng use case)
172
+ - BR ID: {TICKET}-{N}-UC{n}-BR{m} (m tăng LIÊN TỤC xuyên suốt PRD, KHÔNG reset mỗi UC)
173
+ -->
128
174
 
129
- ## 3. User Stories
175
+ ---
130
176
 
131
- As a {persona}, I want to {action} so that {benefit}.
177
+ ## Metadata
132
178
 
133
- ## 4. Use Cases
179
+ | Field | Value |
180
+ |---------------|------------------------------------------|
181
+ | **PRD ID** | {TICKET}-{N} |
182
+ | **Version** | 1.0 |
183
+ | **Status** | draft |
184
+ | **Author** | AI-assisted |
185
+ | **Domain** | {domain} |
186
+ | **Created** | {date} |
187
+ | **Updated** | {date} |
188
+ | **Jira Ticket** | [{TICKET}-{N}]({ticket_url}) |
189
+ | **API Source** | *(để trống nếu greenfield — chỉ điền `existing` khi PRD bọc một API đã chạy production)* |
134
190
 
135
- | UC-ID | Name | Priority | Description |
136
- |-------|------|----------|-------------|
137
- | {DOMAIN}-UC1 | {name} | High | {description} |
191
+ ---
138
192
 
139
- ## 5. Business Rules
193
+ # Feature
140
194
 
141
- | BR-ID | Rule | UC |
142
- |-------|------|----|
143
- | BR-1 | {rule} | UC1 |
195
+ **{Feature Name}**
144
196
 
145
- ## 6. Acceptance Criteria
197
+ {Đoạn tả tổng quan: feature làm gì, cho ai, giải quyết vấn đề gì — lấy từ product-definition.}
146
198
 
147
- ### {DOMAIN}-UC1: {Name}
148
- - AC1: Given {context}, when {action}, then {result}
199
+ ---
149
200
 
150
- ## 7. Out of Scope
151
- {from product-definition}
201
+ # 1. Tổng quan
152
202
 
153
- ## 8. Cross-Service Dependencies
154
- {from product-definition}
203
+ ## a. User Story
155
204
 
156
- ## 9. Open Questions
157
- - [ ] {question requiring clarification}
158
- ```
205
+ - **Là một (As a)** {persona}
206
+ - **Tôi muốn (I want to)** {action}
207
+ - **Để (So that)** {benefit}
159
208
 
160
- ### Output
209
+ ## b. Phạm vi
161
210
 
162
- ```
163
- PRD created: specs/{domain}/{prd-slug}/prd.md
164
- Status: draft
165
- ```
211
+ **In Scope**
212
+ - {hạng mục trong phạm vi 1}
213
+ - {hạng mục trong phạm vi 2}
166
214
 
167
- # Report Footer Standard Command Output Format
215
+ **Out of Scope** *(chỉ thêm khi ranh giới cần nói rõ)*
216
+ - {hạng mục ngoài phạm vi + lý do / chủ sở hữu}
168
217
 
169
- Every command report must end with this standard footer section.
218
+ ---
170
219
 
171
- ## Status Badge
220
+ # 2. Acceptance Criteria
172
221
 
173
- Choose one based on outcome:
174
- - `✅ Complete` — all steps succeeded, no issues found
175
- - `❌ Failed` — command could not complete due to a blocking error
176
- - `⚠️ Warnings` — completed with non-blocking issues that should be reviewed
222
+ **AC1:** {Tiêu chí nghiệm thu, văn xuôi, kiểm chứng được.}
177
223
 
178
- ## Output Artifacts
224
+ **AC2:** {…}
179
225
 
180
- List every file created or modified by this command:
181
- ```
182
- Output Artifacts:
183
- {created|updated} {file-path} ({brief description})
184
- {created|updated} {file-path} ({brief description})
185
- ```
226
+ ---
186
227
 
187
- If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
228
+ # 3. Use Case
188
229
 
189
- ## Pipeline Position
230
+ #### {TICKET}-{N}-UC1: {Tên use case}
190
231
 
191
- Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
192
- so the user always sees where this command sits in the end-to-end flow:
232
+ **Actor:** {actor}
193
233
 
194
- ```
195
- Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
196
- ```
234
+ **Description:** {mô tả luồng}
197
235
 
198
- Find the current command in this phase legend and mark **its** phase in the map above:
236
+ **Pre-condition:**
237
+ - {điều kiện trước 1}
199
238
 
200
- | Phase | Commands |
201
- |-------|----------|
202
- | Discovery | `/define-product` |
203
- | PRD | `/generate-prd` · `/refine-prd` · `/review-context` (PRD) |
204
- | Design Spec | `/generate-design-spec` |
205
- | BDD | `/generate-bdd` · `/review-context` (BDD) |
206
- | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
207
- | Code | `/generate-code` · `/review-code` |
208
- | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
209
- | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
210
- | Trace Audit | `/validate-traces` |
239
+ **Post-condition:**
240
+ - {kết quả sau 1}
211
241
 
212
- For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
213
- `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
242
+ **Business Rule**
214
243
 
215
- **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
216
- `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline —
217
- **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
244
+ | ID | Business Rule | Business Logic |
245
+ |----|---------------|----------------|
246
+ | {TICKET}-{N}-UC1-BR1 | {luật ngắn gọn} | - {logic chi tiết, xuống dòng bằng `<br/>`}<br/>- {…} |
247
+ | {TICKET}-{N}-UC1-BR2 | {…} | - {…} |
218
248
 
219
- ## Next Command Suggestion
249
+ ---
220
250
 
221
- Suggest the logical next command based on workflow phase:
251
+ #### {TICKET}-{N}-UC2: {Tên use case}
252
+
253
+ {lặp cấu trúc UC như trên; BR đánh số tiếp tục BR3, BR4…}
222
254
 
223
- | Current command | Suggest next |
224
- |-------------------------|-----------------------------------------------|
225
- | /setup-ai-first | `/define-product` to start your first feature |
226
- | /define-product | `/generate-prd {product-definition-file}` |
227
- | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
228
- | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
229
- | /review-context (PRD) | FE/App: `/generate-design-spec {prd-file}` (then BDD after sign-off); BE: `/generate-bdd {prd-file}` directly; fix PRD if NEEDS_FIX |
230
- | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
231
- | /generate-bdd | `/review-context {feature-file}` to verify coverage |
232
- | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
233
- | /qc-analyze | `/qc-plan {UC-ID}` (resolve 🔴 blocker gaps first) |
234
- | /qc-plan | `/qc-design-test {UC-ID}` |
235
- | /qc-design-test | `/qc-review {UC-ID}` (test-case review) |
236
- | /qc-review (test-case) | `/qc-run-test {UC-ID}` if APPROVED; fix TCs if NEEDS_FIX |
237
- | /qc-run-test | `/qc-report {UC-ID}` then `/qc-review {UC-ID}` (script review) |
238
- | /qc-review (script) | `/qc-report {UC-ID}` then create PR if APPROVED |
239
- | /qc-report | `/validate-traces {UC-ID}` to refresh Living Docs (qc_status) |
240
- | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
241
- | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
242
- | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/dev-gen-test {UC-ID}` |
243
- | /dev-gen-test | `/dev-run-test {UC-ID}` |
244
- | /dev-run-test (passing) | `/review-code {UC-ID}` |
245
- | /dev-run-test (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
246
- | /review-code | `/dev-smoke-test {UC-ID}` or create PR |
247
- | /dev-smoke-test | Create PR and link to ticket |
248
- | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/dev-gen-test {UC-ID}`; all OK → create PR |
249
- | /fix-bug | Create PR and link to ticket |
250
- | /debug | `/fix-bug {ticket-id}` if fix needed |
251
- | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
252
- | /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
253
- | /learn | Continue working — lesson applies on next command |
254
- | /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
255
- | /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
256
-
257
- Format the footer as:
258
- ```
259
255
  ---
260
- Status : {badge}
261
- {Output Artifacts block}
262
- Pipeline : Discovery → PRD → [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
263
- (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
264
- Next : {suggested command with example arguments}
265
- ```
266
- *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
267
256
 
257
+ # 4. UI/UX Guidelines
268
258
 
269
- ---
259
+ ## a. User Flow
270
260
 
271
- ## /refine-prd — Analyze PRD Through 4 Review Lenses
261
+ ```mermaid
262
+ flowchart TD
263
+ START(["{điểm bắt đầu}"]) --> A{"{điểm quyết định}"}
264
+ A -->|{nhánh}| B["{bước}"]
265
+ ```
272
266
 
273
- Performs a structured multi-perspective analysis of a PRD and writes findings to a YAML file for human review.
267
+ ## b. Wireframe
274
268
 
275
- ### Gate
269
+ ### Screen 1: {Tên màn}
276
270
 
277
- <!-- Directory: specs/*/*/prd.md -->
278
- # Gate — Universal Entry Procedure
271
+ | Thành phần | Chi tiết |
272
+ |------------|----------|
273
+ | **Screen** | {tên/ngữ cảnh màn} |
274
+ | **Components** | - {thành phần 1}<br/>- {thành phần 2} |
275
+ | **Actions** | - {hành động 1 → kết quả}<br/>- {hành động 2 → kết quả} |
279
276
 
280
- Every command must execute this gate before proceeding with its specific logic.
277
+ ---
281
278
 
282
- ## Step 0 Sub-Agent Mode Check
279
+ ### Screen 2: {Tên màn}
283
280
 
284
- Before anything else, check if `$ARGUMENTS` is a JSON payload from an orchestrator:
281
+ {lặp bảng như trên cho từng màn}
285
282
 
286
- 1. Attempt to parse `$ARGUMENTS` as JSON.
287
- 2. If it parses successfully **and** contains `"_agent_mode": true`:
288
- - **Skip Steps 1, 2, and 3 of this Gate entirely.**
289
- - Set target file = `payload.target_file`
290
- - Set loaded context = `payload.context` (do NOT run context-loader.md)
291
- - Set UC scope = `payload.uc_id` (process only this UC)
292
- - Set line range = `payload.uc_section` (read only that PRD section)
293
- - Proceed directly to the command-specific logic.
294
- 3. If `$ARGUMENTS` is not JSON or `_agent_mode` is absent → continue to Step 1 (normal mode).
283
+ ---
295
284
 
296
- ## Step 0-B — Model Check
285
+ # Appendix
297
286
 
298
- *Skip this step if `_agent_mode: true` (sub-agent — orchestrator already validated).*
287
+ ## Input gốc từ PO
299
288
 
300
- Complex generation and review commands require strong reasoning.
301
- Using a smaller model risks missed edge cases, incomplete spec analysis, and architecture violations.
289
+ > {Trích nguyên văn input/ghi chú gốc của PO + đường dẫn product-definition nguồn.}
302
290
 
303
- Display and wait for response:
291
+ ## Tài liệu tham khảo
304
292
 
305
- ```
306
- ⚙️ MODEL CHECK
307
- ──────────────────────────────────────────────────────────────────
308
- Recommended : claude-opus-4 (or latest Opus model)
309
- Why needed : Spec analysis, architecture review, code generation
310
- require deep reasoning. Smaller models miss edge cases.
293
+ - [{TICKET liên quan}](../{prd-slug-khác}/{TICKET-ID-khác}-{prd-slug-khác}.md) — {quan hệ: pre-condition / overlapping / related…}
294
+ - Từ điển nghiệp vụ: `{path}/business-dictionary.md`
295
+ - Domain knowledge: `{path}/{domain}.md`
311
296
 
312
- To switch in Claude Code:
313
- • Settings → Model → select "claude-opus"
314
- • or: /model → choose claude-opus
297
+ ## Existing API Contract *(CHỈ brownfield — điền khi API Source = existing; greenfield BỎ QUA cả section này)*
315
298
 
316
- Running on claude-opus?
317
- Y yes, on claude-opus proceed
318
- S skip check (I accept lower quality risk with current model)
319
- ──────────────────────────────────────────────────────────────────
320
- ```
299
+ <!--
300
+ Chỉ dùng khi PRD bọc một API đã tồn tại trên hệ thống. PO ghi lại contract để:
301
+ - /generate-bdd (system) dùng trực tiếp làm input không cần tổng hợp từ FE/App BDD;
302
+ - /generate-tech-docs chạy mode reverse-document (mô tả lại as-is, không design mới);
303
+ - /review-tech-docs bỏ qua cổng T7 cross-team sign-off (contract đã cố định).
304
+ Nếu greenfield (thiết kế mới) → xoá toàn bộ section này.
305
+ -->
321
306
 
322
- - "Y" proceed to Step 1.
323
- - "S" → proceed to Step 1 (user accepts risk, add ⚠️ to final report).
324
- - "N" or anything else **STOP.** Output: "Please switch to claude-opus, then re-run this command."
307
+ | Method | Path | Auth | Request | Response |
308
+ |--------|------|------|---------|----------|
309
+ | {GET/POST/PUT/DELETE} | {/api/v1/path} | {Bearer / none} | `{ field: type }` | `{ field: type }` |
325
310
 
326
- ## Step 1 — Resolve Target File
311
+ **Error responses:**
327
312
 
328
- 1. If `$ARGUMENTS` is provided and points to an existing file → use it directly as the target.
329
- 2. If `$ARGUMENTS` is a **bare UC-ID / ticket ID / partial name** (no path) → resolve it to a file by globbing the feature-package layout. The `{prd-slug}` is **not known yet**, so use a `*` wildcard for that segment, and a recursive `**` under `bdd/` so the platform subfolders (`bdd/web/`, `bdd/app/`, `bdd/system/`) are all covered:
330
- - **BDD commands** (target is a `.feature`): `{specs_dir}/{domain}/*/bdd/**/{UC-ID}*.feature` or `{specs_dir}/*/*/bdd/**/{UC-ID}*.feature` if the domain is also unknown. If a platform/scope is implied by the command (e.g. a system tech-doc needs the `system/` BDD), prefer the match under that platform subfolder.
331
- - **PRD commands** (target is `prd.md`): `{specs_dir}/{domain}/*/prd.md` (match the feature folder whose id corresponds), else `{specs_dir}/*/*/prd.md`.
332
- - **tech-docs commands**: `{specs_dir}/{domain}/*/tech-docs/{UC-ID}*-tech-design*.md`.
333
- - **design-spec commands**: `{specs_dir}/{domain}/*/design-spec/{TICKET-ID}*.md`.
313
+ | HTTP Status | Error Code | Khi nào xảy ra |
314
+ |-------------|------------|----------------|
315
+ | {4xx/5xx} | {ERR_CODE} | {condition} |
334
316
 
335
- Once a file matches: set it as the target **and** record `domain` + `prd_slug` from its path (per the extraction rule in `context-loader.md` Step 1 — `prd_slug` = first segment after `{specs_dir}/{domain}/`). Every path the command later reads or writes (sibling BDD/tech-docs/design-spec/trace) uses **that resolved `prd_slug`**, so all artifacts stay in one feature package. If several files match (e.g. multiple platforms), pick per the command's platform/scope or list them and ask.
336
- 3. If `$ARGUMENTS` is empty or no match found:
337
- - List files in the relevant directory for this command (e.g., `specs/*/*/prd.md` for PRD commands, `specs/*/*/bdd/**/*.feature` for BDD commands).
338
- - Present the list to the user and ask: "Which file do you want to work with? (Enter number or filename)"
339
- - Wait for user selection before continuing.
317
+ ## Giả định AI
340
318
 
341
- ## Step 2Execute Context Loader
319
+ > {Giả định / độ vênh AI phát hiện khi đối chiếu product-definition với domain-knowledge cần PO review. AI KHÔNG tự hoà giải.}
342
320
 
343
- Load all project context by following the procedure in `steps/context-loader.md`.
344
- Store all loaded context in memory for use throughout this command session.
321
+ - **Q1 [AI DRAFT] {tiêu đề}:** {mô tả độ vênh + nguồn}. **Cần PO chốt {điều gì}.**
345
322
 
346
- ## Step 3CHECKPOINT
323
+ _(Nếu không độ vênh: ghi "Không có toàn bộ nội dung đã được PO xác nhận qua Product Definition.")_
347
324
 
348
- After completing Steps 1 and 2, display a summary and wait for confirmation:
325
+ ---
349
326
 
350
- ```
351
- CHECKPOINT
352
- -----------
353
- Target : {resolved file path}
354
- Project : {project.name from project-context.yaml}
355
- Tech stack : {language} / {framework}
356
- Module : {module if set, else "not configured"}
357
- Domains : {comma-separated domain list}
327
+ # Change Log
358
328
 
359
- Proceed? (Y/N)
360
- ```
329
+ ### v1.0 — {mô tả} ({date})
361
330
 
362
- Wait for explicit "Y" or "N" from the user before continuing.
363
- - "Y" → proceed to the command-specific steps below.
364
- - "N" stop and ask what the user wants to change.
365
-
366
-
367
- ### Analyze — 4 Lenses (run all four perspectives)
368
-
369
- #### QA Lens — Test Coverage & Edge Cases
370
- Evaluate:
371
- - Are all acceptance criteria testable and measurable?
372
- - Are edge cases and error scenarios specified?
373
- - Are boundary conditions defined?
374
- - Is there ambiguity in expected behavior?
375
-
376
- #### DEV Lens — Technical Clarity & Feasibility
377
- Evaluate:
378
- - Are API inputs/outputs clearly defined?
379
- - Are business rules unambiguous enough to implement?
380
- - Are there performance or scalability concerns?
381
- - Are cross-service dependencies fully described?
382
- - Is there anything technically infeasible or risky?
383
-
384
- #### SA Lens — Architecture & Design
385
- Evaluate:
386
- - Does this fit the existing architecture?
387
- - Are there design patterns or constraints to apply?
388
- - Is data modeling clear (entities, relationships)?
389
- - Are there security or auth implications?
390
-
391
- #### PO Lens — Business Value & Scope
392
- Evaluate:
393
- - Is scope clearly bounded?
394
- - Are priorities clear?
395
- - Are success metrics defined?
396
- - Are stakeholder needs fully captured?
397
- - Any scope creep risk?
398
-
399
- ### Write Output
400
-
401
- Derive the output filename from the PRD slug:
402
- - PRD file: `specs/payment/create-invoice/prd.md` → output: `.agent/review/create-invoice-findings.yaml`
403
- - Rule: take the PRD's parent folder name (the `prd-slug`), append `-findings.yaml`
404
-
405
- Write findings to `.agent/review/{prd-slug}-findings.yaml`:
406
-
407
- ```yaml
408
- # Generated by /refine-prd
409
- # Review each finding and mark: accepted / rejected / needs_discussion
410
- prd_source: "specs/{domain}/{prd-slug}/prd.md"
411
- generated_at: "{ISO datetime}"
412
- status: "pending_review"
413
-
414
- findings:
415
- - id: "F001"
416
- lens: "QA" # QA | DEV | SA | PO
417
- severity: "major" # critical | major | minor
418
- section: "§6. Acceptance Criteria"
419
- finding: "{Clear description of the gap or issue}"
420
- suggestion: "{Specific actionable improvement}"
421
- status: "pending" # pending | accepted | rejected | needs_discussion
422
-
423
- - id: "F002"
424
- lens: "DEV"
425
- severity: "minor"
426
- section: "§8. Cross-Service Dependencies"
427
- finding: "{finding}"
428
- suggestion: "{suggestion}"
429
- status: "pending"
430
-
431
- summary:
432
- total_findings: {N}
433
- by_severity:
434
- critical: {N}
435
- major: {N}
436
- minor: {N}
437
- by_lens:
438
- QA: {N}
439
- DEV: {N}
440
- SA: {N}
441
- PO: {N}
442
- recommendation: "APPROVED_WITH_MINOR_CHANGES | NEEDS_REVISION | BLOCKED"
443
- ```
331
+ | Mục | Thay đổi |
332
+ |-----|----------|
333
+ | | Bản đầu sinh từ product-definition. |
444
334
 
445
- ### Report to User
335
+ ---
446
336
 
447
- ```
448
- /refine-prd Complete — {PRD name}
337
+ <!--
338
+ NEXT STEPS:
339
+ Khi PRD được approve (status: approved), chạy:
340
+ /generate-bdd "specs/{domain}/{prd-slug}/{TICKET-ID}-{prd-slug}.md"
341
+ để sinh BDD feature specs từ PRD này.
342
+ -->
449
343
 
450
- Findings: {total} total
451
- 🔴 Critical: {N} 🟡 Major: {N} 🟢 Minor: {N}
344
+ ````
452
345
 
453
- Top issues:
454
- [F001] QA/major — {brief description}
455
- [F002] DEV/minor — {brief description}
346
+ ### Output
456
347
 
457
- Review file: .agent/review/{prd-slug}-findings.yaml
458
- Open with Review Board extension (right-click file) to accept/reject each finding
459
- → After review: update PRD and run /generate-bdd
348
+ ```
349
+ Đã tạo PRD: specs/{domain}/{prd-slug}/{TICKET}-{prd-slug}.md
350
+ Status: draft
460
351
  ```
461
352
 
462
- # Report Footer — Standard Command Output Format
353
+ # Report Footer — Định dạng output chuẩn cho mọi lệnh
463
354
 
464
- Every command report must end with this standard footer section.
355
+ Mọi report của lệnh phải kết thúc bằng section footer chuẩn này.
465
356
 
466
357
  ## Status Badge
467
358
 
468
- Choose one based on outcome:
469
- - `✅ Complete` — all steps succeeded, no issues found
470
- - `❌ Failed` — command could not complete due to a blocking error
471
- - `⚠️ Warnings` — completed with non-blocking issues that should be reviewed
359
+ Chọn một theo kết quả:
360
+ - `✅ Complete` — mọi bước thành công, không vấn đề
361
+ - `❌ Failed` — lệnh không hoàn thành được do lỗi chặn
362
+ - `⚠️ Warnings` — hoàn thành nhưng vấn đề không chặn, nên review lại
472
363
 
473
364
  ## Output Artifacts
474
365
 
475
- List every file created or modified by this command:
366
+ Liệt mọi file được tạo hoặc sửa bởi lệnh này:
476
367
  ```
477
368
  Output Artifacts:
478
- {created|updated} {file-path} ({brief description})
479
- {created|updated} {file-path} ({brief description})
369
+ {created|updated} {file-path} ({ tả ngắn})
370
+ {created|updated} {file-path} ({ tả ngắn})
480
371
  ```
481
372
 
482
- If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
373
+ Nếu không ghi file nào (vd: lệnh review hoặc phân tích) → ghi `Output Artifacts: none (read-only)`.
483
374
 
484
375
  ## Pipeline Position
485
376
 
486
- Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
487
- so the user always sees where this command sits in the end-to-end flow:
377
+ In một đồ pipeline một dòng, đánh dấu phase của lệnh HIỆN TẠI bằng `◀ bạn ở đây`,
378
+ để người dùng luôn thấy lệnh này nằm đâu trong luồng end-to-end:
488
379
 
489
380
  ```
490
381
  Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
491
382
  ```
492
383
 
493
- Find the current command in this phase legend and mark **its** phase in the map above:
384
+ Tìm lệnh hiện tại trong bảng phase dưới đây đánh dấu **phase của nó** trong sơ đồ trên:
494
385
 
495
386
  | Phase | Commands |
496
387
  |-------|----------|
@@ -504,59 +395,72 @@ Find the current command in this phase legend and mark **its** phase in the map
504
395
  | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
505
396
  | Trace Audit | `/validate-traces` |
506
397
 
507
- For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
398
+ Với **lệnh review**, thêm vòng review 3 bước đánh dấu bước hiện tại, vd:
508
399
  `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
509
400
 
510
- **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
511
- `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline
512
- **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
401
+ **Lệnh xuyên suốt** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
402
+ `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) nằm ngoài pipeline tuyến tính
403
+ **bỏ hẳn dòng Pipeline** cho các lệnh này (đừng cố nhét chúng vào đồ).
513
404
 
514
- ## Next Command Suggestion
405
+ ## Gợi ý lệnh tiếp theo
515
406
 
516
- Suggest the logical next command based on workflow phase:
407
+ Gợi ý lệnh kế tiếp hợp theo phase của workflow:
517
408
 
518
- | Current command | Suggest next |
409
+ | Lệnh hiện tại | Gợi ý lệnh tiếp theo |
519
410
  |-------------------------|-----------------------------------------------|
520
- | /setup-ai-first | `/define-product` to start your first feature |
411
+ | /setup-ai-first | `/define-product` để bắt đầu feature đầu tiên |
521
412
  | /define-product | `/generate-prd {product-definition-file}` |
522
- | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
523
- | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
524
- | /review-context (PRD) | FE/App: `/generate-design-spec {prd-file}` (then BDD after sign-off); BE: `/generate-bdd {prd-file}` directly; fix PRD if NEEDS_FIX |
525
- | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
526
- | /generate-bdd | `/review-context {feature-file}` to verify coverage |
527
- | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
528
- | /qc-analyze | `/qc-plan {UC-ID}` (resolve 🔴 blocker gaps first) |
413
+ | /generate-prd | `/refine-prd {prd-file}` rồi `/review-context {prd-file}` |
414
+ | /refine-prd | Mở Review Board → cập nhật PRD → `/review-context {prd-file}` |
415
+ | /review-context (PRD) | FE/App: `/generate-design-spec {prd-file}` (rồi BDD sau khi sign-off); BE: `/generate-bdd {prd-file}` trực tiếp; sửa PRD nếu NEEDS_FIX |
416
+ | /generate-design-spec | Designer review → xác nhận link Figma → PO + Designer sign-off → `/generate-bdd {prd-file}` |
417
+ | /generate-bdd | `/review-context {feature-file}` để kiểm tra độ phủ |
418
+ | /review-context (BDD) | `/generate-tech-docs {UC-ID}` nếu APPROVED; sinh lại nếu NEEDS_FIX |
419
+ | /qc-analyze | `/qc-plan {UC-ID}` (xử các gap blocker 🔴 trước) |
529
420
  | /qc-plan | `/qc-design-test {UC-ID}` |
530
- | /qc-design-test | `/qc-review {UC-ID}` (test-case review) |
531
- | /qc-review (test-case) | `/qc-run-test {UC-ID}` if APPROVED; fix TCs if NEEDS_FIX |
532
- | /qc-run-test | `/qc-report {UC-ID}` then `/qc-review {UC-ID}` (script review) |
533
- | /qc-review (script) | `/qc-report {UC-ID}` then create PR if APPROVED |
534
- | /qc-report | `/validate-traces {UC-ID}` to refresh Living Docs (qc_status) |
421
+ | /qc-design-test | `/qc-review {UC-ID}` (review test-case) |
422
+ | /qc-review (test-case) | `/qc-run-test {UC-ID}` nếu APPROVED; sửa TC nếu NEEDS_FIX |
423
+ | /qc-run-test | `/qc-report {UC-ID}` rồi `/qc-review {UC-ID}` (review script) |
424
+ | /qc-review (script) | `/qc-report {UC-ID}` rồi tạo PR nếu APPROVED |
425
+ | /qc-report | `/validate-traces {UC-ID}` để làm mới Living Docs (qc_status) |
535
426
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
536
- | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
537
- | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/dev-gen-test {UC-ID}` |
427
+ | /review-tech-docs | `/generate-code {feature-file}` nếu APPROVED; sửa doc nếu NEEDS_FIX |
428
+ | /generate-code | Lần gen đầu → `/review-code {UC-ID}`; gen lại → `/dev-gen-test {UC-ID}` |
538
429
  | /dev-gen-test | `/dev-run-test {UC-ID}` |
539
430
  | /dev-run-test (passing) | `/review-code {UC-ID}` |
540
- | /dev-run-test (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
541
- | /review-code | `/dev-smoke-test {UC-ID}` or create PR |
542
- | /dev-smoke-test | Create PR and link to ticket |
543
- | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/dev-gen-test {UC-ID}`; all OK → create PR |
544
- | /fix-bug | Create PR and link to ticket |
545
- | /debug | `/fix-bug {ticket-id}` if fix needed |
546
- | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
547
- | /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
548
- | /learn | Continue working — lesson applies on next command |
549
- | /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
550
- | /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
551
-
552
- Format the footer as:
431
+ | /dev-run-test (failing) | `/fix-bug {ticket-id}` hoặc `/debug {error}` |
432
+ | /review-code | `/dev-smoke-test {UC-ID}` hoặc tạo PR |
433
+ | /dev-smoke-test | Tạo PR link tới ticket |
434
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/dev-gen-test {UC-ID}`; tất cả OK → tạo PR |
435
+ | /fix-bug | Tạo PR link tới ticket |
436
+ | /debug | `/fix-bug {ticket-id}` nếu cần sửa |
437
+ | /report-bug | Gửi cho dev (`/fix-bug {BUG-ID}`); nếu thiếu coverage → `/propose-scenario {UC-ID}` |
438
+ | /propose-scenario | Báo PO/Dev review proposal trong `feedback/bdd-proposals/` |
439
+ | /learn | Tiếp tục làm việc — lesson áp dụng lệnh kế tiếp |
440
+ | /sync | `/validate-traces` để xem độ phủ đầy đủ; xử lý mọi `📥 tester feedback` được nêu |
441
+ | /update-framework | Review `git diff .agent/`, commit; `/sync` để đồng bộ nội dung dự án |
442
+
443
+ Định dạng footer như sau:
553
444
  ```
554
445
  ---
555
446
  Status : {badge}
556
- {Output Artifacts block}
447
+ {khối Output Artifacts}
557
448
  Pipeline : Discovery → PRD → [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
558
- (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
559
- Next : {suggested command with example arguments}
449
+ (lệnh review) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
450
+ Next : {lệnh gợi ý kèm ví dụ tham số}
560
451
  ```
561
- *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
452
+ *(Bỏ dòng `Pipeline` cho các lệnh xuyên suốt liệt kê ở trên.)*
453
+
454
+
455
+ ---
456
+
457
+ ## /refine-prd — Phân tích PRD qua 4 lăng kính review
458
+
459
+ Lệnh này thực thi **y hệt** `commands/refine-prd.md` — không nhân bản logic ở đây để tránh lệch schema findings.
460
+
461
+ `commands/refine-prd.md` bao gồm:
462
+ - Phân tích PRD bằng 4 lăng kính **fan-out đa sub-agent** (QA / DEV / SA / PO) + vòng completeness-critic (1 lần chạy ra đủ finding).
463
+ - Ghi findings YAML với **schema đầy đủ** (`uc_id`, `quote`, `auto_fixable`) — bắt buộc cho source-jump và nút "Apply to PRD" của Review Board.
464
+ - **Resume Mode** (`--resume`): áp dụng findings đã accept → bump version → ghi changelog → reset `draft`.
562
465
 
466
+ → **Đọc và tuân theo `commands/refine-prd.md`** với cùng `$ARGUMENTS`.