@educa-corp/sdd-framework 0.2.4 → 0.2.6

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/commands/generate-architecture.md +706 -0
  2. package/commands/generate-architecture.tmpl +194 -0
  3. package/commands/generate-code.md +35 -9
  4. package/commands/generate-code.tmpl +35 -9
  5. package/commands/generate-tech-docs.md +259 -246
  6. package/commands/generate-tech-docs.tmpl +21 -0
  7. package/core/FRAMEWORK_VERSION +1 -1
  8. package/core/commands/generate-architecture.md +706 -0
  9. package/core/commands/generate-code.md +35 -9
  10. package/core/commands/generate-tech-docs.md +259 -246
  11. package/core/skills/setup-ai-first/SKILL.md +12 -4
  12. package/core/templates/architecture.template.md +392 -111
  13. package/core/templates/tech-design.template.md +238 -246
  14. package/docs/01-getting-started/installation.md +47 -112
  15. package/docs/01-getting-started/quickstart.md +58 -72
  16. package/docs/01-getting-started/what-is-sdd.md +75 -0
  17. package/docs/02-concepts/architecture.md +109 -0
  18. package/docs/02-concepts/glossary.md +87 -0
  19. package/docs/02-concepts/overview.md +93 -0
  20. package/docs/02-concepts/pipeline-steps/00-setup.md +102 -0
  21. package/docs/02-concepts/pipeline-steps/01-discovery.md +129 -0
  22. package/docs/02-concepts/pipeline-steps/02-specification.md +130 -0
  23. package/docs/02-concepts/pipeline-steps/03-design-spec.md +90 -0
  24. package/docs/02-concepts/pipeline-steps/04-bdd.md +120 -0
  25. package/docs/02-concepts/pipeline-steps/05-tech-docs.md +101 -0
  26. package/docs/02-concepts/pipeline-steps/06-code.md +119 -0
  27. package/docs/02-concepts/pipeline-steps/07-dev-selftest.md +92 -0
  28. package/docs/02-concepts/pipeline-steps/08-qc-automation.md +102 -0
  29. package/docs/02-concepts/pipeline-steps/09-validate-traces.md +104 -0
  30. package/docs/02-concepts/pipeline-steps/10-feedback-loop.md +105 -0
  31. package/docs/02-concepts/pipeline-steps/README.md +92 -0
  32. package/docs/02-concepts/roles-and-hitl.md +73 -0
  33. package/docs/02-concepts/traceability.md +94 -0
  34. package/docs/03-guides/architect.md +98 -0
  35. package/docs/03-guides/developer.md +76 -0
  36. package/docs/03-guides/product-owner.md +68 -0
  37. package/docs/03-guides/tester-qa.md +70 -0
  38. package/docs/04-reference/commands.md +105 -0
  39. package/docs/04-reference/configuration.md +94 -0
  40. package/docs/04-reference/model-selection.md +68 -0
  41. package/docs/04-reference/modules.md +74 -0
  42. package/docs/04-reference/trace-schema.md +93 -0
  43. package/docs/README.md +29 -40
  44. package/docs/explain/00-setup-ai-first.md +77 -0
  45. package/docs/explain/00b-generate-architecture.md +76 -0
  46. package/docs/explain/01-define-product.md +79 -0
  47. package/docs/explain/02-generate-prd.md +78 -0
  48. package/docs/explain/03-refine-prd.md +86 -0
  49. package/docs/explain/04-review-context.md +100 -0
  50. package/docs/explain/05-generate-design-spec.md +73 -0
  51. package/docs/explain/06-generate-bdd.md +77 -0
  52. package/docs/explain/07-generate-tech-docs.md +71 -0
  53. package/docs/explain/08-review-tech-docs.md +79 -0
  54. package/docs/explain/09-generate-code.md +78 -0
  55. package/docs/explain/10-review-code.md +70 -0
  56. package/docs/explain/11-map-testids.md +69 -0
  57. package/docs/explain/12-dev-gen-test.md +66 -0
  58. package/docs/explain/13-dev-run-test.md +69 -0
  59. package/docs/explain/14-dev-smoke-test.md +67 -0
  60. package/docs/explain/15-qc-analyze.md +68 -0
  61. package/docs/explain/16-qc-plan.md +61 -0
  62. package/docs/explain/17-qc-design-test.md +61 -0
  63. package/docs/explain/18-qc-review.md +59 -0
  64. package/docs/explain/19-qc-run-test.md +67 -0
  65. package/docs/explain/20-qc-report.md +61 -0
  66. package/docs/explain/21-validate-traces.md +68 -0
  67. package/docs/explain/22-generate-spec-manifest.md +60 -0
  68. package/docs/explain/23-fix-bug.md +69 -0
  69. package/docs/explain/24-debug.md +61 -0
  70. package/docs/explain/25-report-bug.md +65 -0
  71. package/docs/explain/26-propose-scenario.md +63 -0
  72. package/docs/explain/27-learn.md +65 -0
  73. package/docs/explain/28-sync.md +70 -0
  74. package/docs/explain/29-update-framework.md +65 -0
  75. package/docs/explain/README.md +134 -0
  76. package/package.json +1 -1
  77. package/skills/setup-ai-first/SKILL.md +12 -4
  78. package/skills/setup-ai-first/SKILL.tmpl +12 -4
  79. package/templates/architecture.template.md +392 -111
  80. package/templates/tech-design.template.md +238 -246
  81. package/docs/01-getting-started/README.md +0 -19
  82. package/docs/01-getting-started/core-concepts.md +0 -102
  83. package/docs/02-guides/README.md +0 -26
  84. package/docs/02-guides/bdd-input-checklist.md +0 -68
  85. package/docs/02-guides/developer/README.md +0 -49
  86. package/docs/02-guides/developer/bdd-and-trace.md +0 -126
  87. package/docs/02-guides/developer/commands.md +0 -76
  88. package/docs/02-guides/developer/pr-checklist.md +0 -16
  89. package/docs/02-guides/developer/scenarios.md +0 -460
  90. package/docs/02-guides/developer/workflow.md +0 -121
  91. package/docs/02-guides/prd-input-checklist.md +0 -94
  92. package/docs/02-guides/product-owner/README.md +0 -81
  93. package/docs/02-guides/product-owner/commands.md +0 -30
  94. package/docs/02-guides/product-owner/handoff-checklist.md +0 -42
  95. package/docs/02-guides/product-owner/prd-writing-rules.md +0 -45
  96. package/docs/02-guides/product-owner/scenarios.md +0 -438
  97. package/docs/02-guides/tech-docs-input-checklist.md +0 -109
  98. package/docs/02-guides/tester/README.md +0 -75
  99. package/docs/02-guides/tester/bug-reporting.md +0 -117
  100. package/docs/02-guides/tester/qc-automation.md +0 -165
  101. package/docs/02-guides/tester/reading-specs.md +0 -79
  102. package/docs/02-guides/tester/scenarios.md +0 -186
  103. package/docs/02-guides/tester/spec-manifest.md +0 -130
  104. package/docs/02-guides/tester/test-checklist.md +0 -31
  105. package/docs/02-guides/tester/workflow.md +0 -77
  106. package/docs/03-concepts/README.md +0 -20
  107. package/docs/03-concepts/architecture.md +0 -248
  108. package/docs/03-concepts/mechanisms-explained.md +0 -124
  109. package/docs/03-concepts/pipeline.md +0 -278
  110. package/docs/03-concepts/traceability.md +0 -152
  111. package/docs/04-operations/README.md +0 -33
  112. package/docs/04-operations/bug-flow.md +0 -364
  113. package/docs/04-operations/publishing.md +0 -154
  114. package/docs/04-operations/sync-and-update.md +0 -522
  115. package/docs/05-reference/README.md +0 -34
  116. package/docs/05-reference/command-cheatsheet.md +0 -147
  117. package/docs/05-reference/commands.md +0 -234
  118. package/docs/05-reference/model-selection.md +0 -74
  119. package/docs/05-reference/modules.md +0 -110
  120. package/docs/05-reference/trace-schema.md +0 -154
  121. package/docs/06-commands/README.md +0 -75
  122. package/docs/06-commands/explain-debug.md +0 -32
  123. package/docs/06-commands/explain-define-product.md +0 -43
  124. package/docs/06-commands/explain-dev-gen-test.md +0 -28
  125. package/docs/06-commands/explain-dev-run-test.md +0 -24
  126. package/docs/06-commands/explain-dev-smoke-test.md +0 -25
  127. package/docs/06-commands/explain-fix-bug.md +0 -28
  128. package/docs/06-commands/explain-generate-bdd.md +0 -45
  129. package/docs/06-commands/explain-generate-code.md +0 -53
  130. package/docs/06-commands/explain-generate-design-spec.md +0 -54
  131. package/docs/06-commands/explain-generate-prd.md +0 -45
  132. package/docs/06-commands/explain-generate-spec-manifest.md +0 -20
  133. package/docs/06-commands/explain-generate-tech-docs.md +0 -56
  134. package/docs/06-commands/explain-learn.md +0 -21
  135. package/docs/06-commands/explain-map-testids.md +0 -28
  136. package/docs/06-commands/explain-propose-scenario.md +0 -24
  137. package/docs/06-commands/explain-qc-analyze.md +0 -22
  138. package/docs/06-commands/explain-qc-design-test.md +0 -20
  139. package/docs/06-commands/explain-qc-plan.md +0 -21
  140. package/docs/06-commands/explain-qc-report.md +0 -23
  141. package/docs/06-commands/explain-qc-review.md +0 -24
  142. package/docs/06-commands/explain-qc-run-test.md +0 -27
  143. package/docs/06-commands/explain-refine-prd.md +0 -51
  144. package/docs/06-commands/explain-report-bug.md +0 -24
  145. package/docs/06-commands/explain-review-code.md +0 -45
  146. package/docs/06-commands/explain-review-context.md +0 -68
  147. package/docs/06-commands/explain-review-tech-docs.md +0 -45
  148. package/docs/06-commands/explain-setup-ai-first.md +0 -25
  149. package/docs/06-commands/explain-sync.md +0 -24
  150. package/docs/06-commands/explain-update-framework.md +0 -22
  151. package/docs/06-commands/explain-validate-traces.md +0 -25
  152. package/docs/t-sample.md +0 -826
