@anhth2/spec-driven-dev-plugin 0.5.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 (152) hide show
  1. package/ARCHITECTURE.md +243 -0
  2. package/bin/build.js +230 -0
  3. package/bin/index.js +311 -0
  4. package/commands/debug.md +374 -0
  5. package/commands/debug.tmpl +77 -0
  6. package/commands/define-product.md +451 -0
  7. package/commands/define-product.tmpl +154 -0
  8. package/commands/fix-bug.md +379 -0
  9. package/commands/fix-bug.tmpl +82 -0
  10. package/commands/generate-bdd.md +591 -0
  11. package/commands/generate-bdd.tmpl +294 -0
  12. package/commands/generate-code.md +395 -0
  13. package/commands/generate-code.tmpl +98 -0
  14. package/commands/generate-prd.md +488 -0
  15. package/commands/generate-prd.tmpl +191 -0
  16. package/commands/generate-tech-docs.md +362 -0
  17. package/commands/generate-tech-docs.tmpl +65 -0
  18. package/commands/generate-tests.md +377 -0
  19. package/commands/generate-tests.tmpl +80 -0
  20. package/commands/refine-prd.md +408 -0
  21. package/commands/refine-prd.tmpl +111 -0
  22. package/commands/review-code.md +354 -0
  23. package/commands/review-code.tmpl +57 -0
  24. package/commands/review-context.md +646 -0
  25. package/commands/review-context.tmpl +349 -0
  26. package/commands/review-tech-docs.md +518 -0
  27. package/commands/review-tech-docs.tmpl +221 -0
  28. package/commands/run-tests.md +343 -0
  29. package/commands/run-tests.tmpl +46 -0
  30. package/commands/setup-ai-first.md +278 -0
  31. package/commands/setup-ai-first.tmpl +197 -0
  32. package/commands/smoke-test.md +366 -0
  33. package/commands/smoke-test.tmpl +69 -0
  34. package/commands/validate-traces.md +529 -0
  35. package/commands/validate-traces.tmpl +232 -0
  36. package/core/FRAMEWORK_VERSION +1 -0
  37. package/core/commands/debug.md +374 -0
  38. package/core/commands/define-product.md +451 -0
  39. package/core/commands/fix-bug.md +379 -0
  40. package/core/commands/generate-bdd.md +591 -0
  41. package/core/commands/generate-code.md +395 -0
  42. package/core/commands/generate-prd.md +488 -0
  43. package/core/commands/generate-tech-docs.md +362 -0
  44. package/core/commands/generate-tests.md +377 -0
  45. package/core/commands/refine-prd.md +408 -0
  46. package/core/commands/review-code.md +354 -0
  47. package/core/commands/review-context.md +646 -0
  48. package/core/commands/review-tech-docs.md +518 -0
  49. package/core/commands/run-tests.md +343 -0
  50. package/core/commands/setup-ai-first.md +278 -0
  51. package/core/commands/smoke-test.md +366 -0
  52. package/core/commands/validate-traces.md +529 -0
  53. package/core/hooks/data-guard.js +141 -0
  54. package/core/hooks/settings.json +18 -0
  55. package/core/modules/angular/architecture-snippets/component-patterns.md +187 -0
  56. package/core/modules/angular/module.yaml +6 -0
  57. package/core/modules/angular/stack-profile.yaml +38 -0
  58. package/core/modules/context-engineering/architecture-snippets/context-design.md +119 -0
  59. package/core/modules/context-engineering/module.yaml +9 -0
  60. package/core/modules/context-engineering/stack-profile.yaml +61 -0
  61. package/core/modules/dotnet/architecture-snippets/clean-arch.md +160 -0
  62. package/core/modules/dotnet/module.yaml +6 -0
  63. package/core/modules/dotnet/stack-profile.yaml +50 -0
  64. package/core/modules/golang/architecture-snippets/domain-layout.md +283 -0
  65. package/core/modules/golang/module.yaml +6 -0
  66. package/core/modules/golang/stack-profile.yaml +40 -0
  67. package/core/modules/java-spring/architecture-snippets/layered-arch.md +201 -0
  68. package/core/modules/java-spring/module.yaml +15 -0
  69. package/core/modules/java-spring/stack-profile.yaml +28 -0
  70. package/core/modules/nextjs/architecture-snippets/app-router-patterns.md +269 -0
  71. package/core/modules/nextjs/module.yaml +14 -0
  72. package/core/modules/nextjs/stack-profile.yaml +74 -0
  73. package/core/modules/php-laravel/architecture-snippets/service-repository.md +302 -0
  74. package/core/modules/php-laravel/module.yaml +15 -0
  75. package/core/modules/php-laravel/stack-profile.yaml +56 -0
  76. package/core/modules/react/architecture-snippets/hooks-query-patterns.md +254 -0
  77. package/core/modules/react/module.yaml +14 -0
  78. package/core/modules/react/stack-profile.yaml +63 -0
  79. package/core/rules/data-protection.md +80 -0
  80. package/core/rules/workflow.md +44 -0
  81. package/core/skills/code/SKILL.md +526 -0
  82. package/core/skills/debug/SKILL.md +584 -0
  83. package/core/skills/discovery/SKILL.md +363 -0
  84. package/core/skills/prd/SKILL.md +456 -0
  85. package/core/skills/setup-ai-first/SKILL.md +160 -0
  86. package/core/skills/spec/SKILL.md +361 -0
  87. package/core/skills/test/SKILL.md +862 -0
  88. package/core/steps/context-loader.md +163 -0
  89. package/core/steps/gate.md +81 -0
  90. package/core/steps/report-footer.md +53 -0
  91. package/core/steps/spawn-agent.md +123 -0
  92. package/core/templates/architecture.template.md +113 -0
  93. package/core/templates/feature.template +259 -0
  94. package/core/templates/platform-guide.template.md +145 -0
  95. package/core/templates/prd.template.md +312 -0
  96. package/core/templates/product-definition.template.md +168 -0
  97. package/core/templates/project-context.yaml +78 -0
  98. package/hooks/data-guard.js +141 -0
  99. package/hooks/settings.json +18 -0
  100. package/modules/angular/architecture-snippets/component-patterns.md +187 -0
  101. package/modules/angular/module.yaml +6 -0
  102. package/modules/angular/stack-profile.yaml +38 -0
  103. package/modules/context-engineering/architecture-snippets/context-design.md +119 -0
  104. package/modules/context-engineering/module.yaml +9 -0
  105. package/modules/context-engineering/stack-profile.yaml +61 -0
  106. package/modules/dotnet/architecture-snippets/clean-arch.md +160 -0
  107. package/modules/dotnet/module.yaml +6 -0
  108. package/modules/dotnet/stack-profile.yaml +50 -0
  109. package/modules/golang/architecture-snippets/domain-layout.md +283 -0
  110. package/modules/golang/module.yaml +6 -0
  111. package/modules/golang/stack-profile.yaml +40 -0
  112. package/modules/java-spring/architecture-snippets/layered-arch.md +201 -0
  113. package/modules/java-spring/module.yaml +15 -0
  114. package/modules/java-spring/stack-profile.yaml +28 -0
  115. package/modules/nextjs/architecture-snippets/app-router-patterns.md +269 -0
  116. package/modules/nextjs/module.yaml +14 -0
  117. package/modules/nextjs/stack-profile.yaml +74 -0
  118. package/modules/php-laravel/architecture-snippets/service-repository.md +302 -0
  119. package/modules/php-laravel/module.yaml +15 -0
  120. package/modules/php-laravel/stack-profile.yaml +56 -0
  121. package/modules/react/architecture-snippets/hooks-query-patterns.md +254 -0
  122. package/modules/react/module.yaml +14 -0
  123. package/modules/react/stack-profile.yaml +63 -0
  124. package/package.json +42 -0
  125. package/rules/data-protection.md +80 -0
  126. package/rules/workflow.md +44 -0
  127. package/scripts/init.sh +49 -0
  128. package/scripts/upgrade.sh +94 -0
  129. package/skills/code/SKILL.md +526 -0
  130. package/skills/code/SKILL.tmpl +176 -0
  131. package/skills/debug/SKILL.md +584 -0
  132. package/skills/debug/SKILL.tmpl +262 -0
  133. package/skills/discovery/SKILL.md +363 -0
  134. package/skills/discovery/SKILL.tmpl +147 -0
  135. package/skills/prd/SKILL.md +456 -0
  136. package/skills/prd/SKILL.tmpl +188 -0
  137. package/skills/setup-ai-first/SKILL.md +160 -0
  138. package/skills/setup-ai-first/SKILL.tmpl +107 -0
  139. package/skills/spec/SKILL.md +361 -0
  140. package/skills/spec/SKILL.tmpl +174 -0
  141. package/skills/test/SKILL.md +862 -0
  142. package/skills/test/SKILL.tmpl +296 -0
  143. package/steps/context-loader.md +163 -0
  144. package/steps/gate.md +81 -0
  145. package/steps/report-footer.md +53 -0
  146. package/steps/spawn-agent.md +123 -0
  147. package/templates/architecture.template.md +113 -0
  148. package/templates/feature.template +259 -0
  149. package/templates/platform-guide.template.md +145 -0
  150. package/templates/prd.template.md +312 -0
  151. package/templates/product-definition.template.md +168 -0
  152. package/templates/project-context.yaml +78 -0
