@longph2102/v-flow 1.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 (247) hide show
  1. package/AGENTS.md +265 -0
  2. package/CHANGELOG.md +318 -0
  3. package/LICENSE +21 -0
  4. package/README.md +326 -0
  5. package/agents/ba-agent.md +437 -0
  6. package/agents/ba-critic-agent.md +156 -0
  7. package/agents/ba-to-ptyc-agent.md +112 -0
  8. package/agents/bugfix-analyst-agent.md +221 -0
  9. package/agents/constitute-agent.md +155 -0
  10. package/agents/help-agent.md +168 -0
  11. package/agents/implement-agent.md +220 -0
  12. package/agents/import-ba-docs-agent.md +164 -0
  13. package/agents/master-check-agent.md +228 -0
  14. package/agents/metrics-agent.md +180 -0
  15. package/agents/operations-agent.md +123 -0
  16. package/agents/plan-agent.md +218 -0
  17. package/agents/prototype-agent.md +191 -0
  18. package/agents/retrospective-agent.md +196 -0
  19. package/agents/review-agent.md +210 -0
  20. package/agents/sprint-agent.md +191 -0
  21. package/agents/status-agent.md +186 -0
  22. package/agents/sync-agent.md +201 -0
  23. package/agents/test-agent.md +166 -0
  24. package/agents/understand-agent.md +339 -0
  25. package/cli/commands/check.js +96 -0
  26. package/cli/commands/dev-quiz.js +107 -0
  27. package/cli/commands/doctor.js +348 -0
  28. package/cli/commands/feature.js +259 -0
  29. package/cli/commands/hooks.js +163 -0
  30. package/cli/commands/init.js +189 -0
  31. package/cli/commands/log.js +199 -0
  32. package/cli/commands/plugin.js +230 -0
  33. package/cli/commands/score-card.js +203 -0
  34. package/cli/commands/status.js +269 -0
  35. package/cli/commands/sync.js +59 -0
  36. package/cli/commands/upgrade.js +150 -0
  37. package/cli/commands/validate.js +1259 -0
  38. package/cli/commands/watch.js +151 -0
  39. package/cli/index.js +46 -0
  40. package/cli/lib/ac-test-gate.js +89 -0
  41. package/cli/lib/activity-log.js +209 -0
  42. package/cli/lib/cli-error.js +183 -0
  43. package/cli/lib/constitution-lint.js +561 -0
  44. package/cli/lib/dev-quiz-grade.js +127 -0
  45. package/cli/lib/governance.js +78 -0
  46. package/cli/lib/hook-targets.js +167 -0
  47. package/cli/lib/i18n.js +375 -0
  48. package/cli/lib/knowledge-oracle.js +379 -0
  49. package/cli/lib/logger.js +203 -0
  50. package/cli/lib/module-card-lint.js +304 -0
  51. package/cli/lib/module-card-score.js +223 -0
  52. package/cli/lib/plugins.js +481 -0
  53. package/cli/lib/scanner.js +692 -0
  54. package/cli/lib/sync-core.js +232 -0
  55. package/cli/lib/sync-targets.js +84 -0
  56. package/cli/lib/templates.js +268 -0
  57. package/cli/lib/yaml-parser.js +203 -0
  58. package/commands/v.ba-critic.md +101 -0
  59. package/commands/v.ba-to-ptyc.md +71 -0
  60. package/commands/v.bugfix.md +86 -0
  61. package/commands/v.check.md +131 -0
  62. package/commands/v.constitute.md +87 -0
  63. package/commands/v.constitution.md +84 -0
  64. package/commands/v.fork.md +127 -0
  65. package/commands/v.help.md +73 -0
  66. package/commands/v.hotfix.md +200 -0
  67. package/commands/v.implement.md +92 -0
  68. package/commands/v.import-ba-docs.md +222 -0
  69. package/commands/v.metrics.md +74 -0
  70. package/commands/v.operations.md +70 -0
  71. package/commands/v.plan.md +78 -0
  72. package/commands/v.prototype.md +121 -0
  73. package/commands/v.quickfix.md +169 -0
  74. package/commands/v.retrospective.md +80 -0
  75. package/commands/v.review.md +78 -0
  76. package/commands/v.rewind.md +127 -0
  77. package/commands/v.specify.md +118 -0
  78. package/commands/v.sprint.md +75 -0
  79. package/commands/v.status.md +62 -0
  80. package/commands/v.sync.md +81 -0
  81. package/commands/v.test.md +67 -0
  82. package/commands/v.understand.md +112 -0
  83. package/package.json +65 -0
  84. package/skills/_shared/constitution-reader/SKILL.md +109 -0
  85. package/skills/_shared/constitution-reader/config.json +52 -0
  86. package/skills/_shared/constitution-reader/examples/good/b1-phase-output.md +48 -0
  87. package/skills/_shared/constitution-reader/gotchas.md +46 -0
  88. package/skills/_shared/context-reader/SKILL.md +111 -0
  89. package/skills/_shared/context-reader/config.json +54 -0
  90. package/skills/_shared/context-reader/examples/good/legacy-nodejs-output.md +35 -0
  91. package/skills/_shared/context-reader/gotchas.md +49 -0
  92. package/skills/_shared/ears-notation/SKILL.md +63 -0
  93. package/skills/_shared/ears-notation/config.json +55 -0
  94. package/skills/_shared/ears-notation/examples/good/plan-test-interpretation.md +29 -0
  95. package/skills/_shared/ears-notation/gotchas.md +43 -0
  96. package/skills/check/cross-validator/SKILL.md +206 -0
  97. package/skills/check/cross-validator/config.json +33 -0
  98. package/skills/check/cross-validator/examples/good/validation-report-pass-with-concerns.md +105 -0
  99. package/skills/check/cross-validator/gotchas.md +43 -0
  100. package/skills/implement/constitution-enforcer/SKILL.md +134 -0
  101. package/skills/implement/constitution-enforcer/config.json +16 -0
  102. package/skills/implement/constitution-enforcer/examples/bad/vague-report.md +42 -0
  103. package/skills/implement/constitution-enforcer/examples/good/compliance-report.md +57 -0
  104. package/skills/implement/constitution-enforcer/gotchas.md +26 -0
  105. package/skills/implement/constitution-enforcer/scripts/check-constitution.sh +88 -0
  106. package/skills/implement/no-go-zone-guard/SKILL.md +173 -0
  107. package/skills/implement/no-go-zone-guard/config.json +28 -0
  108. package/skills/implement/no-go-zone-guard/examples/good/adapter-workaround.md +46 -0
  109. package/skills/implement/no-go-zone-guard/gotchas.md +27 -0
  110. package/skills/implement/no-go-zone-guard/scripts/check-nogo-zones.sh +148 -0
  111. package/skills/implement/no-go-zone-guard/scripts/nogo-precommit.sh +96 -0
  112. package/skills/implement/tdd-driver/SKILL.md +159 -0
  113. package/skills/implement/tdd-driver/config.json +33 -0
  114. package/skills/implement/tdd-driver/examples/good/tdd-cycle-product-repo.md +81 -0
  115. package/skills/implement/tdd-driver/gotchas.md +34 -0
  116. package/skills/metrics/metrics-collector/SKILL.md +133 -0
  117. package/skills/metrics/metrics-collector/config.json +16 -0
  118. package/skills/metrics/metrics-collector/examples/bad/incomplete-report.md +48 -0
  119. package/skills/metrics/metrics-collector/examples/good/full-metrics-report.md +101 -0
  120. package/skills/metrics/metrics-collector/gotchas.md +26 -0
  121. package/skills/operations/incident-runbook/SKILL.md +167 -0
  122. package/skills/operations/incident-runbook/config.json +21 -0
  123. package/skills/operations/incident-runbook/examples/bad/vague-incident-report.md +48 -0
  124. package/skills/operations/incident-runbook/examples/good/p1-hotfix-response.md +119 -0
  125. package/skills/operations/incident-runbook/gotchas.md +26 -0
  126. package/skills/plan/architecture-designer/SKILL.md +228 -0
  127. package/skills/plan/architecture-designer/config.json +32 -0
  128. package/skills/plan/architecture-designer/examples/bad/vague-plan.md +62 -0
  129. package/skills/plan/architecture-designer/examples/good/expand-contract-migration.md +56 -0
  130. package/skills/plan/architecture-designer/examples/good/plan-structure.md +58 -0
  131. package/skills/plan/architecture-designer/gotchas.md +45 -0
  132. package/skills/plan/task-breakdown/SKILL.md +208 -0
  133. package/skills/plan/task-breakdown/config.json +26 -0
  134. package/skills/plan/task-breakdown/examples/bad/vague-tasks.md +77 -0
  135. package/skills/plan/task-breakdown/examples/good/spike-clarify-tasks.md +66 -0
  136. package/skills/plan/task-breakdown/examples/good/tasks-login-feature.md +111 -0
  137. package/skills/plan/task-breakdown/gotchas.md +39 -0
  138. package/skills/prototype/LOGIC.md +240 -0
  139. package/skills/prototype/SKILL.md +185 -0
  140. package/skills/prototype/UI.md +407 -0
  141. package/skills/prototype/config.json +104 -0
  142. package/skills/prototype/examples/bad/prototype-notes.md +68 -0
  143. package/skills/prototype/examples/good/prototype-notes-ui.md +109 -0
  144. package/skills/prototype/examples/good/prototype-notes.md +67 -0
  145. package/skills/prototype/gotchas.md +128 -0
  146. package/skills/prototype/scripts/check-flow-state.ps1 +112 -0
  147. package/skills/prototype/scripts/check-flow-state.sh +104 -0
  148. package/skills/prototype/scripts/check-prototype-cleanup.ps1 +124 -0
  149. package/skills/prototype/scripts/check-prototype-cleanup.sh +109 -0
  150. package/skills/prototype/scripts/check-prototype-notes.ps1 +107 -0
  151. package/skills/prototype/scripts/check-prototype-notes.sh +102 -0
  152. package/skills/review/adversarial-reviewer/SKILL.md +137 -0
  153. package/skills/review/adversarial-reviewer/config.json +32 -0
  154. package/skills/review/adversarial-reviewer/examples/good/review-report-template.md +56 -0
  155. package/skills/review/adversarial-reviewer/gotchas.md +46 -0
  156. package/skills/review/adversarial-reviewer/scripts/quick-security-scan.sh +52 -0
  157. package/skills/specify/ba-bpmn-doc-gen/SKILL.md +108 -0
  158. package/skills/specify/ba-bpmn-doc-gen/reference/reference-bpmn-generation.md +528 -0
  159. package/skills/specify/ba-bpmn-doc-gen/reference/reference-drawio-flowchart.md +466 -0
  160. package/skills/specify/ba-critic/SKILL.md +172 -0
  161. package/skills/specify/ba-critic/config.json +32 -0
  162. package/skills/specify/ba-critic/examples/good/critic-report-round1.md +51 -0
  163. package/skills/specify/ba-critic/gotchas.md +40 -0
  164. package/skills/specify/ba-critic/scripts/check-spec-quality.sh +72 -0
  165. package/skills/specify/ba-doc-generator/SKILL.md +102 -0
  166. package/skills/specify/ba-doc-generator/references/template-clevel.md +84 -0
  167. package/skills/specify/ba-doc-generator/references/template-compliance.md +83 -0
  168. package/skills/specify/ba-doc-generator/references/template-dev.md +138 -0
  169. package/skills/specify/ba-doc-generator/references/template-partner.md +167 -0
  170. package/skills/specify/ba-doc-generator/references/template-pm.md +92 -0
  171. package/skills/specify/ba-doc-generator/references/template-review.md +114 -0
  172. package/skills/specify/ba-doc-generator/references/template-tester.md +108 -0
  173. package/skills/specify/ba-doc-generator/references/template-user.md +98 -0
  174. package/skills/specify/bugfix-analyst/SKILL.md +296 -0
  175. package/skills/specify/bugfix-analyst/config.json +41 -0
  176. package/skills/specify/bugfix-analyst/examples/bad/common-mistakes.md +71 -0
  177. package/skills/specify/bugfix-analyst/examples/good/email-validation-bugfix.md +53 -0
  178. package/skills/specify/bugfix-analyst/gotchas.md +51 -0
  179. package/skills/specify/ears-writer/SKILL.md +129 -0
  180. package/skills/specify/ears-writer/config.json +20 -0
  181. package/skills/specify/ears-writer/examples/bad/common-mistakes.md +17 -0
  182. package/skills/specify/ears-writer/examples/good/login-requirements.md +41 -0
  183. package/skills/specify/ears-writer/gotchas.md +43 -0
  184. package/skills/specify/ears-writer/scripts/check-ears-compliance.sh +51 -0
  185. package/skills/test/test-case-generator/SKILL.md +161 -0
  186. package/skills/test/test-case-generator/config.json +33 -0
  187. package/skills/test/test-case-generator/examples/good/test-cases-login.md +104 -0
  188. package/skills/test/test-case-generator/gotchas.md +43 -0
  189. package/skills/understand/ba-docs-scanner/SKILL.md +239 -0
  190. package/skills/understand/ba-docs-scanner/config.json +47 -0
  191. package/skills/understand/ba-docs-scanner/examples/good/work-order-br-extract.md +28 -0
  192. package/skills/understand/ba-docs-scanner/gotchas.md +44 -0
  193. package/skills/understand/ba-docs-scanner/merge-rules.md +47 -0
  194. package/skills/understand/codebase-scanner/SKILL.md +260 -0
  195. package/skills/understand/codebase-scanner/config.json +56 -0
  196. package/skills/understand/codebase-scanner/examples/good/menu-module-output.md +44 -0
  197. package/skills/understand/codebase-scanner/gotchas.md +42 -0
  198. package/skills/understand/codebase-scanner/scripts/scan-project-structure.sh +64 -0
  199. package/templates/DESIGN.md +456 -0
  200. package/templates/agent-command-template.yaml +240 -0
  201. package/templates/agent-config-template.md +170 -0
  202. package/templates/agent-definition-template.md +145 -0
  203. package/templates/agent-metrics-template.md +150 -0
  204. package/templates/api-contract-template.md +72 -0
  205. package/templates/bugfix-report-template.md +195 -0
  206. package/templates/bugfix-spec-template.md +134 -0
  207. package/templates/code-review-report-template.md +119 -0
  208. package/templates/constitution-template.md +234 -0
  209. package/templates/context-template.md +94 -0
  210. package/templates/data-model-template.md +95 -0
  211. package/templates/decision-log-template.md +92 -0
  212. package/templates/flow-state-template.yaml +208 -0
  213. package/templates/github/workflows/v-flow-validate.yml +30 -0
  214. package/templates/knowledge/adr-template.md +70 -0
  215. package/templates/knowledge/api-contract-template.md +140 -0
  216. package/templates/knowledge/domain-glossary.md +29 -0
  217. package/templates/knowledge/golden-tests-readme.md +115 -0
  218. package/templates/knowledge/lessons-learned.md +41 -0
  219. package/templates/knowledge/patterns.md +103 -0
  220. package/templates/module-card/SKILL.md +85 -0
  221. package/templates/module-card/api-specs.md +96 -0
  222. package/templates/module-card/business-quiz.md +119 -0
  223. package/templates/module-card/cross-service.md +125 -0
  224. package/templates/module-card/db.md +85 -0
  225. package/templates/module-card/dev-quiz.md +62 -0
  226. package/templates/module-card/permissions.md +83 -0
  227. package/templates/module-card/state-diagram.md +64 -0
  228. package/templates/module-card/tech-context.md +90 -0
  229. package/templates/module-card/ui-flows.md +91 -0
  230. package/templates/module-card/use-cases.md +142 -0
  231. package/templates/module-template.yaml +161 -0
  232. package/templates/operations-report-template.md +108 -0
  233. package/templates/plan-template.md +308 -0
  234. package/templates/prototype-notes-template.md +116 -0
  235. package/templates/ptyc/PTYC.template.docx +0 -0
  236. package/templates/ptyc/ptyc.meta.example.yaml +44 -0
  237. package/templates/retrospective-report-template.md +136 -0
  238. package/templates/security-review-template.md +84 -0
  239. package/templates/session-template.md +167 -0
  240. package/templates/spec-review-log-template.md +75 -0
  241. package/templates/spec-template.md +229 -0
  242. package/templates/sprint-status-template.md +101 -0
  243. package/templates/tasks-template.md +275 -0
  244. package/templates/test-cases-template.md +124 -0
  245. package/templates/ux-checklist-template.md +79 -0
  246. package/templates/validation-report-template.md +125 -0
  247. package/templates/vflow-config-template.yaml +22 -0
