@educa-corp/sdd-framework 0.6.0 → 0.7.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 (205) hide show
  1. package/bin/gate-trace.js +25 -2
  2. package/bin/index.js +32 -5
  3. package/bin/lint-trace.js +41 -0
  4. package/bin/self-check.js +430 -3
  5. package/bin/trace-schema.json +391 -30
  6. package/core/FRAMEWORK_VERSION +1 -1
  7. package/{commands/extend-prd.md → core/commands/amend-prd.md} +205 -173
  8. package/core/commands/dev-run-test.md +47 -9
  9. package/core/commands/extend-prd.md +39 -12
  10. package/core/commands/generate-bdd.md +43 -4
  11. package/core/commands/generate-code.md +33 -0
  12. package/core/commands/generate-tech-docs.md +34 -2
  13. package/core/commands/qc-run-test.md +29 -3
  14. package/core/commands/refine-prd.md +13 -2
  15. package/core/commands/review-context.md +43 -8
  16. package/core/commands/sync.md +105 -1
  17. package/core/commands/validate-traces.md +284 -11
  18. package/core/rules/workflow.md +34 -0
  19. package/core/steps/context-loader.md +26 -5
  20. package/core/templates/feature.template +1 -1
  21. package/docs/02-concepts/architecture.md +36 -0
  22. package/docs/04-reference/commands.md +148 -134
  23. package/docs/04-reference/trace-schema.md +39 -0
  24. package/docs/explain/02b-extend-prd.md +1 -1
  25. package/docs/explain/02c-amend-prd.md +152 -0
  26. package/docs/explain/28-sync.md +25 -0
  27. package/docs/explain/README.md +136 -135
  28. package/package.json +1 -8
  29. package/commands/debug.md +0 -529
  30. package/commands/debug.tmpl +0 -260
  31. package/commands/define-product.md +0 -438
  32. package/commands/define-product.tmpl +0 -225
  33. package/commands/dev-gen-test.md +0 -700
  34. package/commands/dev-gen-test.tmpl +0 -490
  35. package/commands/dev-run-test.md +0 -435
  36. package/commands/dev-run-test.tmpl +0 -225
  37. package/commands/dev-smoke-test.md +0 -374
  38. package/commands/dev-smoke-test.tmpl +0 -217
  39. package/commands/extend-prd.tmpl +0 -273
  40. package/commands/fix-bug.md +0 -519
  41. package/commands/fix-bug.tmpl +0 -197
  42. package/commands/generate-architecture.md +0 -354
  43. package/commands/generate-architecture.tmpl +0 -197
  44. package/commands/generate-bdd.md +0 -923
  45. package/commands/generate-bdd.tmpl +0 -590
  46. package/commands/generate-code.md +0 -859
  47. package/commands/generate-code.tmpl +0 -649
  48. package/commands/generate-design-spec.md +0 -737
  49. package/commands/generate-design-spec.tmpl +0 -524
  50. package/commands/generate-prd.md +0 -722
  51. package/commands/generate-prd.tmpl +0 -226
  52. package/commands/generate-spec-manifest.md +0 -321
  53. package/commands/generate-spec-manifest.tmpl +0 -164
  54. package/commands/generate-tech-docs.md +0 -920
  55. package/commands/generate-tech-docs.tmpl +0 -273
  56. package/commands/learn.md +0 -399
  57. package/commands/learn.tmpl +0 -130
  58. package/commands/map-testids.md +0 -238
  59. package/commands/map-testids.tmpl +0 -81
  60. package/commands/propose-scenario.md +0 -359
  61. package/commands/propose-scenario.tmpl +0 -202
  62. package/commands/qc-analyze.md +0 -269
  63. package/commands/qc-analyze.tmpl +0 -112
  64. package/commands/qc-design-test.md +0 -226
  65. package/commands/qc-design-test.tmpl +0 -69
  66. package/commands/qc-plan.md +0 -206
  67. package/commands/qc-plan.tmpl +0 -49
  68. package/commands/qc-report.md +0 -217
  69. package/commands/qc-report.tmpl +0 -60
  70. package/commands/qc-review.md +0 -210
  71. package/commands/qc-review.tmpl +0 -53
  72. package/commands/qc-run-test.md +0 -326
  73. package/commands/qc-run-test.tmpl +0 -116
  74. package/commands/refine-prd.md +0 -653
  75. package/commands/refine-prd.tmpl +0 -281
  76. package/commands/report-bug.md +0 -305
  77. package/commands/report-bug.tmpl +0 -148
  78. package/commands/review-code.md +0 -415
  79. package/commands/review-code.tmpl +0 -146
  80. package/commands/review-context.md +0 -902
  81. package/commands/review-context.tmpl +0 -530
  82. package/commands/review-tech-docs.md +0 -561
  83. package/commands/review-tech-docs.tmpl +0 -404
  84. package/commands/setup-ai-first.md +0 -602
  85. package/commands/setup-ai-first.tmpl +0 -450
  86. package/commands/sync.md +0 -430
  87. package/commands/sync.tmpl +0 -429
  88. package/commands/update-framework.md +0 -203
  89. package/commands/update-framework.tmpl +0 -202
  90. package/commands/validate-traces.md +0 -1077
  91. package/commands/validate-traces.tmpl +0 -920
  92. package/hooks/data-guard.js +0 -232
  93. package/hooks/settings.json +0 -19
  94. package/modules/android-compose/module.yaml +0 -13
  95. package/modules/android-compose/stack-profile.yaml +0 -57
  96. package/modules/angular/architecture-snippets/component-patterns.md +0 -187
  97. package/modules/angular/module.yaml +0 -6
  98. package/modules/angular/stack-profile.yaml +0 -38
  99. package/modules/context-engineering/architecture-snippets/context-design.md +0 -119
  100. package/modules/context-engineering/module.yaml +0 -9
  101. package/modules/context-engineering/stack-profile.yaml +0 -61
  102. package/modules/dotnet/architecture-snippets/clean-arch.md +0 -160
  103. package/modules/dotnet/module.yaml +0 -6
  104. package/modules/dotnet/stack-profile.yaml +0 -50
  105. package/modules/flutter/module.yaml +0 -14
  106. package/modules/flutter/stack-profile.yaml +0 -59
  107. package/modules/golang/architecture-snippets/domain-layout.md +0 -283
  108. package/modules/golang/module.yaml +0 -6
  109. package/modules/golang/stack-profile.yaml +0 -40
  110. package/modules/ios-swiftui/module.yaml +0 -13
  111. package/modules/ios-swiftui/stack-profile.yaml +0 -55
  112. package/modules/java-spring/architecture-snippets/layered-arch.md +0 -201
  113. package/modules/java-spring/module.yaml +0 -15
  114. package/modules/java-spring/stack-profile.yaml +0 -28
  115. package/modules/nextjs/architecture-snippets/app-router-patterns.md +0 -269
  116. package/modules/nextjs/module.yaml +0 -14
  117. package/modules/nextjs/stack-profile.yaml +0 -74
  118. package/modules/nuxt/module.yaml +0 -14
  119. package/modules/nuxt/stack-profile.yaml +0 -58
  120. package/modules/phaser-game/architecture-snippets/phaser-scene-patterns.md +0 -646
  121. package/modules/phaser-game/module.yaml +0 -15
  122. package/modules/phaser-game/stack-profile.yaml +0 -90
  123. package/modules/php-laravel/architecture-snippets/service-repository.md +0 -302
  124. package/modules/php-laravel/module.yaml +0 -15
  125. package/modules/php-laravel/stack-profile.yaml +0 -56
  126. package/modules/qc-playwright/stack-profile.yaml +0 -66
  127. package/modules/react/architecture-snippets/hooks-query-patterns.md +0 -254
  128. package/modules/react/module.yaml +0 -14
  129. package/modules/react/stack-profile.yaml +0 -63
  130. package/modules/react-native/module.yaml +0 -14
  131. package/modules/react-native/stack-profile.yaml +0 -56
  132. package/modules/vue/module.yaml +0 -14
  133. package/modules/vue/stack-profile.yaml +0 -65
  134. package/rules/data-protection.md +0 -80
  135. package/rules/workflow.md +0 -99
  136. package/skills/code/SKILL.md +0 -19
  137. package/skills/code/SKILL.tmpl +0 -19
  138. package/skills/debug/SKILL.md +0 -19
  139. package/skills/debug/SKILL.tmpl +0 -19
  140. package/skills/design-spec/SKILL.md +0 -11
  141. package/skills/design-spec/SKILL.tmpl +0 -11
  142. package/skills/discovery/SKILL.md +0 -14
  143. package/skills/discovery/SKILL.tmpl +0 -14
  144. package/skills/prd/SKILL.md +0 -19
  145. package/skills/prd/SKILL.tmpl +0 -19
  146. package/skills/qc/qa-analyst/DOC_GAPS.template.md +0 -63
  147. package/skills/qc/qa-analyst/acceptance-criteria.md +0 -60
  148. package/skills/qc/qa-analyst/business-rules.md +0 -59
  149. package/skills/qc/qa-analyst/data-flow.md +0 -64
  150. package/skills/qc/qa-analyst/spec-breakdown.md +0 -61
  151. package/skills/qc/qa-designer/e2e/journey.md +0 -41
  152. package/skills/qc/qa-designer/exploratory/charter.md +0 -68
  153. package/skills/qc/qa-designer/exploratory/explore-to-functional.md +0 -43
  154. package/skills/qc/qa-designer/functional/api.md +0 -45
  155. package/skills/qc/qa-designer/functional/gui-feature.md +0 -46
  156. package/skills/qc/qa-designer/functional/gui-screen.md +0 -52
  157. package/skills/qc/qa-designer/integration/api.md +0 -42
  158. package/skills/qc/qa-designer/integration/db.md +0 -39
  159. package/skills/qc/qa-designer/integration/gui.md +0 -40
  160. package/skills/qc/qa-designer/integration/kafka.md +0 -40
  161. package/skills/qc/qa-designer/non-functional.md +0 -40
  162. package/skills/qc/qa-planner/test-plan.md +0 -120
  163. package/skills/qc/qa-reviewer/script/e2e.md +0 -87
  164. package/skills/qc/qa-reviewer/script/exploratory.md +0 -45
  165. package/skills/qc/qa-reviewer/script/functional.md +0 -101
  166. package/skills/qc/qa-reviewer/script/integration.md +0 -91
  167. package/skills/qc/qa-reviewer/script/non-functional.md +0 -126
  168. package/skills/qc/qa-reviewer/test-case/e2e.md +0 -73
  169. package/skills/qc/qa-reviewer/test-case/exploratory.md +0 -43
  170. package/skills/qc/qa-reviewer/test-case/functional.md +0 -76
  171. package/skills/qc/qa-reviewer/test-case/integration.md +0 -69
  172. package/skills/qc/qa-reviewer/test-case/non-functional.md +0 -73
  173. package/skills/qc/qa-runner/e2e.md +0 -49
  174. package/skills/qc/qa-runner/exploratory/session.md +0 -36
  175. package/skills/qc/qa-runner/functional/api.md +0 -35
  176. package/skills/qc/qa-runner/functional/gui-feature.md +0 -51
  177. package/skills/qc/qa-runner/functional/gui-screen.md +0 -55
  178. package/skills/qc/qa-runner/integration.md +0 -47
  179. package/skills/qc/qa-runner/non-functional.md +0 -49
  180. package/skills/qc/qa-runner/report/report.md +0 -37
  181. package/skills/setup-ai-first/SKILL.md +0 -19
  182. package/skills/setup-ai-first/SKILL.tmpl +0 -19
  183. package/skills/spec/SKILL.md +0 -19
  184. package/skills/spec/SKILL.tmpl +0 -19
  185. package/skills/test/SKILL.md +0 -18
  186. package/skills/test/SKILL.tmpl +0 -18
  187. package/steps/business-language.md +0 -56
  188. package/steps/capture-lesson.md +0 -112
  189. package/steps/context-loader.md +0 -406
  190. package/steps/gate.md +0 -151
  191. package/steps/report-footer.md +0 -125
  192. package/steps/review-fanout.md +0 -159
  193. package/steps/spawn-agent.md +0 -129
  194. package/steps/trace-mirror.md +0 -53
  195. package/templates/README.md +0 -70
  196. package/templates/architecture.template.md +0 -394
  197. package/templates/ci/trace-gate.yml +0 -146
  198. package/templates/design-spec.template.md +0 -217
  199. package/templates/feature.template +0 -123
  200. package/templates/hooks/pre-push +0 -61
  201. package/templates/platform-guide.template.md +0 -145
  202. package/templates/prd.template.md +0 -283
  203. package/templates/product-definition.template.md +0 -188
  204. package/templates/project-context.yaml +0 -212
  205. package/templates/tech-design.template.md +0 -490