@@ -1,248 +0,0 @@
1
- [📚 Docs](../README.md) › [Concepts](README.md) › Architecture
2
-
3
- # Architecture
4
-
5
- > **Nguyên tắc**: Đọc file này để hiểu toàn bộ framework trước khi đọc bất kỳ file chi tiết nào.
6
-
7
- Cách framework được xây dựng: 6 lớp runtime, build pipeline `*.tmpl → *.md → core/`, module plug-in system, hook data-protection, và sub-agent orchestration.
8
-
9
- ## Mục lục
10
-
11
- - [Layer diagram (L0 → L5)](#layer-diagram-l0--l5)
12
- - [Data flow — một command chạy như thế nào](#data-flow--một-command-chạy-như-thế-nào)
13
- - [Build system](#build-system)
14
- - [Module plug-in system](#module-plug-in-system)
15
- - [Hook system — data protection](#hook-system--data-protection)
16
- - [Sub-agent orchestration](#sub-agent-orchestration)
17
- - [Directory map](#directory-map)
18
- - [Maintenance guide](#maintenance-guide)
19
-
20
- ---
21
-
22
- ## Layer diagram (L0 → L5)
23
-
24
- Mỗi command chạy qua 6 lớp, từ bảo vệ dữ liệu đến sinh artifact:
25
-
26
- ```
27
- LAYER 0 — PROTECTION (luôn chạy trước)
28
- hooks/data-guard.js → PreToolUse hook: chặn đọc file nhạy cảm
29
- rules/data-protection.md → quy tắc declarative cho AI agent
30
- │ safe ↓ blocked → ✋ STOP
31
- LAYER 1 — ENTRY POINT (user trigger)
32
- commands/*.tmpl (slash commands: /generate-bdd, /generate-code, …)
33
- skills/*/SKILL.tmpl (auto-trigger theo description match)
34
- │ cả hai build bởi bin/build.js
35
- LAYER 2 — SHARED STEPS (DRY, injected)
36
- steps/gate.md → resolve target file + CHECKPOINT
37
- steps/context-loader.md → load project config + rules
38
- steps/report-footer.md → standard output format
39
- Injected ở build time qua {{include:steps/X.md}} (*.tmpl → *.md, gitignored)
40
- │ context loaded
41
- LAYER 3 — PROJECT CONTEXT (đọc từ consumer project)
42
- .agent/project-context.yaml → paths, tech_stack, domains
43
- CLAUDE.md (root) → umbrella-wide shared rules (base layer)
44
- {service_root}/CLAUDE.md → service architecture + coding standards (overlay, wins)
45
- rules/data-protection.md → AI không được đọc gì
46
- .agent/modules/{stack}/ → stack rules (plug-in, optional)
47
- │ context-aware
48
- LAYER 4 — EXECUTION (command logic)
49
- Discovery /define-product
50
- PRD / BDD /generate-prd · /refine-prd · /generate-bdd · /generate-tech-docs
51
- Code /generate-code · /review-code
52
- Dev check /dev-gen-test · /dev-run-test · /dev-smoke-test → set dev_selftest
53
- QC suite /qc-analyze → /qc-plan → /qc-design-test → /qc-review →
54
- /qc-run-test → /qc-report → set qc_status
55
- Trace/Debug /validate-traces · /fix-bug · /debug
56
-
57
- LAYER 5 — OUTPUT (artifacts in consumer proj)
58
- Spec module (cross-team, via {spec_source}):
59
- specs/product-definition/
60
- specs/{domain}/{prd-slug}/ — feature package gom mọi artifact của một PRD:
61
- {TICKET-ID}-{prd-slug}.md · bdd/ (web/app/system) · tech-docs/ (1 doc full-stack/PRD: API contract + client design) · design-spec/
62
- feedback/
63
- .trace/{domain}/{prd-slug}/*.tsv (authoritative, committed — một chỗ cho PM) · .living-docs/ (gitignored)
64
- Service submodule (per-service):
65
- src/ (chỉ code) · .agent/review/
66
- QC automation outputs:
67
- QC test cases / scripts (Python pytest-playwright, Page Object)
68
- → QC analysis / test-cases ghi vào {qc_dir}/{UC-ID}/ (mặc định docs/,
69
- visible — KHÔNG nằm trong .agent/)
70
- → guides per-layer ở skills/qc/<stage>/ · qc_status trong .trace/*.tsv
71
- ```
72
-
73
- > **Dev self-check vs QC chính thức:** `/dev-*` set `dev_selftest` (smoke, dev tự kiểm code của mình); 6 lệnh `/qc-*` là QC automation pipeline CHÍNH THỨC (port từ agent của team QC; QC repo nay chỉ còn reference) → set `qc_status`. Hai tín hiệu **orthogonal**, cả hai surface trong Living Docs. Chi tiết: [traceability.md](traceability.md).
74
-
75
- ---
76
-
77
- ## Data flow — một command chạy như thế nào
78
-
79
- Ví dụ `/generate-bdd specs/payment/process-payment/{TICKET-ID}-process-payment.md`:
80
-
81
- ```
82
- User types: /generate-bdd specs/payment/process-payment/{TICKET-ID}-process-payment.md
83
-
84
- [L0] data-guard.js check tool calls real-time → đọc .env/*.key → BLOCK + warn
85
-
86
- [L1] commands/generate-bdd.md (assembled từ .tmpl + injected steps) được Claude đọc
87
-
88
- [L2] gate.md → resolve file path từ $ARGUMENTS
89
- context-loader.md → đọc project-context.yaml, CLAUDE.md,
90
- rules/data-protection.md, modules/{stack}/stack-profile.yaml
91
-
92
- [L3] Claude biết: tech_stack, domains, architecture rules, sensitive files, stack patterns
93
-
94
- [L4] generate-bdd logic: đọc PRD → extract UC/BR/AC → apply BDD rules R1–R10
95
-
96
- [L5] Output: specs/payment/process-payment/bdd/PAY-01-UC1.feature
97
- ```
98
-
99
- Chi tiết về step-architecture (gate / context-loader / report-footer) và sub-agent model: xem [pipeline.md](pipeline.md#command-internals--step-architecture).
100
-
101
- ---
102
-
103
- ## Build system
104
-
105
- `*.tmpl` (committed) được assemble thành `*.md` (gitignored) bởi `bin/build.js`:
106
-
107
- ```
108
- Source (committed) Build output (gitignored)
109
- commands/*.tmpl ──┐
110
- skills/**/SKILL.tmpl ──┤ node bin/build.js → commands/*.md · skills/**/SKILL.md
111
- steps/*.md (shared) ──┘
112
-
113
- Trigger:
114
- npm run build ← manual
115
- prepublishOnly hook ← auto trước npm publish
116
- bin/index.js install ← auto khi user chạy npx
117
- ```
118
-
119
- > Build output cũng bao gồm `core/` — bản distributable được copy vào `.agent/` của consumer khi `--init`.
120
-
121
- ---
122
-
123
- ## Module plug-in system
124
-
125
- Stack module là plug-in tùy chọn: cài qua `--module`, đọc ở runtime bởi `context-loader.md`.
126
-
127
- ```
128
- Available modules (modules/):
129
- java-spring, angular, react, nextjs, vue, nuxt, dotnet, golang,
130
- php-laravel, flutter, react-native, ios-swiftui, android-compose,
131
- context-engineering, qc-playwright
132
-
133
- Usage:
134
- npx @educa-corp/sdd-framework --module java-spring
135
- └─ copies modules/java-spring/ → consumer/.agent/modules/java-spring/
136
-
137
- Runtime, context-loader.md đọc:
138
- .agent/modules/{tech_stack.module}/stack-profile.yaml
139
- .agent/modules/{tech_stack.module}/architecture-snippets/
140
- ```
141
-
142
- > **`qc-playwright`** là stack module cho native QC pipeline (`/qc-run-test`, `/qc-report`) — Python + pytest-playwright + Page Object — **ĐỘC LẬP** với dev implementation module (java-spring / react / flutter / …). Per-layer guides ở `skills/qc/<stage>/`. Danh sách module đầy đủ: [../05-reference/modules.md](../05-reference/modules.md).
143
-
144
- ---
145
-
146
- ## Hook system — data protection
147
-
148
- ```
149
- Consumer project setup:
150
- .claude/settings.json ← registers hook (template)
151
- hooks/data-guard.js ← copied khi install
152
-
153
- Runtime — mỗi tool use (Read, Write, Edit, Bash):
154
- data-guard.js checks:
155
- .env* · *.key · *.pem · *secret* · *password* · *credential*
156
- application-prod.* · appsettings.Production.*
157
-
158
- safe → allow blocked → exit(2) + warn user
159
- ```
160
-
161
- ---
162
-
163
- ## Sub-agent orchestration
164
-
165
- Khi một command quá nặng cho single context window, orchestrator spawn các sub-agent độc lập (mỗi agent có context window riêng):
166
-
167
- ```
168
- Main session (orchestrator — lightweight, chỉ coordinate)
169
- ├─ spawn spec-agent ──→ /refine-prd analysis → returns findings.yaml
170
- ├─ spawn codegen-agent ──→ /generate-code UC1 → returns src/ changes
171
- └─ spawn test-agent ──→ /dev-gen-test UC1 → returns self-check test files
172
- ```
173
-
174
- **Lợi ích:** main session không bị bloat bởi large file reads · mỗi agent focus 1 task, ít hallucination · parallel cho nhiều UC.
175
-
176
- Pattern này được hiện thực hóa qua `steps/spawn-agent.md` và tự kích hoạt cho `/generate-bdd`, `/generate-code`, `/dev-gen-test` khi PRD vượt ngưỡng phức tạp (> 3 UC hoặc > 300 dòng). Chi tiết flow + tiết kiệm context: [pipeline.md](pipeline.md#spawn-agentmd--sub-agent-orchestration).
177
-
178
- ---
179
-
180
- ## Directory map
181
-
182
- ```
183
- spec-driven-docs/
184
- ├── docs/ ← Toàn bộ tài liệu (bắt đầu ở docs/README.md) ◀◀◀
185
- │ ├── 01-getting-started/
186
- │ ├── 02-guides/
187
- │ ├── 03-concepts/ ← file này (architecture.md)
188
- │ ├── 04-operations/
189
- │ └── 05-reference/
190
- ├── bin/
191
- │ ├── build.js ← assembles *.tmpl → *.md
192
- │ └── index.js ← npm installer + hook installer
193
- ├── commands/
194
- │ └── *.tmpl ← slash commands
195
- ├── hooks/
196
- │ ├── data-guard.js ← PreToolUse sensitive file protection
197
- │ └── settings.json ← hook registration template
198
- ├── modules/
199
- │ └── {stack}/ ← java-spring, react, …, qc-playwright
200
- │ ├── module.yaml
201
- │ ├── stack-profile.yaml
202
- │ └── architecture-snippets/
203
- ├── rules/
204
- │ ├── data-protection.md ← what AI must NEVER read/write
205
- │ └── workflow.md ← general AI behavior rules
206
- ├── skills/
207
- │ ├── {name}/SKILL.tmpl ← Claude plugin skills
208
- │ └── qc/<stage>/ ← per-layer QC automation guides
209
- ├── steps/
210
- │ ├── gate.md ← shared: file resolve + checkpoint
211
- │ ├── context-loader.md ← shared: load all project context
212
- │ ├── spawn-agent.md ← shared: sub-agent orchestration
213
- │ ├── capture-lesson.md ← shared: record a guardrail (/learn etc.)
214
- │ └── report-footer.md ← shared: standard output format
215
- └── templates/
216
- ├── project-context.yaml ← consumer project config template
217
- ├── architecture.template.md
218
- └── platform-guide.template.md
219
- ```
220
-
221
- > **Build output (gitignored):** `commands/*.md`, `skills/**/SKILL.md`, và `core/`. Consumer-side tester artifacts nằm trong shared spec repo tại `feedback/bug-reports/` và `feedback/bdd-proposals/`.
222
-
223
- > **Umbrella mode — API contract (tech-docs) là cross-team artifact:** khi `setup.spec_source` được set, tech-docs LUÔN route về spec repo tại `{spec_source}/specs/{domain}/{prd-slug}/tech-docs/` (cùng feature-package với PRD / BDD / design-spec), KHÔNG per-service — để FE/App đọc contract qua spec submodule ở `/generate-code --phase=integration`. Chỉ khi không có `spec_source` thì tech-docs mới nằm per-service.
224
-
225
- > **Living Docs / trace data location:** khi `spec_source` set, `.trace/*.tsv` **authoritative** nằm **một chỗ** ở `{spec_source}/.trace/` (committed trong spec repo — PM quản lý tập trung; mỗi scenario mang `@trace.service`). Report `trace-report.json` sinh vào `{spec_source}/.living-docs/` (gitignored) + panel mirror cục bộ `./.trace`. Chỉ khi không có `spec_source` thì `.trace` mới per-service. Chi tiết: [traceability.md](traceability.md#living-docs--canonical-trong-spec-module--panel-mirror).
226
-
227
- ---
228
-
229
- ## Maintenance guide
230
-
231
- | Muốn thay đổi gì | Sửa file nào |
232
- |------------------|-------------|
233
- | Logic của 1 command cụ thể | `commands/{name}.tmpl` |
234
- | Logic của 1 skill cụ thể | `skills/{name}/SKILL.tmpl` |
235
- | Gate / checkpoint pattern | `steps/gate.md` |
236
- | Context loading | `steps/context-loader.md` |
237
- | Report format | `steps/report-footer.md` |
238
- | Sensitive file patterns | `hooks/data-guard.js` + `rules/data-protection.md` |
239
- | Stack-specific rules | `modules/{stack}/stack-profile.yaml` |
240
- | QC automation rules (per-layer) | `skills/qc/<stage>/` + `modules/qc-playwright/` |
241
- | Project setup template | `templates/project-context.yaml` |
242
- | Build system | `bin/build.js` |
243
- | Installer | `bin/index.js` |
244
-
245
- Sau khi sửa bất kỳ `.tmpl` hoặc `steps/*.md`:
246
- ```bash
247
- npm run build # regenerate tất cả *.md
248
- ```
@@ -1,124 +0,0 @@
1
- [📚 Docs](../README.md) › [Concepts](README.md) › Cơ Chế (Dễ Hiểu)
2
-
3
- # Giải Thích Cơ Chế Framework — Ngôn Ngữ Dễ Hiểu
4
-
5
- > Nơi gom các giải thích **cơ chế hoạt động** của framework bằng lời dễ hiểu + ví von đời thường. Bổ sung cho các trang concepts "chính quy" ([pipeline](pipeline.md), [traceability](traceability.md), [architecture](architecture.md)) — trang này ưu tiên *trực giác*, không phải đặc tả.
6
-
7
- ## Mục lục
8
-
9
- - [1. PRD lớn → chia việc cho nhiều "thợ phụ" (orchestration / sub-agent)](#1-prd-lớn--chia-việc-cho-nhiều-thợ-phụ-orchestration--sub-agent)
10
- - [2. AC / BR / Scope ở khác tầng — "4 ngăn" (altitude)](#2-ac--br--scope-ở-khác-tầng--4-ngăn-altitude)
11
- - [3. Coding convention đặt ở đâu để update không nuốt mất](#3-coding-convention-đặt-ở-đâu-để-update-không-nuốt-mất)
12
- - [4. Tech-doc "một bản vẽ / PRD" — gộp full-stack, lớn dần, và cách review nó](#4-tech-doc-một-bản-vẽ--prd--gộp-full-stack-lớn-dần-và-cách-review-nó)
13
-
14
- ---
15
-
16
- ## 1. PRD lớn → chia việc cho nhiều "thợ phụ" (orchestration / sub-agent)
17
-
18
- **Cơ chế:** Khi PRD **nhỏ**, một mình AI làm hết từ đầu tới cuối. Khi PRD **lớn** (> 3 Use Case hoặc > 300 dòng), AI chuyển sang **chế độ điều phối**: session chính thành "sếp" nhẹ, **spawn mỗi Use Case một sub-agent** ("thợ phụ") có context window riêng để làm song song cho nhanh và đỡ tốn bộ nhớ.
19
-
20
- **Ví von:** Việc nhỏ thì một người ôm trọn. Việc lớn thì **sếp chia mỗi thợ một Use Case**.
21
-
22
- **Điểm mấu chốt — sếp làm phần chung MỘT LẦN, rồi "photo" đưa thợ:**
23
- - **Sếp làm trước, một lần** (ở session chính, đọc cả PRD): kiểm tra **cổng duyệt** (PRD approved?), **nạp Design Spec** (đã duyệt + còn mới + soi nhanh) → rút ra phần màn hình + AC-UI cần phủ (gọi là `design_coverage`), và chốt **platform** (web/app/system).
24
- - **Khi giao việc**, sếp **kèm sẵn cho mỗi thợ**: platform + `design_coverage` đã rút. Thợ **không** phải tự đi đọc lại design-spec, **không** phải hỏi lại "đã duyệt chưa".
25
- - Mỗi thợ chỉ đọc đúng **1 Use Case** trong PRD + dùng đồ sếp đưa → sinh BDD cho UC đó.
26
-
27
- **Vì sao thiết kế vậy:**
28
- - **Rẻ:** thợ khỏi đọc lại cả design-spec (đỡ token), khỏi bắt người dùng bấm Y/N nhiều lần (cổng duyệt hỏi 1 lần ở sếp).
29
- - **Không sót:** phần phủ design (Screen States loading/lỗi/trống + AC-UI) áp **cho cả PRD lớn**, không chỉ PRD nhỏ.
30
-
31
- > **Cạm bẫy đã từng có (và cách tránh):** nếu sếp quên "photo" `design_coverage`/platform khi giao việc → thợ làm theo trí nhớ thiếu → BDD của PRD lớn **rớt mất phần design** (dù PRD nhỏ vẫn đúng). Bài học: state nào orchestrator đã phân giải mà bước sau cần → **phải nhét vào payload giao cho sub-agent**, đừng để rơi.
32
-
33
- *Chi tiết kỹ thuật:* [pipeline › spawn-agent](pipeline.md#spawn-agentmd--sub-agent-orchestration) · [architecture › sub-agent orchestration](architecture.md#sub-agent-orchestration).
34
-
35
- ---
36
-
37
- ## 2. AC / BR / Scope ở khác tầng — "4 ngăn" (altitude)
38
-
39
- **Cơ chế:** Nội dung PRD có **4 "ngăn"**, mỗi loại thông tin ở đúng một ngăn:
40
- - **AC** (Acceptance Criteria) = *biên bản nghiệm thu* → "đạt khi nào" (kết quả nhìn/đo được) + trỏ số hiệu BR.
41
- - **BR / BL** (Business Rule / Logic) = *bản vẽ kỹ thuật* → "chạy thế nào" (thử lại mấy lần, timeout, cờ ai giữ, nhánh lỗi).
42
- - **Scope (In/Out)** = *ranh giới lô đất* → "làm gì / không làm gì" (một dòng, đọc lướt hiểu ngay).
43
- - **BUSINESS DEFINITION / business-dictionary** = *giải nghĩa từ*.
44
-
45
- **Vì sao dễ hỏng:** `/refine-prd` giống một **tổ 3 người soi bài** (DEV/SA/PO) + một người canh *"đã đủ chưa?"* (completeness-critic). Cả tổ **chỉ biết THÊM chi tiết** — mà câu hỏi mặc định *"AC đủ chi tiết chưa?"* tự nó **kéo chi tiết bản-vẽ-kỹ-thuật vào biên-bản-nghiệm-thu**. Qua nhiều vòng `--resume`, **AC dày lên bằng BR** → hai ngăn hội tụ, tài liệu trùng lặp + AC hết dùng được như checklist. In Scope tụt tầng cùng lý do (bị nhét định nghĩa cơ chế).
46
-
47
- > **Gốc rễ:** tổ soi bài tối ưu *"đủ từng section"* nhưng **thiếu lực đối trọng giữ ranh giới vai trò** — không ai kéo "mỗi thứ về đúng ngăn", nên chi tiết cứ trôi xuống, ngăn BR hút hết.
48
-
49
- **Cách giữ ranh giới (7 luật, 2 nhóm):**
50
- - **Dọn (hạ nguồn):** AC chỉ ghi outcome + ref BR (cấm cơ chế) · lúc áp fix → cơ chế bỏ vào BR/BL · lính gác bắt AC lỡ chứa cơ chế · Scope chỉ là ranh giới.
51
- - **Sửa gốc (thượng nguồn):** đổi **câu hỏi** của tổ soi bài (hỏi "AC có outcome test được chưa", chi tiết → BR/BL) · thêm **người canh "đừng lộn ngăn"** vào critic (không chỉ "đủ chưa" mà "có lộn tầng không") · **bắt AC ≈ BR** (trùng nội dung → làm mỏng AC).
52
-
53
- > **Đừng hiểu nhầm là "cắt bớt":** chi tiết retry/timeout/nhánh lỗi **KHÔNG bị xoá** — nó **di dời** từ AC xuống BR/BL. Vì `/generate-bdd` sinh test theo *mỗi BR → ≥1 scenario*; nhánh lỗi/retry chính là nguồn đẻ test. Bỏ hẳn = mất test.
54
-
55
- *Chi tiết áp ở đâu:* lăng kính + completeness-critic (`steps/review-fanout.md`, `commands/refine-prd.tmpl`) · P-check (`commands/review-context.tmpl`) · format AC/Scope (`templates/prd.template.md`, `commands/generate-prd.tmpl`).
56
-
57
- ---
58
-
59
- ## 3. Coding convention đặt ở đâu để update không nuốt mất
60
-
61
- **Cơ chế:** File trong project chia làm **hai loại chủ sở hữu**. `/update-framework` (kéo bản framework mới về) **ghi đè** nhóm "của framework" và **không đụng** nhóm "của bạn":
62
-
63
- | Của framework — **bị ghi đè** mỗi lần update | Của bạn — **được giữ** nguyên |
64
- |---|---|
65
- | `.agent/commands · steps · hooks · rules · templates · skills` | `CLAUDE.md` |
66
- | `.agent/modules/{stack}/` (`module.yaml`, `stack-profile.yaml`, snippets) | `.agent/project-context.yaml` |
67
- | `.agent/FRAMEWORK_VERSION`, `.claude/commands/` | `specs/domain-knowledge/`, `.trace/` |
68
-
69
- **Ví von:** Framework là **bộ đồ nghề đi thuê** — mỗi lần đổi bộ mới, đồ thuê bị thay sạch, nhưng **đồ riêng của bạn** (ghi chú dán trên tường = `CLAUDE.md`, sổ tay dự án = `project-context.yaml`) thì không ai động.
70
-
71
- **Điểm mấu chốt — đặt convention ở chỗ vừa GIỮ vừa ĐƯỢC ĐỌC:**
72
- - **`CLAUDE.md`** là nhà chính: `/generate-code`, `/review-code`, `/generate-tech-docs`, `/fix-bug` nạp trực tiếp `§2 Architecture` (thứ tự layer + rule), `§3 Coding Standards` (naming, wrapper, forbidden), `§5 Error Handling` (exception, HTTP code). Framework sinh sẵn skeleton các §; bạn chỉ điền chi tiết stack (vd Java Spring Boot).
73
- - **`project-context.yaml`** `conventions:` giữ lệnh `build_command` / `test_command` / `run_command` — `/generate-code` chạy đúng lệnh này khi tự-kiểm.
74
- - **Convention dài** (cả trang) → tách file dưới `specs/domain-knowledge/` (cũng được giữ + context-loader nạp), rồi trỏ tới từ `CLAUDE.md` cho gọn.
75
-
76
- > **Cạm bẫy hay gặp:** nhét convention riêng vào `.agent/modules/{stack}/` (vì thấy nó "nói về stack của mình"). Sai — module là **default chung của stack do framework phát hành**, nằm trong nhóm bị ghi đè; convention của team sẽ **bay sạch** ở lần update kế. Của-stack (framework) khác của-team (bạn) — để riêng.
77
-
78
- *Chi tiết:* danh sách ghi-đè/giữ (`commands/update-framework.tmpl`) · nơi đọc convention (`commands/generate-code.tmpl` §2/§3/§5) · skeleton CLAUDE.md (`commands/setup-ai-first.tmpl`) · `conventions:` (`templates/project-context.yaml`).
79
-
80
- ---
81
-
82
- ## 4. Tech-doc "một bản vẽ / PRD" — gộp full-stack, lớn dần, và cách review nó
83
-
84
- **Cơ chế:** Một PRD chỉ có **một** technical design document — `{TICKET-ID}-tech-design.md`, nằm trong `specs/{domain}/{prd-slug}/tech-docs/`, cạnh `bdd/` và `design-spec/`. File này **gộp full-stack**: backend (API §4.1–§4.4, data model §3, DB) *và* client (§4.5 component/state/Figma/test-id cho mỗi platform), nối với nhau bằng **sequence diagram xuyên tầng** ở §5 (client → service → API → external → DB). Một dev đọc **một** file là hiểu và code được cả tính năng.
85
-
86
- **Ví von:** không phải nhiều bản vẽ rời (mỗi phòng một tờ) mà **một bản vẽ tổng mặt bằng** cho cả căn nhà — móng, điện, nước, nội thất trên cùng một khổ giấy, có mũi tên chỉ chúng nối nhau ra sao.
87
-
88
- **Input là BDD tech lead trỏ, KHÔNG phải cả PRD:** `/generate-tech-docs` nhận **1..n file BDD** người dùng chỉ định (batch, cảnh báo nếu > 5 để khỏi phình context) — trỏ System BDD → vẽ §4 API; trỏ Web/App BDD → append §4.5 client. Chạy nhiều lần, **doc lớn dần** (append), không đè phần cũ. **§10 UC Coverage** là "sổ điểm danh" để lệnh biết UC nào đã vẽ, UC nào còn thiếu.
89
-
90
- **Vì sao gộp thay vì tách BE/FE per-UC:** một tính năng vốn liền mạch (bấm nút ở web → gọi API → ghi DB); tách ra nhiều file khiến dev phải ghép hình. Gộp lại: §4.5.4 (client gọi API) map thẳng lên §4.1 (endpoint) trong **cùng** tài liệu — không lệch, không đi tìm file anh em.
91
-
92
- **Review chạy trên doc gộp thế nào (`/review-tech-docs`):**
93
- - **Phạm vi = cả PRD, không phải 1 UC:** đọc `@trace.ucs` (danh sách UC) để biết doc phủ những câu nào, ra **một** file findings `{TICKET-ID}-tech-review-findings.yaml` — nhưng **mỗi finding gắn `uc_id`** để biết lỗi thuộc câu nào (như phiếu chấm cho cả xấp bài, mỗi lỗi ghi rõ "câu số mấy").
94
- - **T3 truy vết BDD 2 chiều** với **mọi** BDD của PRD (system/web/app): doc có behavior nào không có scenario? scenario nào chưa được vẽ (§5/§10)? — các file BDD này thuộc *chính PRD* nên phạm vi có giới hạn.
95
- - **Duyệt xong → đóng dấu revision cho mọi UC:** doc bump `@trace.revision`; review ghi `tech_doc_revision = revision mới` vào TSV của **từng** UC trong `@trace.ucs` (sổ trace vẫn per-UC). Chừa cột `fe_tech_doc_revision` cho `/generate-code --phase=integration` ghi (lúc FE wire API thật theo §4.5.4) — **2 cột, cùng đọc 1 file, ghi ở 2 thời điểm**.
96
-
97
- **Điểm mấu chốt — check trùng endpoint liên-PRD kiểu "tra sổ địa chỉ, không vào từng nhà" (T4):** vì doc rất dài, muốn bắt 2 PRD vô tình định nghĩa cùng endpoint khác shape, review **không** đọc trọn tech-doc của mọi PRD khác (nổ context). Thay vào đó: trích danh sách endpoint (§4.1) của doc đang review → `grep` các path đó trong tech-doc PRD khác (chỉ đọc dòng match) → **chỉ khi trùng path** mới nạp đúng đoạn §4 của doc kia để so. Bình thường tốn vài dòng grep; chỉ "trả tiền" khi thật sự va chạm.
98
-
99
- > **Cạm bẫy đã tránh:** ban đầu định cho T4 nạp full mọi tech-doc cùng domain để so — mỗi doc 500–800 dòng × N PRD = context nổ. Bài học: khi cần đối chiếu chéo nhiều tài liệu lớn, **lọc bằng chỉ mục rẻ (grep path) trước, nạp full chỉ khi có hit** — đừng load tất cả rồi mới so.
100
-
101
- > **Cạm bẫy #2 — trùng số SC khi gộp platform (số căn hộ giữa hai toà):** mã scenario `{UC}-SC{N}` **chỉ độc nhất trong (UC × platform)** — `system UC1-SC1` và `web UC1-SC1` là **hai scenario khác nhau**. Gộp cả 3 platform vào 1 doc rồi liệt kê SC phẳng → nhập nhằng (như Toà A căn 101 vs Toà B căn 101, gộp danh bạ chỉ ghi "101"). **Cách tránh — giữ lane theo platform:** §5 chia `5.A system / 5.B web / 5.C app`, mỗi SC ghi kèm platform (`web · UC1-SC1`); §10 có cột **Platform** (mỗi `(platform, SC)` một dòng); review T3 match SC trong đúng lane, không so chéo. *(Cùng gốc collision này từng nằm ở **tầng trace**: sổ TSV per-UC key thuần `sc_id` → scenario các platform **đè/xoá nhau** (gen web xoá luôn scenario system). **Đã fix bằng cách tách sổ theo platform** — `{UC-ID}-{platform}.tsv`, mỗi platform một sổ (system/web/app). Hết đè/xoá; Living Docs gắn field `platform` mỗi row để hiển thị coverage tách bạch. Chi tiết: [Trace Schema](../05-reference/trace-schema.md).)*
102
-
103
- **Điều hướng doc gộp (mục lục + độ hạt):** vì doc là cấp PRD nhưng consumer (`generate-code`/`map-testids`/`qc`) xử **một UC**, **§10 UC Coverage là mục lục**: tra UC → scenario → section/§5-lane của nó (endpoint liên quan = §4.1 mà §5-lane của UC gọi tới). §4.5 **nhóm theo platform** (một nhóm `§4.5 — web`, một `§4.5 — app`), mỗi màn/UC là sub-block; §4.5.6 là **một bảng chung/platform** với cột "Serves SC (UC·SC)" để lọc theo UC. *Ví von: bản vẽ cả toà nhà phải có mục lục "tầng ở trang mấy"; nội thất gom theo tầng, mỗi phòng một trang.*
104
-
105
- **Cách `/generate-code` tiêu thụ doc gộp:** code sinh cho **1 UC** nhưng mở **cùng** file gộp rồi lật đúng phần UC đó — không còn đi tìm file per-UC/per-platform:
106
- - **Khuôn mock (`--phase=ui`):** shape request/response lấy từ **§4.1/§4.2/§4.3** (API contract) để mock giống API thật, đỡ nắn lại lúc ráp. Chưa có §4 → suy từ System BDD + cảnh báo.
107
- - **Đấu nối thật (`--phase=integration`):** map client method → endpoint theo **§4.5.4** (sơ đồ đấu nối của platform), endpoint/shape tra §4.1–§4.3 **cùng doc**. Chưa có §4.5.4 → map thẳng từ §4.1 + warn.
108
- - **Test-id:** emit đúng id trong **§4.5.6** (thay §2b cũ) để QC Page Object khớp ngay. (`/map-testids` backfill §4.5.6 cho component tái dùng/brownfield; `/qc-design-test` + `/qc-run-test` đọc §4.5.6 để dựng locator; `/validate-traces` so `@trace.revision` của doc gộp với 2 cột để bắt drift.)
109
- - **Đóng dấu bản vẽ:** ghi `tech_doc_revision` (lúc gen BE) / `fe_tech_doc_revision` (lúc FE integration) = `@trace.revision` của doc → `/validate-traces` bắt drift khi code lắp theo bản cũ.
110
-
111
- *Ví von ba mục: §4 = **kích thước ô cửa** (đóng khung mock cho khít) · §4.5.4 = **sơ đồ đấu dây** (nối API thật) · §4.5.6 = **bảng số phòng** (QC tìm element).*
112
-
113
- **Quy tắc nhận dạng & vài edge (rút ra khi soi BDD thật):**
114
- - **Định danh đọc từ header, không cắt tên file:** `{TICKET-ID}` ← `@trace.prd`, `{UC-ID}` ← `@trace.id` (đều slug-free). Vì TICKET-ID có gạch nối (`FEAT-01-2`) và **slug/title một UC khác nhau theo platform** (UC3: system `sua-cau-bo-qua` vs web `sua-cau-quay-lai-bo-qua`) — cắt chuỗi dễ sai. Gom UC theo `@trace.id` → system/web/app cùng id = **một** UC; title lấy canonical từ **PRD**.
115
- - **`@trace.bdd_version` là map theo platform** (`system=1.5, web=1.9`) chứ không một số — mỗi feature giữ version riêng, gộp phẳng sẽ che mất platform nào còn cũ.
116
- - **PRD client-only (không có system BDD):** đừng bịa BE contract — §4.1 chỉ ghi endpoint client **tiêu thụ** (external/team khác/existing), hoặc "N/A — client-only". Đối xứng với backend-only (bỏ §4.5).
117
-
118
- > ✅ **Trạng thái migrate:** **toàn bộ command** đã theo mô hình doc gộp — `/generate-tech-docs`, `/review-tech-docs`, `/generate-code`, `/validate-traces`, `/map-testids`, `/qc-design-test`, `/qc-run-test`, `/generate-bdd`. Còn lại: một số **trang guide/reference** (getting-started, developer/tester guides, command reference, sync-and-update) vẫn mô tả layout per-UC cũ — sẽ quét đồng bộ sau (không ảnh hưởng hành vi lệnh).
119
-
120
- *Chi tiết:* sinh doc (`commands/generate-tech-docs.tmpl` + `templates/tech-design.template.md`) · review (`commands/review-tech-docs.tmpl` — T3/T4/T7 + Resume TSV) · vị trí trong dây chuyền ([pipeline › Phase 4](pipeline.md)) · chuẩn bị input ([Checklist Input Tech-Docs](../02-guides/tech-docs-input-checklist.md)).
121
-
122
- ---
123
-
124
- *Có thêm cơ chế nào được giải thích kiểu dễ hiểu → thêm một mục mới ở đây.*