@@ -0,0 +1,312 @@
1
+ # {TICKET-ID} Tên tính năng/Feature Name
2
+
3
+ <!--
4
+ Template này được sử dụng bởi workflow /generate-prd.
5
+ AI Agent sẽ điền các section dựa trên input từ PO.
6
+ Các placeholder {…} cần được thay thế bằng nội dung thực tế.
7
+
8
+ ╔══════════════════════════════════════════════════════════════════════╗
9
+ ║ TERMINOLOGY RULES — Business Dictionary Enforcement ║
10
+ ║ Source: specs/domain-knowledge/business-dictionary.md ║
11
+ ║ AI Agent PHẢI tuân thủ 100% khi sinh nội dung PRD. ║
12
+ ╚══════════════════════════════════════════════════════════════════════╝
13
+
14
+ THUẬT NGỮ BẮT BUỘC (phải dùng đúng keyword):
15
+ ┌─────────────────────────┬──────────────────────────────────────────┐
16
+ │ Keyword chuẩn │ Ngữ cảnh │
17
+ ├─────────────────────────┼──────────────────────────────────────────┤
18
+ │ Consumer │ Khách hàng (global entity) │
19
+ │ Merchant / Tenant │ Merchant = nghiệp vụ, Tenant = kỹ thuật│
20
+ │ Online Storefront │ Tính năng bán hàng trên Zalo Mini App │
21
+ │ Branch │ Chi nhánh vật lý (projection từ KVS) │
22
+ │ Loyalty Member │ Quan hệ Consumer ↔ Merchant │
23
+ │ Order │ Đơn hàng (chỉ completed → Loyalty) │
24
+ │ OrderItem │ Chi tiết dòng hàng trong Order │
25
+ │ Product │ Hàng hóa (projection từ KVS) │
26
+ │ ProductCategory │ Nhóm hàng (hierarchical) │
27
+ │ ProductAttribute │ Định nghĩa loại thuộc tính │
28
+ │ ProductAttributeMap │ Mapping thuộc tính → sản phẩm cụ thể │
29
+ │ ProductImage │ Hình ảnh sản phẩm (nhiều ảnh, có rank) │
30
+ │ Address │ Địa chỉ đa hình (polymorphic) │
31
+ │ SourceSystem │ Hệ thống partner (map → X-App-Id) │
32
+ │ ExternalId │ ID tham chiếu từ hệ thống nguồn (KVS) │
33
+ │ Onboarding │ Quy trình khởi tạo gian hàng lần đầu │
34
+ │ revision │ Row version — delta sync │
35
+ │ KVLoyalty Widget │ Thư viện tích hợp frontend (JS qua CDN) │
36
+ └─────────────────────────┴──────────────────────────────────────────┘
37
+
38
+ THUẬT NGỮ BỊ CẤM — TUYỆT ĐỐI KHÔNG xuất hiện trong PRD:
39
+ ┌─────────────────────────┬─────────────────────────────────────────────────┐
40
+ │ ❌ KHÔNG dùng │ ✅ Thay thế bằng │
41
+ ├─────────────────────────┼─────────────────────────────────────────────────┤
42
+ │ Customer │ Consumer │
43
+ │ SKU │ Product + ProductAttribute + ProductAttributeMap│
44
+ │ JS SDK / JavaScript SDK │ KVLoyalty Widget │
45
+ │ CDC │ Event bus (Kafka) │
46
+ │ primaryBranchId │ Branch.isPrimary │
47
+ │ Cửa hàng (= storefront)│ Online Storefront / Gian hàng online │
48
+ └─────────────────────────┴─────────────────────────────────────────────────┘
49
+
50
+ QUY TẮC BỔ SUNG:
51
+ - Luôn dùng SourceSystem cho partners, ExternalId cho external references.
52
+ - Status/Enum values → tham chiếu core-entities.md Global Enum Registry.
53
+ - Khi nhắc "SKU" → diễn giải bằng Product con (masterProductId) + ProductAttributeMap.
54
+ - Consumer là global entity — 1 Consumer có thể mua hàng ở nhiều Merchant.
55
+ - Nếu phát hiện banned term trong input PO → thay thế bằng term chuẩn và ghi chú trong "Giả định AI".
56
+ - CROSS-REFERENCE (BẮT BUỘC): Bất kỳ chỗ nào trong tài liệu có nhắc đến một tính năng/ticket khác
57
+ (dù là pre-condition, business rule, giả định, AC, hay bất kỳ section nào) → PHẢI gắn inline link:
58
+ [TICKET-ID](./TICKET-ID-slug.md)
59
+ Không được để TICKET-ID dạng plain text nếu tồn tại file PRD tương ứng.
60
+ Ngoài ra, ghi rõ quan hệ phụ thuộc trong "Tài liệu tham khảo" ở Appendix.
61
+ - NEW TERM DETECTION: Nếu trong input PO xuất hiện thuật ngữ CHƯA CÓ trong business-dictionary.md
62
+ và thuật ngữ đó lặp lại ≥ 2 lần → DỪNG lại, hỏi PO confirm trước khi tiếp tục:
63
+ + Thuật ngữ đó có nghĩa gì trong ngữ cảnh hệ thống?
64
+ + English term chuẩn nên dùng là gì?
65
+ + Có cần bổ sung vào business-dictionary.md không?
66
+ Sau khi PO confirm → cập nhật business-dictionary.md (nếu PO đồng ý) rồi mới tiếp tục sinh PRD.
67
+ -->
68
+
69
+ ---
70
+
71
+ ## Metadata
72
+
73
+ | Field | Value |
74
+ |---------------|---------------------------------|
75
+ | **PRD ID** | {TICKET-ID} |
76
+ | **Version** | 1.0 |
77
+ | **Status** | draft / review / approved |
78
+ | **Author** | {PO name or "AI-assisted"} |
79
+ | **Domain** | {domain: loyalty, identity, …} |
80
+ | **Created** | {YYYY-MM-DD} |
81
+ | **Updated** | {YYYY-MM-DD} |
82
+
83
+ ---
84
+
85
+ # Feature
86
+
87
+ {Tên tính năng chính và mô tả capability hoặc chức năng mà sản phẩm cung cấp.}
88
+
89
+ ---
90
+
91
+ # 1. Tổng quan
92
+
93
+ ## a. User Story
94
+
95
+ <!--
96
+ ĐỊNH NGHĨA: Mô tả ngắn gọn nhu cầu của người dùng theo góc nhìn nghiệp vụ.
97
+ Trả lời câu hỏi: "Ai cần gì và tại sao?" — KHÔNG mô tả kỹ thuật.
98
+
99
+ QUY TẮC VIẾT:
100
+ - {User role} → Vai trò người dùng (ví dụ: Consumer, Merchant Admin, Cashier)
101
+ - {User goal} → Mục tiêu người dùng muốn đạt được (hành động/chức năng cụ thể)
102
+ - {Business value}→ Giá trị nghiệp vụ mang lại (lý do tại sao người dùng cần điều này)
103
+ -->
104
+
105
+ As a {User role}
106
+ I want to {User goal}
107
+ So that {Business value}
108
+
109
+ ## b. Phạm vi
110
+
111
+ <!--
112
+ ĐỊNH NGHĨA: Liệt kê danh sách các chức năng thuộc feature này.
113
+ Trả lời câu hỏi: "Feature này làm gì?" — giúp xác định ranh giới, tránh scope creep.
114
+
115
+ QUY TẮC VIẾT:
116
+ - Mỗi dòng là một chức năng/capability cụ thể mà feature này cung cấp.
117
+ - Chỉ liệt kê những gì được làm trong ticket này. Nếu có chức năng liên quan nhưng
118
+ KHÔNG thuộc ticket này → KHÔNG đưa vào danh sách.
119
+ - Viết ngắn gọn, súc tích, đủ để người đọc hiểu mà không cần giải thích thêm.
120
+ -->
121
+
122
+ In Scope
123
+ - {Chức năng thuộc feature}
124
+
125
+ ---
126
+
127
+ # 2. Acceptance Criteria
128
+
129
+ <!--
130
+ ĐỊNH NGHĨA: Danh sách điều kiện cần thỏa mãn để tính năng được coi là hoàn thành.
131
+ Trả lời câu hỏi: "Khi nào thì feature này được coi là DONE?" — tiêu chí để QA kiểm thử và PO sign-off.
132
+
133
+ QUY TẮC VIẾT:
134
+ - Viết theo góc nhìn người dùng: "Người dùng có thể...", "Hệ thống cho phép..."
135
+ - Mỗi AC phải testable (có thể kiểm tra được — pass hoặc fail rõ ràng).
136
+ - Chỉ ghi các tiêu chí CỐT LÕI — khi tính năng đạt được những điều này thì người dùng
137
+ đã có thể sử dụng được. Không ghi tiêu chí phụ hoặc edge case nhỏ.
138
+
139
+ KHÔNG viết AC về:
140
+ - UI/UX (màu sắc, vị trí nút, font chữ, animation) → thuộc Wireframe.
141
+ - Chi tiết kỹ thuật hoặc logic xử lý nội bộ → thuộc Business Rule / Business Logic.
142
+ -->
143
+
144
+ AC1: {Điều kiện chấp nhận}
145
+ AC2: {Điều kiện chấp nhận}
146
+ AC3: {Điều kiện chấp nhận}
147
+
148
+ ---
149
+
150
+ # 3. Use Case
151
+
152
+ <!--
153
+ ĐỊNH NGHĨA — USE CASE (UC):
154
+ Mô tả một kịch bản nghiệp vụ cụ thể từ góc nhìn người dùng tương tác với hệ thống.
155
+ Trả lời câu hỏi: "Người dùng tương tác với hệ thống như thế nào trong từng tình huống?"
156
+ - Actor → Ai thực hiện hành động trong kịch bản này
157
+ - Description → Tóm tắt kịch bản bằng 1 câu
158
+ - Pre-condition → Điều kiện PHẢI đúng TRƯỚC KHI Use Case bắt đầu (trạng thái hệ thống, quyền, dữ liệu)
159
+ - Post-condition→ Trạng thái/kết quả SAU KHI Use Case hoàn thành thành công
160
+
161
+ ĐỊNH NGHĨA — BUSINESS RULE (BR):
162
+ Quy tắc nghiệp vụ mà hệ thống bắt buộc phải tuân theo — viết thành một câu rõ ràng, ngắn gọn, dễ hiểu.
163
+ Trả lời câu hỏi: "Hệ thống PHẢI làm gì / KHÔNG được làm gì?" (WHAT)
164
+ - Là ràng buộc không thể thương lượng, xuất phát từ yêu cầu nghiệp vụ.
165
+ - Mỗi BR chỉ phát biểu MỘT quy tắc duy nhất, không gộp nhiều quy tắc vào một dòng.
166
+
167
+ ĐỊNH NGHĨA — BUSINESS LOGIC (BL):
168
+ Cách thực thi cụ thể của một Business Rule — mô tả các điều kiện và logic chi tiết.
169
+ Trả lời câu hỏi: "Hệ thống thực hiện quy tắc đó cụ thể như thế nào?" (HOW)
170
+ - Các điều kiện rẽ nhánh (if/else, trường hợp A / trường hợp B)
171
+ - Công thức tính toán hoặc quy tắc áp dụng theo từng trường hợp
172
+ - Thứ tự xử lý, ưu tiên, các trường hợp ngoại lệ
173
+ - Đây là input trực tiếp để developer implement.
174
+
175
+ NUMBERING CONVENTION:
176
+ - UC ID: format {TICKET_ID}-UC{N}
177
+ + {TICKET_ID} = Jira Ticket ID (e.g., LOYAL-29)
178
+ + {N} = UC number within this PRD (1, 2, 3, ...)
179
+ + E.g.: LOYAL-29-UC1, LOYAL-29-UC2, LOYAL-29-UC3, ...
180
+ - BR ID: format {TICKET_ID}-UC{N}-BR{M}
181
+ + {M} = BR number incrementing from 1 across the PRD (not reset per UC, not global)
182
+ + E.g.: LOYAL-29-UC1-BR1, LOYAL-29-UC1-BR2, LOYAL-29-UC2-BR3, ...
183
+ -->
184
+
185
+ #### {TICKET_ID}-UC1: {Tên Use Case}
186
+ Actor: {Người dùng thực hiện}
187
+ Description: {Mô tả ngắn gọn kịch bản nghiệp vụ}
188
+ Pre-condition: {Điều kiện cần trước khi Use Case bắt đầu}
189
+ Post-condition: {Kết quả sau khi Use Case hoàn thành}
190
+
191
+ Business Rule
192
+ | ID | Business Rule | Business Logic |
193
+ |----|---------------|----------------|
194
+ | {TICKET_ID}-UC1-BR1 | | - Logic 1<br/>- Logic 2<br/>- Logic 3 |
195
+
196
+ ---
197
+
198
+ # 4. UI/UX Guidelines
199
+
200
+ ## a. User Flow
201
+
202
+ <!--
203
+ ĐỊNH NGHĨA: Sơ đồ trực quan mô tả trình tự các bước và nhánh quyết định mà người dùng đi qua.
204
+ Trả lời câu hỏi: "Người dùng đi qua những bước nào và hệ thống phản hồi ra sao?"
205
+
206
+ QUY TẮC VIẾT (Mermaid flowchart):
207
+ - Start/Entry → Điểm vào: người dùng bắt đầu từ đâu (màn hình nào, hành động nào)
208
+ - Process → Bước xử lý: hình chữ nhật [ ] — hành động hoặc hiển thị của hệ thống
209
+ - Decision → Điểm rẽ nhánh: hình thoi { } — điều kiện dẫn đến kết quả khác nhau
210
+ - End State → Trạng thái kết thúc: kết quả cuối cùng người dùng nhận được
211
+
212
+ Mỗi nhánh Decision phải có label rõ ràng (|Có|, |Không|, |Thành công|, |Thất bại|...).
213
+ Bao gồm cả luồng lỗi / luồng ngoại lệ quan trọng (không chỉ happy path).
214
+ -->
215
+
216
+ {Flowchart mô tả trình tự các bước và các nhánh quyết định (Start/Entry → Process → Decision → End State)}
217
+
218
+ ```mermaid
219
+ flowchart TD
220
+ A[Bước 1: ...] --> B[Bước 2: ...]
221
+ B --> C{Điều kiện?}
222
+ C -->|Có| D[Bước 3a: ...]
223
+ C -->|Không| E[Bước 3b: ...]
224
+ ```
225
+
226
+ ## b. Wireframe
227
+
228
+ <!--
229
+ ĐỊNH NGHĨA: Mô tả bố cục và thành phần UI của từng màn hình.
230
+ Trả lời câu hỏi: "Màn hình trông như thế nào và người dùng tương tác với nó ra sao?"
231
+ Là cầu nối giữa nghiệp vụ và thiết kế UI. Có thể kèm link Figma hoặc ảnh mockup.
232
+
233
+ CẤU TRÚC BẢNG CHUẨN (3 thành phần chính):
234
+ - Screen → Tên màn hình / modal / trạng thái đang mô tả
235
+ - Components → Danh sách các thành phần UI hiển thị (button, label, list, input, bar...)
236
+ - Actions → Hành động người dùng thực hiện và kết quả/màn hình tiếp theo tương ứng
237
+
238
+ LƯU Ý — CẤU TRÚC LINH HOẠT THEO ĐỘ PHỨC TẠP:
239
+ Với màn đơn giản → dùng bảng 3 cột chuẩn (Screen / Components / Actions) là đủ.
240
+ Với màn phức tạp (nhiều trạng thái, nhiều modal, nhiều luồng lỗi) → có thể mở rộng:
241
+ - Tách riêng từng màn / modal / trạng thái thay vì gộp chung một bảng.
242
+ - Thêm các field chi tiết hơn nếu cần (UI Pattern, Header, Footer, Toast, Entry Point...).
243
+ Nguyên tắc: ưu tiên sự rõ ràng hơn tuân thủ cứng nhắc cấu trúc —
244
+ miễn là designer, dev, QA đọc vào hiểu đúng ý định của màn hình đó.
245
+ -->
246
+
247
+ **Screen N: {Tên màn hình}**
248
+
249
+ | Thành phần | Chi tiết |
250
+ | -------------- | -------- |
251
+ | **Screen** | {Tên màn hình} |
252
+ | **Components** | - {Component 1} <br>- {Component 2} <br>- {Component 3} |
253
+ | **Actions** | - {Hành động 1} → {Kết quả} <br>- {Hành động 2} → {Kết quả} |
254
+
255
+ <!-- Figma Design: {Link Figma — xóa dòng này nếu không có URL} -->
256
+
257
+ <!-- ![Wireframe mô tả](./assets/wireframe-name.png) -->
258
+
259
+ ---
260
+
261
+ # Appendix
262
+
263
+ ## Input gốc từ PO
264
+
265
+ > Lưu lại nguyên văn input ban đầu (text + links đến hình ảnh).
266
+
267
+ {Paste original input here}
268
+
269
+ ## Tài liệu tham khảo
270
+
271
+ <!--
272
+ Cross-reference PRD liên quan dùng format: [TICKET-ID](./TICKET-ID-slug.md) — {quan hệ phụ thuộc}
273
+ Ví dụ:
274
+ - [LOYAL-23](./LOYAL-23-cau-hinh-chi-nhanh.md) — Pre-condition: Branch phải được cấu hình trước
275
+ - [LOYAL-10](./LOYAL-10-onboarding-merchant.md) — Entity dùng chung: Merchant/Tenant
276
+ -->
277
+
278
+ - {[TICKET-ID](./TICKET-ID-slug.md) — mô tả quan hệ phụ thuộc}
279
+
280
+ ## Giả định AI
281
+
282
+ > Các giả định AI đưa ra khi PO chọn "skip" hoặc thông tin chưa đầy đủ.
283
+ > Mỗi giả định cần được PO review và confirm.
284
+
285
+ - {Giả định 1 — [AI DRAFT]}
286
+ - {Giả định 2 — [AI DRAFT]}
287
+
288
+ ---
289
+
290
+ ## Changelog
291
+
292
+ <!--
293
+ Version history — mỗi lần PRD được cập nhật (qua /refine-prd --resume hoặc PO tự sửa)
294
+ → thêm 1 dòng mới vào đầu bảng này với version mới.
295
+
296
+ Version bumping rules:
297
+ - Major (X.0 → X+1.0): thêm/xoá Use Case, thay đổi scope lớn, breaking BR change
298
+ - Minor (x.Y → x.Y+1): làm rõ AC/BR, thêm edge case, cập nhật wording
299
+
300
+ BDD và Code đọc version này qua @trace.prd_version để detect drift.
301
+ -->
302
+
303
+ | Version | Date | Changes |
304
+ |---------|------|---------|
305
+ | 1.0 | {YYYY-MM-DD} | Initial version |
306
+
307
+ <!--
308
+ NEXT STEPS:
309
+ Khi PRD được approve (status: approved), chạy:
310
+ /generate-bdd "path/to/this-prd.md"
311
+ để sinh BDD feature specs từ PRD này.
312
+ -->
@@ -0,0 +1,168 @@
1
+ # {TICKET-ID} Product Definition — {Feature Name}
2
+
3
+ <!--
4
+ This template is used by the /define-product workflow.
5
+ AI Agent fills each section through phased Q&A with PO.
6
+ Output is structured input for /generate-prd.
7
+
8
+ RULES:
9
+ - Each section corresponds to 1 phase in the workflow
10
+ - Incomplete section → keep placeholder, MUST NOT proceed to next phase
11
+ - PO confirmation status is recorded in each section
12
+ -->
13
+
14
+ ---
15
+
16
+ ## Metadata
17
+
18
+ | Field | Value |
19
+ |--------------------|--------------------------------|
20
+ | **Ticket** | {TICKET-ID} |
21
+ | **Feature** | {Feature name} |
22
+ | **Domain** | {domain} |
23
+ | **PO** | {PO name} |
24
+ | **Created** | {YYYY-MM-DD} |
25
+ | **Status** | in-progress / completed |
26
+ | **Completed Phase**| {last completed phase number} |
27
+
28
+ ---
29
+
30
+ ## Phase 0: Knowledge Sync
31
+
32
+ > AI syncs system knowledge. No PO input needed.
33
+
34
+ ### Related Entities
35
+ - {Entity 1} — {brief description}
36
+ - {Entity 2} — {brief description}
37
+
38
+ ### Related Modules
39
+ - {Module 1}
40
+ - {Module 2}
41
+
42
+ ### Existing Rules / Logic
43
+ - {Rule/logic from existing PRDs or domain knowledge}
44
+
45
+ ### Terminology Normalization
46
+ | Term in PO input | Canonical term (business-dictionary) |
47
+ |-------------------|--------------------------------------|
48
+ | {original term} | {canonical term} |
49
+
50
+ ---
51
+
52
+ ## Phase 1: Feature Definition
53
+
54
+ > ✅ PO Confirmed: {Yes/No}
55
+
56
+ ### Context
57
+ {Business context leading to this feature}
58
+
59
+ ### Problem Statement
60
+ {Problem to solve}
61
+
62
+ ### Goal
63
+ {Feature objective}
64
+
65
+ ### Actors
66
+ | Actor | Role | Primary/Secondary |
67
+ |----------|--------------------|-------------------|
68
+ | {Actor} | {Role description} | Primary |
69
+
70
+ ### Scope (In Scope)
71
+ - {Function 1}
72
+ - {Function 2}
73
+
74
+ ### User Story
75
+ As a {User role}
76
+ I want to {User goal}
77
+ So that {Business value}
78
+
79
+ ---
80
+
81
+ ## Phase 2: User Flow Definition
82
+
83
+ > ✅ PO Confirmed: {Yes/No}
84
+
85
+ ### Entry Point
86
+ {How user starts interacting with the feature}
87
+
88
+ ### Flow Steps
89
+ | Step | Action | Screen/State | Notes |
90
+ |------|-----------------|------------------|-------------|
91
+ | 1 | {User action} | {Screen/State} | {Notes} |
92
+ | 2 | {User action} | {Screen/State} | {Notes} |
93
+
94
+ ### Exit Point
95
+ {Final outcome when flow completes}
96
+
97
+ ---
98
+
99
+ ## Phase 3: Clarification Log
100
+
101
+ > Records all questions and answers across rounds.
102
+
103
+ ### Round {N}
104
+ | # | Category | Question | PO Answer |
105
+ |---|----------|------------|------------|
106
+ | 1 | Context | {question} | {answer} |
107
+ | 2 | Flow | {question} | {answer} |
108
+ | 3 | Logic | {question} | {answer} |
109
+
110
+ ### Unresolved Items
111
+ - {Unresolved item — if any remain, MUST NOT proceed to Phase 4}
112
+
113
+ ---
114
+
115
+ ## Phase 4: Business Rules
116
+
117
+ > ✅ PO Confirmed: {Yes/No}
118
+
119
+ | Rule ID | Action/Trigger | Rule | Condition |
120
+ |---------|---------------------|---------------------|----------------------|
121
+ | BR-1 | {Action from flow} | {Business rule} | {Applicable condition} |
122
+ | BR-2 | {Action from flow} | {Business rule} | {Applicable condition} |
123
+
124
+ ---
125
+
126
+ ## Phase 5: Business Logic
127
+
128
+ > ✅ PO Confirmed: {Yes/No}
129
+
130
+ | Rule ID | System Behavior | Data State Change | UI Behavior | Error Handling |
131
+ |---------|------------------------------------------|----------------------|----------------------|-----------------------|
132
+ | BR-1 | {How system processes when rule triggers} | {Data changes} | {enable/disable/...} | {Error message/action}|
133
+ | BR-2 | {How system processes when rule triggers} | {Data changes} | {enable/disable/...} | {Error message/action}|
134
+
135
+ ---
136
+
137
+ ## Phase 6: Acceptance Criteria
138
+
139
+ > ✅ PO Confirmed: {Yes/No}
140
+
141
+ | AC ID | Description | Expected Behavior | Derived from |
142
+ |-------|------------------------|---------------------------|--------------|
143
+ | AC-1 | {Criterion description} | {Expected behavior} | BR-{N} |
144
+ | AC-2 | {Criterion description} | {Expected behavior} | BR-{N} |
145
+
146
+ ---
147
+
148
+ ## Phase 7: Validation Report
149
+
150
+ ### Coverage Matrix
151
+ | Flow Action | Has Rule? | Has Logic? | Has AC? | Status |
152
+ |-------------|-----------|------------|---------|--------|
153
+ | {Action 1} | ✅/❌ | ✅/❌ | ✅/❌ | OK/GAP |
154
+
155
+ ### Conflicts Detected
156
+ - {Conflict description — or "None"}
157
+
158
+ ### Missing Items
159
+ - {Missing rule/AC/logic — or "None"}
160
+
161
+ ---
162
+
163
+ <!--
164
+ NEXT STEPS:
165
+ When Product Definition is complete (Status: completed), run:
166
+ /generate-prd {path-to-this-file} --jira {TICKET-ID}
167
+ to generate a PRD from this Product Definition.
168
+ -->
@@ -0,0 +1,78 @@
1
+ # =============================================================
2
+ # Project Context — AI-First Spec-Driven Development
3
+ # =============================================================
4
+ # This is the SINGLE SOURCE OF TRUTH for project-specific
5
+ # paths, tools, and routing used by all workflows.
6
+ #
7
+ # Workflows reference this file for WHERE to find things.
8
+ # Workflow steps define WHAT to do (universal best practices).
9
+ # =============================================================
10
+ #
11
+ # HOW AI AGENTS USE THIS FILE:
12
+ # 1. Open this file at the start of any workflow
13
+ # 2. Parse the YAML structure
14
+ # 3. When a workflow says "→ key.subkey", look up that key
15
+ # and use the resolved value as the actual path
16
+ # 4. All paths are RELATIVE to workspace root
17
+ # 5. For "{domain}", substitute from spec's @trace.domain
18
+ # =============================================================
19
+
20
+ project:
21
+ name: "{{PROJECT_NAME}}"
22
+ description: "{{PROJECT_DESCRIPTION}}"
23
+
24
+ # ----- File Paths -----
25
+ # All paths are relative to workspace root.
26
+ paths:
27
+ # BDD Specs
28
+ specs_dir: "specs/bdd"
29
+ templates_dir: "specs/templates"
30
+ feature_template: "specs/templates/feature.template"
31
+ bdd_writing_guide: "specs/templates/bdd-writing-guide.md"
32
+ trace_report: "specs/.trace/trace-report.md"
33
+
34
+ # PRD Documents
35
+ prd_dir: "specs/prd"
36
+ prd_template: "specs/templates/prd.template.md"
37
+ refinement_dir: ".agent/review"
38
+
39
+ # Product Definitions
40
+ product_definitions_dir: "specs/product-definition"
41
+ product_definition_template: "specs/templates/product-definition.template.md"
42
+
43
+ # Domain Knowledge
44
+ domain_knowledge_dir: "specs/domain-knowledge"
45
+ business_dictionary: "specs/domain-knowledge/business-dictionary.md"
46
+ core_entities: "specs/domain-knowledge/core-entities.md"
47
+
48
+ # Tech Docs
49
+ tech_docs_dir: "tech-docs"
50
+
51
+ # Trace
52
+ trace_dir: ".trace"
53
+
54
+ tech_stack:
55
+ language: "{{LANGUAGE}}" # e.g., Java 17 / TypeScript / C# / Go
56
+ framework: "{{FRAMEWORK}}" # e.g., Spring Boot 3.2 / Angular 17 / .NET 8
57
+ build_tool: "{{BUILD_TOOL}}" # e.g., Maven / npm / dotnet / go
58
+ test_framework: "{{TEST_FRAMEWORK}}" # e.g., JUnit 5 + Mockito / Jest / xUnit
59
+ database: "{{DATABASE}}" # e.g., PostgreSQL / MySQL / MongoDB
60
+ module: "{{MODULE}}" # e.g., java-spring / angular / dotnet / golang / context-engineering
61
+
62
+ conventions:
63
+ build_command: "{{BUILD_COMMAND}}" # e.g., mvn clean install -DskipTests
64
+ test_command: "{{TEST_COMMAND}}" # e.g., mvn test
65
+ service_run: "{{RUN_COMMAND}}" # e.g., mvn spring-boot:run
66
+ ticket_prefix: "{{TICKET_PREFIX}}" # e.g., PROJ / FEAT / UC
67
+
68
+ domains:
69
+ - "{{DOMAIN_1}}"
70
+ # - "{{DOMAIN_2}}"
71
+
72
+ # ----- Architecture -----
73
+ architecture:
74
+ style: "{{ARCH_STYLE}}" # e.g., Layered / Clean / Hexagonal
75
+ layers: "{{LAYER_STACK}}" # e.g., Controller → Facade → Service → Repository
76
+ key_rules:
77
+ - "{{ARCH_RULE_1}}"
78
+ - "{{ARCH_RULE_2}}"