@@ -1,450 +0,0 @@
1
- # /setup-ai-first — Khởi tạo SDD Framework trong một dự án
2
-
3
- Dẫn người dùng qua một setup một-lần tạo mọi thư mục cần thiết, cài CLAUDE.md, và verify môi trường.
4
-
5
- ## Gate
6
- {{include:steps/gate.md}}
7
-
8
- *Lưu ý: Với lệnh này — **bỏ qua Gate Step 1, 2, và 3** (chưa có file input và chưa có project context). Chỉ chạy Step 0-B (model check). Project root là **thư mục làm việc hiện tại**. Đi thẳng tới Precondition Check bên dưới.*
9
-
10
- ---
11
-
12
- ## Precondition Check
13
-
14
- Kiểm tra đã setup chưa:
15
- - Nếu cả `CLAUDE.md` **và** `.agent/project-context.yaml` đều tồn tại → hỏi: "Dự án này đã được khởi tạo. Chạy lại setup để regenerate file config? (Y/N)"
16
- - N → dừng
17
- - Y → tiếp tục (file có sẵn được giữ — mỗi bước sẽ đề nghị merge/skip)
18
- - Nếu chỉ có `specs/` hoặc phát hiện setup một phần → tiếp tục bình thường (an toàn chạy lại)
19
-
20
- ## Step 0.5 — Loại dự án
21
-
22
- Hỏi người dùng:
23
-
24
- ```
25
- Dự án này thuộc loại nào?
26
- 1. Single-service — một codebase, một platform (setup chuẩn)
27
- 2. Umbrella repo — repo này chứa nhiều service submodule (microservices / multi-app)
28
- 3. PO Spec repo — chỉ docs, không có code chạy được (chỉ PRD + design-spec)
29
- ```
30
-
31
- Lưu câu trả lời thành `project_type`. Mặc định `1` nếu user không trả lời.
32
-
33
- Dựa trên câu trả lời:
34
-
35
- **project_type = 1 (Single-service):** Tiếp tục setup chuẩn bên dưới.
36
-
37
- **project_type = 2 (Umbrella):** Hỏi các câu follow-up:
38
- - "Path tới spec submodule (vd `free-trial-spec`)? Nhấn Enter để skip."
39
- - "Một business-domain được triển khai trên NHIỀU platform (BE + Web + App) không? (Y/N)"
40
- - **N → dạng phẳng (FORM A):** "Liệt kê service dạng cặp `domain:module`, ngăn cách bởi dấu phẩy
41
- (vd `user:java-spring,order:java-spring`). Nhấn Enter để skip."
42
- - **Y → dạng map-theo-platform (FORM B):** "Liệt kê dạng bộ ba `domain:platform:module`
43
- (platform ∈ system|web|app), ngăn cách bởi dấu phẩy — lặp lại domain cho từng platform
44
- (vd `onboarding:system:java-spring,onboarding:web:nextjs,onboarding:app:flutter`). Nhấn Enter để skip."
45
- context-loader route theo `@trace.platform` của target `.feature` → chọn đúng submodule.
46
- **Giữ `@trace.domain` là business-domain** (KHÔNG bịa `onboarding-web`).
47
- - "Có ô định tuyến nào ứng với NHIỀU repo không — tức cùng một domain (và cùng platform,
48
- nếu có) nhưng mỗi feature nằm ở một repo riêng? (vd mỗi mini-game webview một repo) (Y/N)"
49
- - **Y → dạng map-theo-prd_slug (FORM C):** "Liệt kê dạng `domain:platform:prd-slug:module`
50
- — bỏ trống đoạn platform nếu domain không chia platform (`domain::prd-slug:module`) —
51
- ngăn cách bởi dấu phẩy (vd
52
- `learning:webview:dap-chuot:phaser-game,learning:webview:ban-cung:phaser-game`).
53
- Nhấn Enter để skip."
54
- `prd-slug` là **tên thư mục feature-package** dưới `specs/{domain}/`, phải khớp chính xác.
55
- context-loader tra `@trace.platform` rồi tra tiếp `prd_slug` → chọn đúng repo.
56
- Không khớp slug nào thì lệnh DỪNG (`unresolved`) chứ không đoán repo gần giống.
57
-
58
- Rồi:
59
- - Skip tạo bất kỳ artifact `specs/` nào (mọi spec — PRD, BDD, tech-docs, design-spec — sống trong spec submodule theo bố cục feature-package `specs/{domain}/{prd-slug}/`)
60
- - Chỉ tạo: `.trace/`, `.agent/review/` ở cấp umbrella
61
- *(Trừ khi user yêu cầu rõ tạo cấu trúc đầy đủ)*
62
- - Sinh `.agent/project-context.yaml` ở umbrella mode với services (FORM A, B hoặc C — trộn được trong cùng một file) và spec_source đã cung cấp.
63
- **Sau khi sinh, MỞ file kiểm tra:** mỗi `services.{domain}.path` (hoặc `.{platform}.path`, hoặc `.by_prd_slug.{slug}.path`) phải trỏ **đúng tên thư mục submodule thật** — generator để placeholder `TODO-…` vì tên dir thường khác tên domain. Sửa cho khớp trước khi chạy lệnh generate.
64
- - Skip tạo `CLAUDE.md` root (umbrella không có một tech stack đơn) — nhưng nhắc mỗi submodule code cần overlay `{path}/CLAUDE.md` riêng (thiếu thì code-gen fallback về default + cờ ⚠️, có thể sai coding-standards).
65
- - Sau setup, nhắc: "Mở từng service submodule riêng trong Claude Code để cài framework/overlay ở đó nếu cần."
66
-
67
- **project_type = 3 (PO Spec repo):**
68
- - Tạo base dir: `specs/product-definition/`, `specs/domain-knowledge/`, `feedback/`, `.agent/review/`
69
- - Artifact theo từng feature (`specs/{domain}/{prd-slug}/{ {TICKET-ID}-{prd-slug}.md, bdd/, tech-docs/, design-spec/}`) được tạo on demand bởi các lệnh generate — ĐỪNG tạo trước
70
- - Skip: `.trace/` (theo service, sống cạnh code trong mỗi service submodule)
71
- - Sinh `CLAUDE.md` tối thiểu chỉ với §1 (project overview) và §7 (git conventions)
72
- - Hỏi người dùng: **"Liệt kê các business domain của bạn (vd auth, payment, loyalty):"** — lưu thành domain list cho `project-context.yaml` và nhắc PO các tên này phải được dùng nhất quán ở row `| **Domain** |` của bảng Metadata trong mọi PRD
73
- - Thông báo:
74
- - Lệnh cho PO repo: `/define-product`, `/generate-prd`, `/review-context`, `/generate-design-spec`
75
- - **Quan trọng cho handoff team dev:** Mọi PRD phải có row `| **Domain** | {domain} |` trong **bảng Metadata**. Team dev dùng nó để route BDD/code sinh ra tới đúng service submodule. Tên domain không nhất quán sẽ phá routing.
76
- - Bảng Metadata PRD (do `/generate-prd` điền sẵn theo template):
77
- ```
78
- | **Domain** | {domain} | ← phải khớp một key trong services config của team dev
79
- | **Ticket** | {TICKET-ID} |
80
- | **Status** | draft | approved |
81
- ```
82
-
83
- ## Step 1 — Tạo cấu trúc thư mục
84
-
85
- Tạo các thư mục này (skip nếu đã tồn tại):
86
-
87
- ```
88
- {project-root}/
89
- ├── specs/
90
- │ ├── product-definition/ ← Output của /define-product
91
- │ └── domain-knowledge/ ← business dictionary & domain context
92
- ├── .trace/ ← .trace/{domain}/{prd-slug}/{UC-ID}-{platform}.tsv
93
- └── .agent/
94
- └── review/
95
- ```
96
-
97
- **Bố cục feature-package** — artifact spec theo từng feature KHÔNG được tạo trước. Mỗi lệnh generate
98
- tự tạo folder của nó on demand dưới `specs/{domain}/{prd-slug}/`:
99
-
100
- ```
101
- specs/{domain}/{prd-slug}/
102
- ├── {TICKET-ID}-{prd-slug}.md ← /generate-prd (vd SEG01-segment-scoring-service.md)
103
- ├── bdd/ ← /generate-bdd (file .feature)
104
- ├── tech-docs/ ← /generate-tech-docs
105
- └── design-spec/ ← /generate-design-spec (chỉ platform FE/App)
106
- ```
107
-
108
- *Tạo base dir nào tuỳ theo `project_type` set ở Step 0.5:*
109
-
110
- | project_type | Tạo | Skip |
111
- |---|---|---|
112
- | **1 — Single-service** | Cấu trúc base ở trên (`specs/product-definition/`, `specs/domain-knowledge/`, `.trace/`, `.agent/review/`) | folder theo feature (tạo on demand) |
113
- | **2 — Umbrella** | Chỉ `.trace/` + `.agent/review/` (ở umbrella root) | Mọi thứ khác — **toàn bộ spec sống trong spec submodule (`spec_source`)** dưới `specs/{domain}/{prd-slug}/`; service submodule chỉ chứa **code + `.trace/`** |
114
- | **3 — PO Spec repo** | `specs/product-definition/`, `specs/domain-knowledge/`, **`feedback/`**, `.agent/review/` (folder `specs/{domain}/{prd-slug}/` theo feature tạo on demand) | `.trace/` (theo service, sống cạnh code trong mỗi service submodule) |
115
-
116
- ### Step 1b — Luật merge cho sổ trace *(mọi project_type có tạo `.trace/`)*
117
-
118
- Ngay khi tạo `.trace/`, tạo luôn `.trace/.gitattributes`:
119
-
120
- ```gitattributes
121
- # Sổ trace — dữ liệu KHÔNG regenerate được. Hai luật, hai lý do khác nhau:
122
- #
123
- # merge=union — giữ row của CẢ HAI nhánh thay vì bắt người chọn một bên. Trùng sc_id sau
124
- # union là ca ĐÚNG VÀ ĐƯỢC MONG ĐỢI: `--lint-trace` T4 bắt nó, rồi /validate-traces
125
- # reconcile về một row. Mất row thì KHÔNG có gì bắt được. Đánh đổi có chủ ý — đừng "dọn".
126
- # (union là driver built-in của git: không ai cần chạy git config gì thêm.)
127
- #
128
- # text eol=lf — BẮT BUỘC đi kèm union. Thiếu nó: một máy ghi CRLF → git thấy MỌI dòng đã
129
- # đổi → union giữ cả hai bản → NHÂN ĐÔI CẢ FILE, gồm cả dòng header.
130
- #
131
- # KHÔNG thêm *.json — trace-report.json nằm cùng thư mục và union trên JSON tạo ra JSON
132
- # không hợp lệ. Nó sinh lại được: conflict thì chạy lại /validate-traces.
133
- *.tsv text eol=lf merge=union
134
- *.jsonl text eol=lf merge=union
135
- ```
136
-
137
- **Vì sao làm ở đây, ngay lúc tạo thư mục:** sổ trace phải commit và được nhiều người ghi trên
138
- nhiều nhánh song song. Không có luật này, lần merge song song đầu tiên sẽ conflict — và giải
139
- conflict bằng "take mine" là **mất row của người kia, im lặng**. Đây là ca **chắc chắn xảy ra**
140
- với team ≥3 người và không cần ai làm sai gì cả.
141
-
142
- *Project đã cài từ trước → `/sync` Step 4c kiểm và tạo hộ.*
143
-
144
- ## Step 2 — Tạo CLAUDE.md
145
-
146
- *Bỏ qua hoàn toàn step này nếu `project_type = 2` (Umbrella) — umbrella không có một tech stack đơn.*
147
- *Với `project_type = 3` (PO Spec repo) — tạo CLAUDE.md tối thiểu chỉ với §1 (project overview) và §7 (git conventions). Skip §2–§6.*
148
-
149
- Kiểm tra `CLAUDE.md` tồn tại chưa:
150
- - Có → hỏi "Merge template hay skip?"
151
- - Không → tạo từ template bên dưới
152
-
153
- Sau khi tạo, hướng dẫn: "Mở CLAUDE.md và điền các giá trị `{{PLACEHOLDER}}` bằng thông tin dự án của bạn."
154
-
155
- ### CLAUDE.md Template
156
-
157
- ```
158
- # §1. Project Overview
159
- Project: {{PROJECT_NAME}}
160
- Language: {{LANGUAGE}}
161
- Framework: {{FRAMEWORK}}
162
- Build: {{BUILD_COMMAND}}
163
- Test: {{TEST_COMMAND}}
164
- Domains: {{COMMA_SEPARATED_DOMAINS}}
165
-
166
- # §2. Architecture
167
- layers: "{{LAYER_STACK}}"
168
- # Example: Controller → Facade → Service → Repository
169
- rules:
170
- - "Controllers must not contain business logic"
171
- - "Services own transaction boundaries"
172
-
173
- # §3. Coding Standards
174
- naming:
175
- classes: "{{NAMING_CONVENTION}}"
176
- methods: "{{METHOD_CONVENTION}}"
177
- response_wrapper: "{{WRAPPER}}"
178
- forbidden:
179
- - "Magic numbers"
180
- - "Debug print statements"
181
-
182
- # §4. Traceability
183
- # Every entry-point method must carry the FULL block (repeat it per UC in a
184
- # multi-UC file — the version tags are per-UC scalars, never merge them):
185
- # @trace.implements={UC-ID}-SC{N}
186
- # @trace.prd_version={PRD version} / @trace.bdd_version={BDD version} / @trace.tech_doc_revision={n}
187
- # @trace.source=specs/{domain}/{prd-slug}/bdd/{platform}/{UC-ID}-{slug}.feature
188
- # ({platform} = web|app|system · adjust the root if specs_dir differs in .agent/project-context.yaml)
189
- # Tests must be tagged:
190
- # @trace.verifies={UC-ID}-SC{N}
191
-
192
- # §5. Error Handling
193
- not_found: "{{NOT_FOUND_EXCEPTION}}"
194
- http_codes: { get: 200, create: 201, not_found: 404, validation: 400 }
195
-
196
- # §6. Build & Test
197
- build_command: "{{BUILD_COMMAND}}"
198
- test_command: "{{TEST_COMMAND}}"
199
- run_command: "{{RUN_COMMAND}}"
200
-
201
- # §7. Git Conventions
202
- branch_feature: "feature/{{TICKET_PREFIX}}-{N}-{slug}"
203
- commit_feature: "feat({{TICKET_PREFIX}}-{N}): {description}"
204
- ```
205
-
206
- ## Step 3 — Tạo project-context.yaml
207
-
208
- *Với `project_type = 2` (Umbrella):*
209
- - *Nếu `.agent/project-context.yaml` đã được sinh bởi `--init --umbrella` → mở nó và verify/sửa section `services` (domain key, path, module). Skip copy template bên dưới.*
210
- - *Nếu chưa sinh → hỏi: "Path spec submodule?" và "Services (cặp domain:module)?" rồi sinh config umbrella (xem Step 0.5 cho format).*
211
-
212
- Tạo `.agent/project-context.yaml` dùng `.agent/templates/project-context.yaml` làm template nguồn.
213
-
214
- Copy template và hướng dẫn: "Mở `.agent/project-context.yaml` và điền mọi giá trị `{{PLACEHOLDER}}`. Section `paths` đã được cấu hình sẵn với default hợp lý — chỉnh nếu dự án dùng tên thư mục khác."
215
-
216
- ## Step 4 — Tạo business-dictionary.md
217
-
218
- *Skip Step 4 và 5 nếu `project_type = 2` (Umbrella) — business dictionary và core entities sống trong spec submodule và do team PO quản lý. Team dev đọc chúng từ `{spec_source}/specs/domain-knowledge/`.*
219
-
220
-
221
- Tạo `specs/domain-knowledge/business-dictionary.md` nếu chưa tồn tại:
222
-
223
- ```markdown
224
- # Business Dictionary — {{PROJECT_NAME}}
225
-
226
- > Thuật ngữ chuẩn cho dự án này. Mọi PRD, BDD spec, và code phải theo các thuật ngữ này.
227
- > Managed by: PO / SA team.
228
-
229
- ## Canonical Terms
230
-
231
- | Canonical Term | Description / Context |
232
- |----------------|----------------------|
233
- | {Term} | {Short description, usage scope} |
234
-
235
- ## Banned Terms
236
-
237
- | ❌ Do NOT use | ✅ Use instead | Reason |
238
- |---------------|-------------------|--------|
239
- | {banned} | {canonical} | {why} |
240
-
241
- ## Status / Enum Registry
242
-
243
- | Entity | Field | Allowed Values |
244
- |--------|---------|--------------------|
245
- | {Entity} | status | {value1, value2} |
246
- ```
247
-
248
- Hướng dẫn: "Mở `specs/domain-knowledge/business-dictionary.md` và thêm thuật ngữ dự án của bạn. File này sẽ được mọi lệnh đọc để enforce naming nhất quán."
249
-
250
- ## Step 5 — Tạo core-entities.md
251
-
252
- Tạo `specs/domain-knowledge/core-entities.md` nếu chưa tồn tại:
253
-
254
- ```markdown
255
- # Core Entities — {{PROJECT_NAME}}
256
-
257
- > Glossary entity máy-đọc-được cho phát triển có AI hỗ trợ.
258
- > Được mọi lệnh nạp để AI biết domain model của bạn mà không cần đọc source code.
259
- > Managed by: Tech Lead / Architect.
260
- >
261
- > HOW TO USE:
262
- > - Add one `## Entity: {Name}` section per domain entity (aggregate root, value object, etc.)
263
- > - Keep field descriptions concise — this is a REFERENCE, not API docs
264
- > - Update this file whenever you add/rename fields or change business invariants
265
-
266
- ---
267
-
268
- ## Entity: {EntityName}
269
-
270
- **Purpose**: {1-2 sentences — what this entity represents and why it exists in the domain}
271
- **Domain**: {domain}
272
- **Storage**: {e.g., `orders` table in PostgreSQL | `orders` collection in MongoDB}
273
- **Owner service**: {service/module that owns this entity}
274
-
275
- | Field | Type | Nullable | Description |
276
- |--------------|---------|----------|-------------------------------------|
277
- | id | UUID | No | Primary key |
278
- | {field_name} | {type} | Yes/No | {short description} |
279
- | status | Enum | No | See Status Registry in business-dictionary.md |
280
-
281
- **Business invariants:**
282
- - {Rule 1: e.g., "status can only transition: PENDING → ACTIVE → CLOSED"}
283
- - {Rule 2: e.g., "total must equal sum of line items"}
284
-
285
- **Relationships:**
286
- - `{EntityA}` 1:N `{EntityB}` — {one sentence description}
287
- - `{EntityA}` N:N `{EntityC}` via `{junction_table}` — {description}
288
-
289
- ---
290
-
291
- ## Entity: {AnotherEntity}
292
-
293
- *(Add more entities following the same pattern above)*
294
- ```
295
-
296
- Hướng dẫn: "Mở `specs/domain-knowledge/core-entities.md` và định nghĩa các domain entity chính. Bắt đầu với aggregate root. File này được mọi lệnh AI nạp — định nghĩa tốt ở đây tiết kiệm đáng kể qua-lại khi sinh code."
297
-
298
- ## Step 6 — Cài VS Code Extension (Khuyến nghị)
299
-
300
- Khuyến nghị user cài extension VS Code **Spec Driven Docs Tools** — nó cung cấp panel Review Board + Living Documentation tích hợp với workflow này.
301
-
302
- ```bash
303
- code --install-extension SpecDrivenDocsTools.spec-driven-docs-tool
304
- ```
305
-
306
- Hoặc: VS Code → `Ctrl+Shift+P` → **"Extensions: Install from Marketplace"** → tìm **Spec Driven Docs Tools**.
307
-
308
- **Nó làm gì:**
309
- - 📋 **Review Board** — UI trực quan để review findings từ `/refine-prd`, `/review-context`, `/review-tech-docs`
310
- - 📊 **Living Documentation** — dashboard traceability dựa trên `.trace/*.tsv`
311
-
312
- ## Step 6b — Cổng chặn bằng máy (Khuyến nghị mạnh)
313
-
314
- *Skip nếu `project_type = 3` (PO Spec repo) — không có code thì không có PR cần chặn.*
315
-
316
- Framework phát hiện được một lớp lỗi mà **build xanh + test từng-UC xanh KHÔNG thấy**: luồng
317
- ghép chạy vào hàm rỗng (`SEAM_UNWIRED`, `STUB_UNRESOLVED`), hoặc code trỏ vào scenario đã bị
318
- xoá (`ORPHANED`, `TRACE_ORPHAN`). Nhưng nếu việc phát hiện đó phụ thuộc vào **có người tự
319
- nguyện chạy `/validate-traces` rồi đọc report bằng mắt**, thì sau sprint thứ ba không ai làm.
320
-
321
- Hai file mẫu đã có sẵn. Hỏi user muốn cài cái nào:
322
-
323
- ```
324
- Cài cổng chặn bằng máy? (khuyến nghị cả hai)
325
- 1. pre-push hook — chặn push khi sổ trace hỏng cấu trúc. Rẻ, 2 giây, offline được.
326
- Bắt được marker conflict git trước khi nó vào nhánh chung.
327
- 2. CI workflow — chặn PR khi có cờ 🔴. Cần GitHub Actions.
328
- 3. Cả hai (khuyến nghị)
329
- 4. Bỏ qua, cài sau
330
- ```
331
-
332
- **Chọn 1 hoặc 3** — copy hook rồi cấp quyền chạy:
333
- ```bash
334
- cp .agent/templates/hooks/pre-push .git/hooks/pre-push && chmod +x .git/hooks/pre-push
335
- ```
336
- *Nếu `trace_dir` của project không phải `.trace` (vd `../.trace` hay `{spec_source}/.trace`) →
337
- mở file vừa copy và sửa biến `TRACE_DIR` ở đầu file cho khớp.*
338
-
339
- **Chọn 2 hoặc 3** — copy workflow:
340
- ```bash
341
- mkdir -p .github/workflows && cp .agent/templates/ci/trace-gate.yml .github/workflows/
342
- ```
343
- *Rồi mở nó ra: sửa `src/**` ở job `require-fresh-audit` cho khớp layout project, và bỏ comment
344
- `submodules: recursive` nếu spec/trace nằm trong submodule.*
345
-
346
- > **Phải COPY RA khỏi `.agent/`** — `.agent/` bị ghi đè mỗi lần `/update-framework`, và
347
- > `.git/hooks/` thì git không chạy từ chỗ khác. Copy ra rồi thì chúng là file của project.
348
-
349
- Kiểm ngay sau khi cài (chưa có sổ trace thì cả hai thoát sạch, không phải lỗi):
350
- ```bash
351
- npx @educa-corp/sdd-framework --lint-trace
352
- ```
353
-
354
- Chi tiết + giới hạn của cổng → `docs/03-guides/architect.md` §Cắm vào CI.
355
-
356
- ## Step 7 — Verify
357
-
358
- Checklist tuỳ theo `project_type`:
359
-
360
- **project_type = 1 (Single-service):**
361
- - [ ] `specs/` tồn tại
362
- - [ ] `specs/product-definition/` tồn tại
363
- - [ ] `specs/domain-knowledge/` tồn tại
364
- - [ ] `.trace/` tồn tại
365
- *(folder `specs/{domain}/{prd-slug}/` theo feature tạo on demand — không check ở đây)*
366
- - [ ] `.agent/project-context.yaml` tồn tại
367
- - [ ] `CLAUDE.md` tồn tại
368
- - [ ] `specs/domain-knowledge/business-dictionary.md` tồn tại
369
- - [ ] `specs/domain-knowledge/core-entities.md` tồn tại
370
-
371
- **project_type = 2 (Umbrella):**
372
- - [ ] `.agent/project-context.yaml` tồn tại với `setup.mode: umbrella`
373
- - [ ] Section `services` có ít nhất một entry với đúng domain key
374
- - [ ] Path `spec_source` tồn tại (vd thư mục `my-project-specs/` có mặt)
375
- - [ ] `.agent/review/` tồn tại
376
- - [ ] Spec submodule đã init: `git submodule status` không hiện prefix `-`
377
-
378
- **project_type = 3 (PO Spec repo):**
379
- - [ ] `specs/product-definition/` tồn tại
380
- - [ ] `specs/domain-knowledge/` tồn tại
381
- - [ ] `feedback/` tồn tại
382
- *(folder `specs/{domain}/{prd-slug}/` theo feature tạo on demand — không check ở đây)*
383
- - [ ] `.agent/review/` tồn tại
384
- - [ ] `.agent/project-context.yaml` tồn tại
385
- - [ ] `CLAUDE.md` tồn tại (tối thiểu)
386
- - [ ] `specs/domain-knowledge/business-dictionary.md` tồn tại
387
- - [ ] `specs/domain-knowledge/core-entities.md` tồn tại
388
-
389
- ## Output
390
-
391
- {{include:steps/report-footer.md}}
392
-
393
- ```
394
- /setup-ai-first Hoàn tất ✅
395
- ```
396
-
397
- Output tuỳ theo `project_type`:
398
-
399
- **Single-service:**
400
- ```
401
- Next:
402
- 1. Điền CLAUDE.md (thay các giá trị {{PLACEHOLDER}})
403
- 2. Điền .agent/project-context.yaml
404
- 3. Điền specs/domain-knowledge/business-dictionary.md
405
- 4. Điền specs/domain-knowledge/core-entities.md
406
- 5. git add và commit 4 file đó
407
- 6. Cài VS Code extension:
408
- code --install-extension SpecDrivenDocsTools.spec-driven-docs-tool
409
- 7. /define-product để bắt đầu feature đầu tiên
410
- ```
411
-
412
- **Umbrella:**
413
- ```
414
- Next:
415
- 1. Review .agent/project-context.yaml:
416
- - Cập nhật services[].path khớp tên thư mục submodule thực tế
417
- - Cập nhật domain key của services khớp row `Domain` (bảng Metadata) trong các file PRD
418
- - Xác nhận path spec_source đúng
419
-
420
- 2. Chạy /sync — một lệnh lo mọi thứ còn lại:
421
- /sync
422
- → git pull + submodule init + spec submodule update
423
- → Tự tạo .agent/project-context.yaml cho mỗi service submodule
424
- (phát hiện module từ pom.xml / go.mod / package.json / pubspec.yaml v.v.)
425
- → Sync Living Docs panel
426
- → Refresh spec-manifest.yaml
427
-
428
- 3. Bắt đầu sinh:
429
- /generate-bdd {spec_source}/specs/{domain}/{prd-slug}/{TICKET-ID}-{prd-slug}.md
430
- ```
431
-
432
- **PO Spec repo:**
433
- ```
434
- Next:
435
- 1. Điền .agent/project-context.yaml:
436
- - domains: [liệt kê mọi business domain — chúng thành row `Domain` (bảng Metadata) trong PRD]
437
- - project.name, project.description
438
- 2. Điền specs/domain-knowledge/business-dictionary.md ← canonical terms
439
- 3. Điền specs/domain-knowledge/core-entities.md ← entity glossary
440
- 4. git add và commit các file đó
441
- 5. Cài VS Code extension:
442
- code --install-extension SpecDrivenDocsTools.spec-driven-docs-tool
443
- 6. /define-product để bắt đầu feature đầu tiên
444
-
445
- ⚠️ Nhắc handoff team dev:
446
- - Mỗi PRD phải có row `Domain` (bảng Metadata) khớp một trong domains list của bạn
447
- - Khi team dev setup umbrella repo của họ, họ map các tên domain này
448
- tới path service submodule trong section services của project-context.yaml
449
- - Chia sẻ tên domain với team dev trước khi họ cấu hình umbrella
450
- ```