@@ -0,0 +1,296 @@
1
+ ---
2
+ name: bugfix-analyst
3
+ description: "Hướng dẫn Bugfix Analyst Agent phân tích bug theo 3-behavior model (Current/Expected/Unchanged), tìm root cause, và thiết kế 3-tier test plan. Agent PHẢI đọc skill này khi /v.bugfix được gọi."
4
+ trigger: "Khi /v.bugfix được gọi"
5
+ phase: "S.1"
6
+ used_by:
7
+ - /v.bugfix
8
+ hooks:
9
+ pre_analysis: "Scan codebase → trace execution path → xác định root cause hypothesis"
10
+ post_analysis: "Verify 3-behavior model đầy đủ, 3-tier test plan có mapping matrix"
11
+ ---
12
+
13
+ # Bugfix Analyst — Phân Tích Bug Có Cấu Trúc
14
+
15
+ > ⚠️ Đây là **Skill bắt buộc** cho Bugfix Analyst Agent.
16
+ > QUAN TRỌNG: Phải document đủ **3 loại behavior**. Thiếu "Unchanged Behavior" → regression risk cao.
17
+ >
18
+ > → Xem `gotchas.md` cho lỗi phổ biến khi phân tích bug.
19
+ > → Xem `examples/good/` cho mẫu bugfix.md chuẩn.
20
+ > → Xem `examples/bad/` cho anti-patterns cần tránh.
21
+ > → Xem `config.json` để customize (min_unchanged, confidence_threshold).
22
+
23
+ ---
24
+
25
+ ## Khi nào KHÔNG cần skill này
26
+
27
+ - Bug đơn giản, rõ ràng, ≤ 5 files → dùng `/v.quickfix` (không cần formal analysis)
28
+ - Production incident P1/P2 → dùng `/v.hotfix` (speed > structure)
29
+ - Feature mới → dùng `/v.specify` (không phải bugfix)
30
+
31
+ ---
32
+
33
+ ## 3-Behavior Model — Core Concept
34
+
35
+ > 💡 Đây là concept QUAN TRỌNG NHẤT. Mọi bugfix analysis đều xoay quanh 3 loại behavior.
36
+ > Agent tự quyết depth dựa trên severity và complexity của bug.
37
+
38
+ ### Tại sao cần 3 behaviors?
39
+
40
+ Hầu hết regression khi fix bug xảy ra vì developer:
41
+ 1. ❌ Chỉ focus vào "cái gì sai" → fix xong break cái khác
42
+ 2. ❌ Không document "cái gì ĐÚNG phải giữ nguyên" → không ai biết regression xảy ra
43
+
44
+ 3-Behavior Model buộc agent phải suy nghĩ **cả 3 chiều**:
45
+
46
+ ```
47
+ 🔴 Current Behavior (BUG-B) — Cái gì ĐANG SAI?
48
+ 🟢 Expected Behavior (BUG-E) — Cái gì PHẢI ĐÚNG sau fix?
49
+ 🛡️ Unchanged Behavior (BUG-U) — Cái gì KHÔNG ĐƯỢC THAY ĐỔI?
50
+ ```
51
+
52
+ ### EARS Notation cho Bugfix
53
+
54
+ Áp dụng EARS notation (cross-ref `ears-writer` skill) với từ khóa bugfix-specific:
55
+
56
+ | Behavior Type | EARS Template | Prefix |
57
+ |---------------|---------------|--------|
58
+ | **Current (Defect)** | `Khi [điều kiện], hệ thống [hành vi sai hiện tại]` | BUG-B |
59
+ | **Expected (Correct)** | `Khi [điều kiện], hệ thống phải [hành vi đúng]` | BUG-E |
60
+ | **Unchanged (Protect)** | `Khi [điều kiện], hệ thống phải TIẾP TỤC [hành vi giữ nguyên]` | BUG-U |
61
+
62
+ ---
63
+
64
+ ## Đặc Thù Và Quy Ước
65
+
66
+ > 💡 Phần này chứa thông tin Agent thường bỏ sót hoặc làm sai.
67
+
68
+ ### 1. BUG-B và BUG-E phải là cặp đối xứng
69
+
70
+ - Mỗi BUG-B (defect) PHẢI có đúng 1 BUG-E (expected) tương ứng
71
+ - ❌ 3 BUG-B + 1 BUG-E → không rõ E nào fix B nào
72
+ - ✅ BUG-B01 ↔ BUG-E01, BUG-B02 ↔ BUG-E02
73
+
74
+ ### 2. BUG-U ít nhất 2 items
75
+
76
+ - Nghĩ về behaviors **liên quan** nhưng **không bị ảnh hưởng** bởi fix
77
+ - Hỏi: "Nếu tôi fix X, behavior nào ở gần X có thể bị ảnh hưởng?"
78
+ - Đọc code callers/dependents → infer unchanged behaviors
79
+
80
+ ### 3. Mỗi behavior = 1 assertion cụ thể
81
+
82
+ - ❌ "Hệ thống phải TIẾP TỤC hoạt động bình thường"
83
+ - ✅ "Khi user nhập email hợp lệ, hệ thống phải TIẾP TỤC chấp nhận và lưu với response 200"
84
+
85
+ ### 4. Measurable — có thể verify bằng test
86
+
87
+ - Mỗi behavior phải viết được test case tương ứng
88
+ - Nếu không test được → behavior quá vague
89
+
90
+ ### 5. Từ cấm trong behaviors
91
+
92
+ | Từ cấm | Vấn đề | Thay bằng |
93
+ |--------|--------|-----------|
94
+ | "nên", "should" | Không bắt buộc | "phải", "must" |
95
+ | "nhanh", "fast" | Không measurable | "trong vòng 200ms" |
96
+ | "hợp lý", "reasonable" | Mơ hồ | Số cụ thể |
97
+ | "có thể", "can" | Description, không phải assertion | "phải" |
98
+ | "bình thường" | Vague | Mô tả behavior cụ thể |
99
+
100
+ ---
101
+
102
+ ## Root Cause Analysis — Quy Trình
103
+
104
+ > 💡 Agent PHẢI scan code trước khi viết root cause. Không đoán mò.
105
+
106
+ ### Step 1: Thu thập thông tin
107
+
108
+ ```
109
+ 1. Đọc reproduction steps từ user
110
+ 2. Tìm logs/error messages liên quan
111
+ 3. Xác định input → output mong đợi vs thực tế
112
+ ```
113
+
114
+ ### Step 2: Scan codebase
115
+
116
+ ```
117
+ 1. Tìm entry point (API route, UI handler, event listener)
118
+ 2. Trace execution path — follow data flow từ input → bug location
119
+ 3. Đọc code xung quanh bug location — context 20-30 dòng
120
+ 4. Kiểm tra related tests — đã có test cover case này chưa?
121
+ 5. Kiểm tra git blame — code này thay đổi gần đây?
122
+ ```
123
+
124
+ ### Step 3: Xác định root cause
125
+
126
+ ```
127
+ Root cause PHẢI trả lời được 2 câu hỏi:
128
+ 1. "Dòng code nào / logic nào gây ra bug?"
129
+ 2. "Tại sao code đó sai?" (thiếu validation, logic error, race condition, etc.)
130
+ ```
131
+
132
+ ### Confidence Level
133
+
134
+ | Level | Criteria | Action |
135
+ |-------|----------|--------|
136
+ | **High** | Trace exact line, reproduce 100%, evidence rõ ràng | → Proceed to implement |
137
+ | **Medium** | Hypothesis hợp lý, nhiều suspect, chưa reproduce 100% | → Proceed nhưng ghi cảnh báo |
138
+ | **Low** | Chưa rõ exact location, cần debug thêm | → DỪNG, recommend debug session |
139
+
140
+ ---
141
+
142
+ ## 3-Tier Test Plan — Thiết Kế
143
+
144
+ ### Tier 1: Bug Reproducible (Red 🔴)
145
+
146
+ **Mục đích**: Confirm bug tồn tại — test PHẢI FAIL trước khi fix.
147
+
148
+ | Aspect | Giá trị |
149
+ |--------|---------|
150
+ | **Input** | Reproduction steps từ BUG-B* |
151
+ | **Assert** | Current (wrong) behavior KHÔNG xảy ra |
152
+ | **Trước fix** | ❌ FAIL (confirm bug exists) |
153
+ | **Sau fix** | ✅ PASS |
154
+ | **ID Convention** | TC-R01, TC-R02, ... |
155
+
156
+ ### Tier 2: Bug Fixed (Green 🟢)
157
+
158
+ **Mục đích**: Confirm fix hoạt động — test PHẢI PASS sau khi fix.
159
+
160
+ | Aspect | Giá trị |
161
+ |--------|---------|
162
+ | **Input** | Same scenario từ BUG-E* |
163
+ | **Assert** | Expected (correct) behavior |
164
+ | **Trước fix** | ❌ FAIL |
165
+ | **Sau fix** | ✅ PASS |
166
+ | **ID Convention** | TC-G01, TC-G02, ... |
167
+
168
+ ### Tier 3: No Regression (Protect 🛡️)
169
+
170
+ **Mục đích**: Confirm unchanged behaviors vẫn đúng — PHẢI PASS cả trước và sau fix.
171
+
172
+ | Aspect | Giá trị |
173
+ |--------|---------|
174
+ | **Input** | Scenarios từ BUG-U* |
175
+ | **Assert** | Unchanged behavior vẫn đúng |
176
+ | **Trước fix** | ✅ PASS |
177
+ | **Sau fix** | ✅ PASS |
178
+ | **ID Convention** | TC-P01, TC-P02, ... |
179
+
180
+ ### Mapping Matrix (bắt buộc trong bugfix.md)
181
+
182
+ | Behavior | Test Tier | Test ID | Trước fix | Sau fix |
183
+ |----------|-----------|---------|-----------|---------|
184
+ | BUG-B01 | T1 (Red) | TC-R01 | ❌ FAIL | ✅ PASS |
185
+ | BUG-E01 | T2 (Green) | TC-G01 | ❌ FAIL | ✅ PASS |
186
+ | BUG-U01 | T3 (Protect) | TC-P01 | ✅ PASS | ✅ PASS |
187
+ | BUG-U02 | T3 (Protect) | TC-P02 | ✅ PASS | ✅ PASS |
188
+
189
+ ---
190
+
191
+ ## Scope Analysis
192
+
193
+ ### Xác định files cần thay đổi
194
+
195
+ ```
196
+ 1. Từ root cause → file(s) chứa bug
197
+ 2. Từ fix approach → file(s) cần modify
198
+ 3. Từ test plan → test file(s) cần tạo/update
199
+ 4. TỔNG files giới hạn (nếu > 10 → cân nhắc escalate)
200
+ ```
201
+
202
+ ### Xác định constraints
203
+
204
+ ```
205
+ 1. Đọc context.md → No-Go Zones
206
+ 2. Từ BUG-U* → infer modules phải giữ nguyên
207
+ 3. Liệt kê explicit: "File X KHÔNG được thay đổi vì Y"
208
+ ```
209
+
210
+ ---
211
+
212
+ ## V-Flow Integration Points
213
+
214
+ - **context.md** → No-Go Zones, tech constraints
215
+ - **constitution.md** → Naming conventions, patterns
216
+ - **ears-writer skill** → EARS notation reference cho behaviors
217
+ - **tdd-driver skill** → Phase B.1 implement sẽ dùng 3-tier tests từ bugfix.md
218
+ - **adversarial-reviewer skill** → Phase R.1 review dùng 3-tier checklist
219
+ - **bugfix.md** → Output chính (thay vì spec.md)
220
+ - **_session.md** → Append trace entry `[BF]`
221
+ - **.flow-state.yaml** → Init `project_type: "bugfix"`
222
+
223
+ ---
224
+
225
+ ## Output — bugfix.md Structure
226
+
227
+ ```markdown
228
+ # Bugfix — [BUG-ID] [Mô tả ngắn]
229
+
230
+ **Severity**: P1 | P2 | P3 | P4
231
+ **Reporter**: [Tên/source]
232
+ **Affected Module**: [module/domain]
233
+ **Spec Version**: v1.0
234
+ **Date**: [YYYY-MM-DD]
235
+
236
+ ## 1. Bug Report
237
+ ### Reproduction Steps
238
+ ### Environment
239
+
240
+ ## 2. Bugfix Analysis (3-Behavior Model)
241
+ ### 2.1 Current Behavior (Defect) 🔴
242
+ ### 2.2 Expected Behavior (Correct) 🟢
243
+ ### 2.3 Unchanged Behavior (Regression Prevention) 🛡️
244
+
245
+ ## 3. Root Cause Analysis
246
+ ### Hypothesis
247
+ ### Affected Code
248
+ ### Why It Happened
249
+
250
+ ## 4. Scope
251
+ ### Files cần thay đổi
252
+ ### Constraints
253
+ ### No-Go Check
254
+
255
+ ## 5. Test Plan (3-Tier)
256
+ ### T1: Bug Reproducible (Red 🔴)
257
+ ### T2: Bug Fixed (Green 🟢)
258
+ ### T3: No Regression (Protect 🛡️)
259
+ ### Mapping Matrix
260
+
261
+ ## 6. Acceptance Criteria
262
+
263
+ ## 7. Routing
264
+ ```
265
+
266
+ ---
267
+
268
+ ## Checklist Trước Khi Submit bugfix.md
269
+
270
+ ```
271
+ [ ] 3-Behavior Model đầy đủ:
272
+ [ ] ≥1 BUG-B (defect) — mô tả cụ thể, measurable
273
+ [ ] ≥1 BUG-E (expected) — đối xứng 1:1 với từng BUG-B
274
+ [ ] ≥2 BUG-U (unchanged) — behaviors liên quan phải giữ nguyên
275
+ [ ] Root Cause Analysis:
276
+ [ ] Có hypothesis với evidence (file + line)
277
+ [ ] Confidence level xác định (high/medium/low)
278
+ [ ] Nếu confidence = low → DỪNG, recommend debug
279
+ [ ] Scope:
280
+ [ ] Files cần thay đổi listed
281
+ [ ] Constraints listed
282
+ [ ] No-Go check done (context.md)
283
+ [ ] Test Plan 3-Tier:
284
+ [ ] T1 (Red): ≥1 test reproduce bug
285
+ [ ] T2 (Green): ≥1 test verify fix
286
+ [ ] T3 (Protect): ≥2 tests regression prevention
287
+ [ ] Mapping matrix đầy đủ
288
+ [ ] Acceptance Criteria: ≥3 ACs cover cả 3 behavior types
289
+ [ ] Không dùng từ cấm: "nên", "nhanh", "hợp lý", "có thể", "bình thường"
290
+ ```
291
+
292
+ ---
293
+
294
+ ## Gotchas
295
+
296
+ → Xem `gotchas.md` cho lỗi phổ biến khi phân tích bug — cập nhật liên tục.
@@ -0,0 +1,41 @@
1
+ {
2
+ "setup_questions": [
3
+ {
4
+ "id": "min_unchanged",
5
+ "question": "Số Unchanged Behaviors (BUG-U) tối thiểu phải document?",
6
+ "type": "number",
7
+ "default": 2,
8
+ "description": "Tối thiểu 2 BUG-U để đảm bảo regression prevention có ý nghĩa."
9
+ },
10
+ {
11
+ "id": "confidence_threshold",
12
+ "question": "Confidence level tối thiểu để proceed implement?",
13
+ "options": ["high", "medium", "low"],
14
+ "default": "medium",
15
+ "description": "high = chỉ proceed khi chắc chắn. medium = proceed kèm cảnh báo. low = DỪNG, cần debug thêm."
16
+ },
17
+ {
18
+ "id": "max_scope_files",
19
+ "question": "Số files thay đổi tối đa trước khi escalate?",
20
+ "type": "number",
21
+ "default": 10,
22
+ "description": "Nếu scope > N files → cân nhắc escalate sang /v.specify full pipeline."
23
+ },
24
+ {
25
+ "id": "design_phase",
26
+ "question": "Bắt buộc Phase 2 (Fix Design)?",
27
+ "options": ["required", "optional", "auto"],
28
+ "default": "auto",
29
+ "description": "required = luôn tạo design.md. optional = skip nếu root cause rõ. auto = tự quyết dựa trên complexity."
30
+ }
31
+ ],
32
+ "hooks": {
33
+ "pre_analysis": "Scan codebase → trace execution path → build root cause hypothesis",
34
+ "post_analysis": "Verify 3-behavior model đầy đủ, mapping matrix complete, append _session.md"
35
+ },
36
+ "memory": {
37
+ "file": "bugfix-history.log",
38
+ "format": "[date] | [bug_id] | [severity] | [confidence] | [behaviors_b] | [behaviors_e] | [behaviors_u] | [tests_t1] | [tests_t2] | [tests_t3] | [verdict]",
39
+ "purpose": "Track bugfix quality — dùng cho /v.metrics và /v.retrospective"
40
+ }
41
+ }
@@ -0,0 +1,71 @@
1
+ # Bad Examples — Bugfix Analysis Anti-Patterns
2
+
3
+ ---
4
+
5
+ ❌ **Unchanged Behavior quá generic**:
6
+ ```
7
+ ### Unchanged Behavior 🛡️
8
+ - BUG-U01: Hệ thống phải TIẾP TỤC hoạt động bình thường
9
+ ```
10
+ → Vấn đề: "Hoạt động bình thường" không test được. Không rõ behavior cụ thể nào phải giữ.
11
+ → Fix: Mô tả chính xác behavior: "Khi user nhập email hợp lệ không có khoảng trắng, hệ thống phải TIẾP TỤC chấp nhận với response 200"
12
+
13
+ ---
14
+
15
+ ❌ **Root Cause = Symptom**:
16
+ ```
17
+ ### Root Cause
18
+ - Root Cause: API trả về lỗi 500
19
+ - Confidence: high
20
+ ```
21
+ → Vấn đề: 500 là symptom, không phải root cause. Tại sao 500? SQL error? Null pointer? Timeout?
22
+ → Fix: "SQL query không escape ký tự `'` trong field name, gây syntax error tại user_repository.dart:42"
23
+
24
+ ---
25
+
26
+ ❌ **BUG-B và BUG-E không đối xứng**:
27
+ ```
28
+ ### Current Behavior 🔴
29
+ - BUG-B01: Form chấp nhận email sai format
30
+ - BUG-B02: Form cho phép submit khi field trống
31
+ - BUG-B03: Error message không hiện
32
+
33
+ ### Expected Behavior 🟢
34
+ - BUG-E01: Form phải validate đúng
35
+ ```
36
+ → Vấn đề: 3 defects nhưng chỉ 1 expected behavior. Không rõ BUG-E01 fix bug nào.
37
+ → Fix: BUG-B01 ↔ BUG-E01, BUG-B02 ↔ BUG-E02, BUG-B03 ↔ BUG-E03 (mapping 1:1)
38
+
39
+ ---
40
+
41
+ ❌ **Thiếu Unchanged Behavior hoàn toàn**:
42
+ ```
43
+ ## Bugfix Analysis
44
+ ### Current Behavior 🔴
45
+ - BUG-B01: ...
46
+ ### Expected Behavior 🟢
47
+ - BUG-E01: ...
48
+ (không có section Unchanged)
49
+ ```
50
+ → Vấn đề: Thiếu regression prevention. Fix có thể break behaviors liên quan.
51
+ → Fix: LUÔN có ≥2 BUG-U. Hỏi: "Code nào call function bị fix?" → Infer unchanged behaviors.
52
+
53
+ ---
54
+
55
+ ❌ **Test plan chỉ có T2 (Green)**:
56
+ ```
57
+ ## Test Plan
58
+ - [ ] Test verify email validation hoạt động đúng
59
+ - [ ] Test verify form submit thành công
60
+ ```
61
+ → Vấn đề: Chỉ test fix hoạt động. Không test bug reproduce (T1) và không test regression (T3).
62
+ → Fix: Phải có cả 3 tiers: T1 (reproduce bug) + T2 (verify fix) + T3 (no regression).
63
+
64
+ ---
65
+
66
+ ❌ **Scope creep — fix nhiều bug trong 1 analysis**:
67
+ ```
68
+ # Bugfix — Email validation + Password strength + Login redirect
69
+ ```
70
+ → Vấn đề: 3 bug khác nhau trong 1 bugfix.md. Scope quá lớn, regression risk cao.
71
+ → Fix: 1 bugfix.md = 1 bug. Tạo bugfix riêng cho mỗi bug hoặc dùng /v.quickfix cho bug nhỏ.
@@ -0,0 +1,53 @@
1
+ # Good Example — Email Validation Bugfix
2
+
3
+ ## Bugfix Analysis (3-Behavior Model)
4
+
5
+ ### 2.1 Current Behavior (Defect) 🔴
6
+ - **BUG-B01**: Khi user nhập email có khoảng trắng đầu/cuối (vd: " user@test.com "),
7
+ hệ thống chấp nhận và lưu email chứa khoảng trắng vào database
8
+ - **BUG-B02**: Khi user nhập email " user@test.com " và sau đó đăng nhập với "user@test.com",
9
+ hệ thống báo "Email không tồn tại" vì so sánh exact match
10
+
11
+ ### 2.2 Expected Behavior (Correct) 🟢
12
+ - **BUG-E01**: Khi user nhập email có khoảng trắng đầu/cuối,
13
+ hệ thống phải trim khoảng trắng trước khi validate và lưu "user@test.com" (đã trim)
14
+ - **BUG-E02**: Khi user nhập email có khoảng trắng và sau đó đăng nhập với email không khoảng trắng,
15
+ hệ thống phải authenticate thành công (vì email đã được trim khi lưu)
16
+
17
+ ### 2.3 Unchanged Behavior (Regression Prevention) 🛡️
18
+ - **BUG-U01**: Khi user nhập email hợp lệ không có khoảng trắng (vd: "user@test.com"),
19
+ hệ thống phải TIẾP TỤC chấp nhận và lưu bình thường với response 200
20
+ - **BUG-U02**: Khi user nhập email không hợp lệ (thiếu @, domain sai, vd: "user@", "user"),
21
+ hệ thống phải TIẾP TỤC từ chối với error "Email không hợp lệ" và response 400
22
+ - **BUG-U03**: Khi user nhập các field khác (name, phone),
23
+ hệ thống phải TIẾP TỤC validate theo rules hiện tại, không bị ảnh hưởng bởi fix email
24
+
25
+ ---
26
+
27
+ ## Root Cause Analysis
28
+
29
+ ### Hypothesis
30
+ - **Root Cause**: Hàm `validateEmail()` trong `lib/validators/email_validator.dart:28`
31
+ validate format nhưng KHÔNG trim whitespace trước khi validate và lưu
32
+ - **Confidence**: high
33
+ - **Evidence**: Code line 28: `return emailRegex.hasMatch(input)` — `input` chưa được `.trim()`
34
+
35
+ ### Affected Code
36
+ | File | Line(s) | Mô tả vấn đề |
37
+ |------|---------|---------------|
38
+ | `lib/validators/email_validator.dart` | L28 | `hasMatch(input)` thiếu `.trim()` |
39
+ | `lib/repositories/user_repository.dart` | L45 | `save(email)` lưu email raw, chưa trim |
40
+
41
+ ---
42
+
43
+ ## Test Plan (3-Tier) — Mapping Matrix
44
+
45
+ | Behavior | Test Tier | Test ID | Trước fix | Sau fix |
46
+ |----------|-----------|---------|-----------|---------|
47
+ | BUG-B01 | T1 (Red) | TC-R01 | ❌ FAIL | ✅ PASS |
48
+ | BUG-B02 | T1 (Red) | TC-R02 | ❌ FAIL | ✅ PASS |
49
+ | BUG-E01 | T2 (Green) | TC-G01 | ❌ FAIL | ✅ PASS |
50
+ | BUG-E02 | T2 (Green) | TC-G02 | ❌ FAIL | ✅ PASS |
51
+ | BUG-U01 | T3 (Protect) | TC-P01 | ✅ PASS | ✅ PASS |
52
+ | BUG-U02 | T3 (Protect) | TC-P02 | ✅ PASS | ✅ PASS |
53
+ | BUG-U03 | T3 (Protect) | TC-P03 | ✅ PASS | ✅ PASS |
@@ -0,0 +1,51 @@
1
+ # Gotchas — Bugfix Analyst
2
+
3
+ > Cập nhật liên tục khi Agent gặp edge case mới.
4
+ > Mỗi lỗi lặp lại 2 lần → BẮT BUỘC thêm vào đây.
5
+
6
+ ---
7
+
8
+ ## Anti-Patterns
9
+
10
+ 1. ❌ **Unchanged Behavior quá generic** — "Hệ thống phải TIẾP TỤC hoạt động bình thường"
11
+ - **Fix**: Mô tả CỤ THỂ: "Khi user nhập email hợp lệ, hệ thống phải TIẾP TỤC chấp nhận và lưu với response 200"
12
+ - **Hậu quả**: T3 test không viết được → regression không bị phát hiện.
13
+
14
+ 2. ❌ **Root Cause = Symptom** — "Root cause: API trả 500"
15
+ - **Fix**: Đó là symptom. Root cause: "SQL query không escape ký tự đặc biệt trong field `name`, gây SQL syntax error tại `user_repository.dart:42`"
16
+ - **Hậu quả**: Fix symptom (wrap try-catch) → bug vẫn tồn tại, chỉ bị che.
17
+
18
+ 3. ❌ **Skip T3 tests** — "Chắc không break gì" → skip regression tests
19
+ - **Fix**: T3 LUÔN có ≥2 tests. Đây là **giá trị chính** của bugfix flow.
20
+ - **Hậu quả**: Fix gây regression → phải hotfix → vòng lặp chi phí.
21
+
22
+ 4. ❌ **Fix symptom thay vì root cause** — Thêm try-catch wrap error → "hết lỗi 500"
23
+ - **Fix**: Trace đến root cause thực sự. Try-catch chỉ là band-aid.
24
+ - **Signal**: Nếu fix chỉ là wrap/suppress error → almost certainly wrong.
25
+
26
+ 5. ❌ **BUG-B và BUG-E không đối xứng** — 3 BUG-B nhưng chỉ 1 BUG-E
27
+ - **Fix**: Mỗi BUG-B PHẢI có đúng 1 BUG-E tương ứng. Mapping 1:1.
28
+ - **Hậu quả**: Không rõ fix nào cho bug nào → confusion khi implement.
29
+
30
+ 6. ❌ **Quên scan codebase** — Viết root cause dựa trên guess, không trace code
31
+ - **Fix**: PHẢI scan code trước khi viết root cause. Evidence = file + line range.
32
+ - **Hậu quả**: Root cause sai → fix sai → bug vẫn còn.
33
+
34
+ 7. ❌ **Scope creep silent** — Fix 1 bug nhưng "tiện thể" fix 3 bug khác
35
+ - **Fix**: 1 bugfix.md = 1 bug. Các bug khác → tạo bugfix riêng hoặc quickfix.
36
+ - **Hậu quả**: Scope lớn → review khó → regression risk tăng.
37
+
38
+ 8. ❌ **Quên context.md / constitution.md** — Phân tích bug mà không check constraints
39
+ - **Fix**: LUÔN check No-Go Zones + constitution patterns trước khi propose fix.
40
+ - **Hậu quả**: Fix vi phạm No-Go Zone → bị block ở implement.
41
+
42
+ ---
43
+
44
+ ## Edge Cases
45
+
46
+ - ✅ Root cause không tìm được → Ghi confidence = "Low", recommend pairing/debug session. KHÔNG implement khi low confidence.
47
+ - ✅ Bug ảnh hưởng nhiều module (> 10 files) → Escalate sang `/v.specify` full pipeline.
48
+ - ✅ Bug 5-10 files → Có thể tiếp tục nhưng ghi warning vào bugfix.md.
49
+ - ✅ Bug đã fix trước đó nhưng regression → Đọc git history, document fix cũ trong Root Cause. T3 PHẢI cover case fix cũ gây regression.
50
+ - ✅ Unchanged behavior khó xác định → Hỏi: "Code nào call/depend function bị fix?" → Infer BUG-U từ callers/dependents.
51
+ - ✅ Bug chỉ reproduce trên specific environment → Document environment rõ ràng, flag trong bugfix.md.
@@ -0,0 +1,129 @@
1
+ ---
2
+ name: ears-writer
3
+ description: "Hướng dẫn BA Agent viết requirements theo EARS notation chính xác. Agent PHẢI đọc skill này trước khi viết bất kỳ requirement nào trong spec.md."
4
+ trigger: "Khi viết hoặc review requirements trong spec.md"
5
+ phase: "S.1"
6
+ used_by:
7
+ - /v.specify
8
+ - /v.ba-critic
9
+ ---
10
+
11
+ # EARS Writer — Viết Requirements Đúng Chuẩn
12
+
13
+ > ⚠️ Đây là **Skill bắt buộc** cho BA Agent khi viết requirements.
14
+ > Đọc trước khi viết bất kỳ REQ nào. Không có EARS → spec mơ hồ, không testable.
15
+ >
16
+ > → Xem `gotchas.md` cho Anti-patterns phổ biến.
17
+ > → Xem `examples/good/` và `examples/bad/` cho ví dụ thực tế.
18
+ > → Xem `config.json` để customize EARS settings (language, ID style).
19
+ > → Chạy `.v-flow/skills/specify/ears-writer/scripts/check-ears-compliance.sh <spec.md>` để validate tự động.
20
+
21
+ ---
22
+
23
+ ## Khi nào KHÔNG cần skill này
24
+
25
+ - Viết mô tả feature tổng quan (không phải requirement)
26
+ - Viết user story dạng "As a... I want... So that..." (dùng ở 1.1 Mô tả, không phải §3 Requirements)
27
+ - Viết acceptance criteria (AC là con của REQ, không phải REQ)
28
+
29
+ ---
30
+
31
+ ## 4 Templates EARS
32
+
33
+ Mỗi requirement thuộc ĐÚNG 1 loại. Chọn loại dựa trên bản chất yêu cầu:
34
+
35
+ | Type | Keyword khởi đầu | Template | Signal nhận biết |
36
+ |------|-------------------|----------|-----------------|
37
+ | **Ubiquitous** | `phải` | `Hệ thống phải <action>` | Luôn đúng, không phụ thuộc event |
38
+ | **Event-driven** | `Khi` | `Khi <trigger>, hệ thống phải <action>` | Có sự kiện rõ ràng kích hoạt |
39
+ | **State-driven** | `Trong khi` | `Trong khi <state>, hệ thống phải <action>` | Áp dụng SUỐT thời gian ở trạng thái |
40
+ | **Optional** | `Nếu` | `Nếu <condition>, hệ thống phải <action>` | Có điều kiện tiên quyết |
41
+
42
+ ### Cách chọn đúng loại
43
+
44
+ ```
45
+ Yêu cầu luôn đúng? ───────────────────── Ubiquitous (REQ-U)
46
+ Có sự kiện trigger? ──────────────────── Event-driven (REQ-E)
47
+ Áp dụng suốt 1 trạng thái? ───────────── State-driven (REQ-S)
48
+ Chỉ áp dụng khi condition thỏa? ──────── Optional (REQ-O)
49
+ ```
50
+
51
+ ### ID Convention
52
+
53
+ | Prefix | Loại | Ví dụ |
54
+ |--------|------|-------|
55
+ | REQ-U | Ubiquitous | REQ-U01, REQ-U02 |
56
+ | REQ-E | Event-driven | REQ-E01, REQ-E02 |
57
+ | REQ-S | State-driven | REQ-S01, REQ-S02 |
58
+ | REQ-O | Optional | REQ-O01, REQ-O02 |
59
+
60
+ ---
61
+
62
+ ## Đặc thù và Quy ước Nội bộ
63
+
64
+ > 💡 Đây là phần **QUAN TRỌNG NHẤT** — những gì LLM thường sai khi viết EARS.
65
+
66
+ ### 1. Mỗi REQ = 1 action duy nhất
67
+ - ❌ "Hệ thống phải validate input và lưu vào DB"
68
+ - ✅ Tách thành REQ-U01 (validate) + REQ-E01 (lưu DB)
69
+ - **Lý do**: 1 REQ → 1 test case → 1 task. Trộn lẫn = trace mất.
70
+
71
+ ### 2. Acceptance Criteria ngay dưới REQ
72
+ - Mỗi REQ phải có ≥1 AC dạng checkbox `- [ ] ...`
73
+ - AC phải **measurable** — có số cụ thể hoặc boolean outcome
74
+
75
+ ### 3. Security requirements luôn có ít nhất 1 REQ-U
76
+ - Feature có auth/data → phải có REQ-U cho security
77
+ - VD: REQ-U01: "Hệ thống phải hash password bằng bcrypt trước khi lưu"
78
+
79
+ ### 4. Error handling = REQ riêng
80
+ - Happy path: REQ-E01 (POST valid → 201)
81
+ - Error path: REQ-E02 (POST invalid → 400 + details)
82
+ - Đừng nhồi error vào REQ-E01
83
+
84
+ ### 5. Từ ngữ cấm trong requirements
85
+ Grep spec output trước khi submit — nếu tìm thấy bất kỳ từ nào, requirement SAI:
86
+
87
+ | Từ cấm | Vấn đề | Thay bằng |
88
+ |--------|--------|----------|
89
+ | "nên", "should" | Không bắt buộc → không testable | "phải", "must" |
90
+ | "nhanh", "fast" | Không measurable | "trong vòng 200ms" |
91
+ | "dễ dùng", "user-friendly" | Chủ quan → không testable | Mô tả behavior cụ thể |
92
+ | "hợp lý", "reasonable" | Mơ hồ | Số cụ thể |
93
+ | "có thể", "can" | Feature description, không phải requirement | "phải" |
94
+ | "v.v.", "etc." | Incomplete specification | Liệt kê hết |
95
+
96
+ ---
97
+
98
+ ## Mapping EARS → Downstream Agents
99
+
100
+ > 💡 Mỗi loại REQ gợi ý implementation pattern cho các Agent phía sau:
101
+
102
+ | REQ Type | Plan Agent nên | Test Agent nên | Implement Agent nên |
103
+ |----------|---------------|---------------|-------------------|
104
+ | REQ-U | Always-on component, middleware, interceptor | Unit test (always true — test mọi entry point) | Core module, no conditional logic |
105
+ | REQ-E | Event handler, controller action, callback | Event-triggered test (given trigger → expect action) | Handler function, route handler |
106
+ | REQ-S | State management, state machine, lifecycle | State-based test (while in state → verify behavior) | Stateful component, BLoC, StateNotifier |
107
+ | REQ-O | Conditional logic, feature flag, guard | Condition branch test (if condition → expect, else → expect different) | if/guard clause, optional adapter |
108
+
109
+ ---
110
+
111
+ ## Checklist Trước Khi Submit Spec
112
+
113
+ ```
114
+ [ ] Mỗi requirement có ID đúng convention (REQ-U/E/S/O + số)
115
+ [ ] Mỗi requirement bắt đầu bằng keyword EARS đúng loại
116
+ [ ] Mỗi requirement chỉ có 1 action chính
117
+ [ ] Mọi số liệu đều cụ thể (thời gian, kích thước, số lượng)
118
+ [ ] Mỗi requirement có ≥1 Acceptance Criteria
119
+ [ ] Không có từ cấm: "nên", "nhanh", "dễ dùng", "hợp lý", "có thể", "v.v."
120
+ [ ] Có ≥1 REQ-U cho security (nếu feature involve auth/data)
121
+ [ ] Error cases có REQ riêng (tách khỏi happy path)
122
+ [ ] Không có REQ nào vi phạm No-Go Zones (kiểm tra context.md)
123
+ ```
124
+
125
+ ---
126
+
127
+ ## Gotchas
128
+
129
+ → Xem `gotchas.md` cho danh sách lỗi phổ biến — cập nhật liên tục khi Agent mắc lỗi mới.
@@ -0,0 +1,20 @@
1
+ {
2
+ "setup_questions": [
3
+ {
4
+ "id": "language",
5
+ "question": "Requirements viết bằng ngôn ngữ nào?",
6
+ "options": ["vi", "en", "mixed"],
7
+ "default": "vi"
8
+ },
9
+ {
10
+ "id": "id_style",
11
+ "question": "REQ ID style?",
12
+ "options": ["ears-prefixed", "sequential"],
13
+ "default": "ears-prefixed",
14
+ "description": "ears-prefixed = REQ-U01, REQ-E01. sequential = REQ-001, REQ-002."
15
+ }
16
+ ],
17
+ "hooks": {
18
+ "post_spec": "Scan spec.md → kiểm tra từ cấm, EARS compliance, ID uniqueness"
19
+ }
20
+ }
@@ -0,0 +1,17 @@
1
+ ❌ "User có thể đăng nhập vào hệ thống bằng email và password"
2
+ → Vấn đề: Feature description, không phải EARS requirement. Thiếu keyword, thiếu AC.
3
+
4
+ ❌ "Hệ thống nên validate input trước khi lưu"
5
+ → Vấn đề: "Nên" = optional behavior → không testable. Dùng "phải".
6
+
7
+ ❌ "REQ-001: Hệ thống phải validate input và lưu vào DB và gửi email xác nhận"
8
+ → Vấn đề: 3 actions trong 1 REQ. Tách thành 3 REQs riêng.
9
+
10
+ ❌ "Hệ thống phải nhanh và dễ sử dụng"
11
+ → Vấn đề: "Nhanh" và "dễ sử dụng" không measurable. Thay bằng số cụ thể.
12
+
13
+ ❌ "REQ-E01: Hệ thống phải hash password"
14
+ → Vấn đề: Dùng prefix Event-driven (E) nhưng nội dung là Ubiquitous (U). Sai loại.
15
+
16
+ ❌ "Khi user login, hệ thống phải xử lý hợp lý"
17
+ → Vấn đề: "Hợp lý" = mơ hồ. Mô tả CHÍNH XÁC behavior expected.