ai-developer-skill-os 1.8.1 → 2.0.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 (55) hide show
  1. package/README.md +130 -171
  2. package/docs/CHI_TIET_SKILLS.md +89 -81
  3. package/docs/HUONG_DAN_SU_DUNG.md +120 -152
  4. package/package.json +1 -1
  5. package/skills/{qk-accessibility-audit → _archive_old_skills/qk-accessibility-audit}/SKILL.md +1 -1
  6. package/skills/{qk-agent-orchestrator → _archive_old_skills/qk-agent-orchestrator}/SKILL.md +1 -1
  7. package/skills/{qk-bug-fix → _archive_old_skills/qk-bug-fix}/SKILL.md +1 -1
  8. package/skills/{qk-component-generator → _archive_old_skills/qk-component-generator}/SKILL.md +1 -1
  9. package/skills/{qk-database-engineer → _archive_old_skills/qk-database-engineer}/SKILL.md +1 -1
  10. package/skills/{qk-design-system → _archive_old_skills/qk-design-system}/SKILL.md +1 -1
  11. package/skills/{qk-form-builder → _archive_old_skills/qk-form-builder}/SKILL.md +1 -1
  12. package/skills/{qk-frontend-architecture → _archive_old_skills/qk-frontend-architecture}/SKILL.md +1 -1
  13. package/skills/{qk-frontend-debug → _archive_old_skills/qk-frontend-debug}/SKILL.md +1 -1
  14. package/skills/{qk-frontend-performance → _archive_old_skills/qk-frontend-performance}/SKILL.md +1 -1
  15. package/skills/{qk-git-engineer → _archive_old_skills/qk-git-engineer}/SKILL.md +1 -1
  16. package/skills/_archive_old_skills/qk-help/SKILL.md +67 -0
  17. package/skills/{qk-state-management → _archive_old_skills/qk-state-management}/SKILL.md +1 -1
  18. package/skills/{qk-table-crud-generator → _archive_old_skills/qk-table-crud-generator}/SKILL.md +1 -1
  19. package/skills/qk-access-policy/SKILL.md +127 -0
  20. package/skills/qk-ai-builder/SKILL.md +33 -0
  21. package/skills/qk-api-lifecycle/SKILL.md +420 -0
  22. package/skills/qk-bug-resolution/SKILL.md +371 -0
  23. package/skills/qk-context-loader/SKILL.md +206 -0
  24. package/skills/qk-data-lifecycle/SKILL.md +135 -0
  25. package/skills/qk-design-to-code/SKILL.md +33 -0
  26. package/skills/qk-docs/SKILL.md +335 -0
  27. package/skills/qk-documentation-system/SKILL.md +33 -0
  28. package/skills/qk-engineering-standard/SKILL.md +171 -0
  29. package/skills/qk-engineering-standard/rules/backend.md +122 -0
  30. package/skills/qk-engineering-standard/rules/database.md +3 -0
  31. package/skills/qk-engineering-standard/rules/frontend.md +152 -0
  32. package/skills/qk-engineering-standard/rules/security.md +3 -0
  33. package/skills/qk-engineering-standard/rules/testing.md +3 -0
  34. package/skills/qk-feature-delivery/SKILL.md +432 -0
  35. package/skills/qk-help/SKILL.md +95 -67
  36. package/skills/qk-orchestrator/SKILL.md +272 -0
  37. package/skills/qk-policy-engine/SKILL.md +33 -0
  38. package/skills/qk-production-release/SKILL.md +127 -0
  39. package/skills/qk-project-bootstrap/SKILL.md +33 -0
  40. package/skills/qk-project-health/SKILL.md +650 -0
  41. package/skills/qk-project-memory/SKILL.md +33 -0
  42. package/skills/qk-system-evolution/SKILL.md +315 -0
  43. package/skills/qk-ui-audit/SKILL.md +152 -0
  44. package/skills/qk-ui-system-builder/SKILL.md +444 -0
  45. package/skills/qk-validation-gate/SKILL.md +33 -0
  46. /package/skills/{qk-api-integration → _archive_old_skills/qk-api-integration}/SKILL.md +0 -0
  47. /package/skills/{qk-auth-security → _archive_old_skills/qk-auth-security}/SKILL.md +0 -0
  48. /package/skills/{qk-backend-architecture → _archive_old_skills/qk-backend-architecture}/SKILL.md +0 -0
  49. /package/skills/{qk-context-manager → _archive_old_skills/qk-context-manager}/SKILL.md +0 -0
  50. /package/skills/{qk-deployment → _archive_old_skills/qk-deployment}/SKILL.md +0 -0
  51. /package/skills/{qk-frontend-testing → _archive_old_skills/qk-frontend-testing}/SKILL.md +0 -0
  52. /package/skills/{qk-migration → _archive_old_skills/qk-migration}/SKILL.md +0 -0
  53. /package/skills/{qk-project-audit → _archive_old_skills/qk-project-audit}/SKILL.md +0 -0
  54. /package/skills/{qk-refactor → _archive_old_skills/qk-refactor}/SKILL.md +0 -0
  55. /package/skills/{qk-ui-builder → _archive_old_skills/qk-ui-builder}/SKILL.md +0 -0
@@ -0,0 +1,33 @@
1
+ ---
2
+ name: qk-design-to-code
3
+ purpose: Chuyển đổi Figma/Screenshot thành Code UI tuân thủ hệ thống.
4
+ mode_supported: [standard]
5
+ input: [Image/Figma]
6
+ output: [UI Code]
7
+ workflow: [1. Analyze Image -> 2. Map Components -> 3. Code -> 4. Responsive]
8
+ allowed_tools: [write_to_file]
9
+ handoff_to: [qk-ui-audit]
10
+ ---
11
+
12
+ # 🛠️ qk-design-to-code - Quy Trình Vận Hành Chuẩn (SOP)
13
+
14
+ > **Mô tả:** Chuyển đổi Figma/Screenshot thành Code UI tuân thủ hệ thống.
15
+
16
+ ## 🎯 1. Mục Tiêu (Goal)
17
+ - Hoàn thành thành công tác vụ được giao liên quan đến nhiệm vụ của skill.
18
+ - Đảm bảo chất lượng mã nguồn và tính nhất quán của hệ thống.
19
+
20
+ ## 🔄 2. Chuỗi Hành Động (Chain of Thought / SOP)
21
+ *(Bắt buộc AI phải suy nghĩ và làm theo đúng thứ tự)*
22
+ 1. **Phân tích (Analyze):** Thu thập ngữ cảnh và hiểu rõ yêu cầu đầu vào.
23
+ 2. **Lên kế hoạch (Plan):** Xác định các bước cần thay đổi/tạo mới dựa trên bộ luật (rules).
24
+ 3. **Thực thi (Execute):** Tiến hành sửa đổi mã nguồn hoặc tạo tài liệu.
25
+ 4. **Xác thực (Verify):** Đảm bảo đầu ra đáp ứng đúng yêu cầu và không vi phạm quy định.
26
+
27
+ ## 🛡️ 3. Ràng Buộc & Quy Tắc (Constraints)
28
+ - CẤM bỏ qua việc kiểm tra `qk-engineering-standard` trước khi viết code.
29
+ - Mọi quyết định kỹ thuật phải dựa trên nội dung tại phần Deep Knowledge (nếu có).
30
+
31
+ ## 🤝 4. Giao Thức Bàn Giao (Handoff Protocol)
32
+ - Đích đến: `qk-ui-audit`
33
+ - Nội dung bàn giao: Chuyển toàn bộ ngữ cảnh và kết quả đã thực thi cho bước tiếp theo.
@@ -0,0 +1,335 @@
1
+ ---
2
+ name: qk-docs
3
+ purpose: Viết và duy trì tài liệu dự án dễ hiểu cho con người (Human-readable Docs).
4
+ mode_supported: [standard]
5
+ input: [Code changes]
6
+ output: [Updated README, API Docs, Changelog]
7
+ workflow: [1. Tóm tắt Code -> 2. Generate Docs -> 3. Handoff]
8
+ allowed_tools: [write_to_file]
9
+ handoff_to: [qk-documentation-system]
10
+ ---
11
+
12
+ # 🛠️ qk-docs - Quy Trình Vận Hành Chuẩn (SOP)
13
+
14
+ > **Mô tả:** Viết và duy trì tài liệu dự án dễ hiểu cho con người (Human-readable Docs).
15
+
16
+ ## 🎯 1. Mục Tiêu (Goal)
17
+ - Hoàn thành thành công tác vụ được giao liên quan đến nhiệm vụ của skill.
18
+ - Đảm bảo chất lượng mã nguồn và tính nhất quán của hệ thống.
19
+
20
+ ## 🔄 2. Chuỗi Hành Động (Chain of Thought / SOP)
21
+ *(Bắt buộc AI phải suy nghĩ và làm theo đúng thứ tự)*
22
+ 1. **Phân tích (Analyze):** Thu thập ngữ cảnh và hiểu rõ yêu cầu đầu vào.
23
+ 2. **Lên kế hoạch (Plan):** Xác định các bước cần thay đổi/tạo mới dựa trên bộ luật (rules).
24
+ 3. **Thực thi (Execute):** Tiến hành sửa đổi mã nguồn hoặc tạo tài liệu.
25
+ 4. **Xác thực (Verify):** Đảm bảo đầu ra đáp ứng đúng yêu cầu và không vi phạm quy định.
26
+
27
+ ## 🛡️ 3. Ràng Buộc & Quy Tắc (Constraints)
28
+ - CẤM bỏ qua việc kiểm tra `qk-engineering-standard` trước khi viết code.
29
+ - Mọi quyết định kỹ thuật phải dựa trên nội dung tại phần Deep Knowledge (nếu có).
30
+
31
+ ## 🤝 4. Giao Thức Bàn Giao (Handoff Protocol)
32
+ - Đích đến: `qk-documentation-system`
33
+ - Nội dung bàn giao: Chuyển toàn bộ ngữ cảnh và kết quả đã thực thi cho bước tiếp theo.
34
+
35
+ ## 📚 5. Kiến Thức Chuyên Sâu (Deep Knowledge)
36
+
37
+ *(Nền tảng kiến thức và quy tắc chi tiết kế thừa từ kỹ sư)*
38
+
39
+ ---
40
+
41
+
42
+
43
+ # Git Engineer
44
+
45
+ > **Language rule:**
46
+ > Use English for: code, identifiers, file names, architecture terms, technical decisions.
47
+ > Use the user's language for: explanations, questions, summaries, and feedback.
48
+ > The user may write in any language — detect and match it automatically.
49
+
50
+ > 📌 **Standard followed:** [Conventional Commits v1.0.0](https://www.conventionalcommits.org/)
51
+
52
+ ---
53
+
54
+ ## Trigger
55
+
56
+ Activate this skill when:
57
+ - User wants to write a commit message
58
+ - User has finished a feature and needs a PR description
59
+ - User needs to generate a changelog for a release
60
+ - User asks "what should I commit?", "write PR", "release notes"
61
+ - User wants to clean up their git history before merging
62
+
63
+ ---
64
+
65
+ ## Scope
66
+
67
+ - ✅ Write commit messages (Conventional Commits format)
68
+ - ✅ Suggest logical commit groupings from a set of changes
69
+ - ✅ Write pull request titles and descriptions
70
+ - ✅ Generate CHANGELOG entries from commit history
71
+ - ✅ Write release notes (human-readable)
72
+ - ✅ Suggest branch naming conventions
73
+ - ✅ Review and improve existing commit messages
74
+
75
+ ---
76
+
77
+ ## Non-goals
78
+
79
+ - ❌ Do NOT run git commands without explicit user approval
80
+ - ❌ Do NOT force-push or rebase without warning
81
+ - ❌ Do NOT create commits that bundle unrelated changes
82
+ - ❌ Do NOT write vague messages like "fix stuff" or "updates"
83
+
84
+ ---
85
+
86
+ ## Conventional Commits Format
87
+
88
+ ```
89
+ <type>(<scope>): <description>
90
+
91
+ [optional body]
92
+
93
+ [optional footer(s)]
94
+ ```
95
+
96
+ ### Types
97
+
98
+ | Type | When to use |
99
+ |------|-------------|
100
+ | `feat` | New feature |
101
+ | `fix` | Bug fix |
102
+ | `docs` | Documentation only changes |
103
+ | `style` | Formatting, missing semicolons — no logic change |
104
+ | `refactor` | Code restructure without behavior change |
105
+ | `perf` | Performance improvement |
106
+ | `test` | Adding or fixing tests |
107
+ | `build` | Build system or dependency changes |
108
+ | `ci` | CI/CD configuration changes |
109
+ | `chore` | Other changes that don't modify src or test files |
110
+ | `revert` | Reverts a previous commit |
111
+
112
+ ### Breaking Changes
113
+
114
+ ```
115
+ feat!: remove deprecated login endpoint
116
+
117
+ BREAKING CHANGE: The /auth/login endpoint has been removed.
118
+ Use /auth/v2/login instead.
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Workflow
124
+
125
+ ### Phase 1 — Understand the Changes
126
+
127
+ Review what has changed:
128
+ 1. Read the diff or file list provided by the user
129
+ 2. Group changes by concern (feature, fix, refactor, docs, etc.)
130
+ 3. Identify if changes should be split into multiple commits or kept as one
131
+ 4. Note any breaking changes
132
+
133
+ ---
134
+
135
+ ### Phase 2 — Commit Message(s)
136
+
137
+ For each logical group of changes, write:
138
+
139
+ **Single commit:**
140
+ ```
141
+ feat(auth): add refresh token rotation
142
+
143
+ Implements automatic refresh token rotation on each use.
144
+ Old tokens are invalidated immediately after use to prevent
145
+ replay attacks.
146
+
147
+ Closes #142
148
+ ```
149
+
150
+ **Multiple commits (if changes should be split):**
151
+ ```
152
+ refactor(api): extract axios instance to lib/axios.ts
153
+
154
+ No behavior change — prepares for interceptor configuration.
155
+
156
+ ---
157
+
158
+ feat(api): add request retry interceptor
159
+
160
+ Automatically retries failed requests up to 3 times with
161
+ exponential backoff. Skips retry for 4xx errors.
162
+ ```
163
+
164
+ **Rules:**
165
+ - Subject line: ≤72 characters, imperative mood ("add" not "added")
166
+ - Body: explain *why*, not *what* (the diff shows what)
167
+ - Reference issues: `Closes #123`, `Fixes #456`, `Refs #789`
168
+
169
+ ---
170
+
171
+ ### Phase 3 — Pull Request Description
172
+
173
+ Structure:
174
+ ```markdown
175
+ ## Summary
176
+ [1-3 sentences describing what this PR does and why]
177
+
178
+ ## Changes
179
+ - [Specific change 1]
180
+ - [Specific change 2]
181
+ - [Specific change 3]
182
+
183
+ ## Testing
184
+ - [ ] Unit tests pass
185
+ - [ ] Manual testing: [describe what you tested]
186
+ - [ ] [Other relevant checks]
187
+
188
+ ## Breaking Changes
189
+ [None | Description of breaking change and migration path]
190
+
191
+ ## Screenshots / Demo
192
+ [If UI changes — attach before/after screenshots]
193
+
194
+ ## Related Issues
195
+ Closes #[issue number]
196
+ ```
197
+
198
+ ---
199
+
200
+ ### Phase 4 — Changelog Entry
201
+
202
+ Follow [Keep a Changelog](https://keepachangelog.com/) format:
203
+
204
+ ```markdown
205
+ ## [1.2.0] - 2026-07-01
206
+
207
+ ### Added
208
+ - Refresh token rotation for improved security (#142)
209
+ - Retry interceptor with exponential backoff (#138)
210
+
211
+ ### Changed
212
+ - Extracted axios instance to `src/lib/axios.ts` for cleaner configuration
213
+
214
+ ### Fixed
215
+ - Fixed race condition in useUserData hook causing stale state (#135)
216
+ - Resolved memory leak when component unmounts during fetch (#133)
217
+
218
+ ### Deprecated
219
+ - `GET /api/v1/users` — use `GET /api/v2/users` instead (removes in v2.0)
220
+
221
+ ### Removed
222
+ - Removed legacy `moment.js` dependency — migrated to `date-fns`
223
+
224
+ ### Security
225
+ - Updated `package-x` from 2.1.0 to 2.1.4 (CVE-2026-XXXX)
226
+ ```
227
+
228
+ ---
229
+
230
+ ### Phase 5 — Release Notes (Human-Readable)
231
+
232
+ For non-technical stakeholders:
233
+
234
+ ```markdown
235
+ # Release v1.2.0 — Security & Stability
236
+
237
+ ## What's new
238
+
239
+ **Better security**: Login sessions are now more secure with automatic
240
+ token rotation. Each time you use the app, your session is refreshed
241
+ automatically.
242
+
243
+ **More reliable**: The app now automatically retries failed requests,
244
+ so temporary network issues won't interrupt your workflow.
245
+
246
+ ## Bug fixes
247
+
248
+ - Fixed an issue where user data could appear stale after navigating
249
+ - Fixed a rare crash that occurred when closing the app during data loading
250
+
251
+ ## Under the hood
252
+
253
+ We've updated several internal libraries to keep the app fast, secure,
254
+ and maintainable.
255
+ ```
256
+
257
+ ---
258
+
259
+ ## Decision Tree
260
+
261
+ ```
262
+ What does the user need?
263
+ ├── Commit message → Phase 2 only
264
+ ├── PR description → Phase 3 (+ Phase 2 if commits not written)
265
+ ├── Changelog entry → Phase 4 (from commit list or diff)
266
+ └── Full release → Phase 2 + Phase 4 + Phase 5
267
+
268
+ Should changes be split into multiple commits?
269
+ ├── Changes are unrelated → Yes — split by concern
270
+ ├── Changes form one atomic feature → No — single commit
271
+ └── Unsure → Ask user
272
+
273
+ Is there a breaking change?
274
+ ├── Yes → Use `feat!` or `fix!` type + BREAKING CHANGE footer
275
+ └── No → Standard type
276
+ ```
277
+
278
+ ---
279
+
280
+ ## Branch Naming Convention
281
+
282
+ ```
283
+ feature/short-description → new features
284
+ fix/short-description → bug fixes
285
+ refactor/short-description → refactoring
286
+ chore/dependency-upgrade → maintenance
287
+ release/v1.2.0 → release preparation
288
+ hotfix/critical-issue → urgent production fixes
289
+ ```
290
+
291
+ ---
292
+
293
+ ## Output Format
294
+
295
+ ```
296
+ 📝 Git Output
297
+ ─────────────────────────────────────────────────
298
+ Type: [commit | PR | changelog | release-notes]
299
+
300
+ ─── Commit Message ───────────────────────────────
301
+ feat(scope): short imperative description
302
+
303
+ Body explaining why this change was made.
304
+ What problem does it solve?
305
+
306
+ Closes #123
307
+
308
+ ─── PR Title ─────────────────────────────────────
309
+ feat(scope): short imperative description
310
+
311
+ ─── PR Description ───────────────────────────────
312
+ [Formatted markdown PR body]
313
+
314
+ ─── Changelog ────────────────────────────────────
315
+ [Formatted changelog section]
316
+ ```
317
+
318
+ ---
319
+
320
+ ## Validation Checklist
321
+
322
+ - [ ] Commit type is correct (feat/fix/refactor/etc.)
323
+ - [ ] Subject line ≤72 chars, imperative mood, no period at end
324
+ - [ ] Breaking changes flagged with `!` and `BREAKING CHANGE:` footer
325
+ - [ ] Body explains *why*, not just *what*
326
+ - [ ] Issue references included (`Closes #N`)
327
+ - [ ] PR description covers: summary, changes, testing, breaking changes
328
+ - [ ] Changelog uses correct sections (Added/Changed/Fixed/etc.)
329
+ - [ ] No vague messages ("fix stuff", "updates", "wip")
330
+
331
+ ---
332
+
333
+ ## Examples
334
+
335
+ See `examples/` folder.
@@ -0,0 +1,33 @@
1
+ ---
2
+ name: qk-documentation-system
3
+ purpose: Hệ thống tri thức AI: Rút trích Pattern/Decision và cập nhật AI Memory.
4
+ mode_supported: [enterprise]
5
+ input: [Docs & Code]
6
+ output: [Updated project memory (ADR, patterns)]
7
+ workflow: [1. Đọc Docs mới -> 2. Trích xuất Rule -> 3. Update Memory]
8
+ allowed_tools: [write_to_file]
9
+ handoff_to: [none]
10
+ ---
11
+
12
+ # 🛠️ qk-documentation-system - Quy Trình Vận Hành Chuẩn (SOP)
13
+
14
+ > **Mô tả:** Hệ thống tri thức AI: Rút trích Pattern/Decision và cập nhật AI Memory.
15
+
16
+ ## 🎯 1. Mục Tiêu (Goal)
17
+ - Hoàn thành thành công tác vụ được giao liên quan đến nhiệm vụ của skill.
18
+ - Đảm bảo chất lượng mã nguồn và tính nhất quán của hệ thống.
19
+
20
+ ## 🔄 2. Chuỗi Hành Động (Chain of Thought / SOP)
21
+ *(Bắt buộc AI phải suy nghĩ và làm theo đúng thứ tự)*
22
+ 1. **Phân tích (Analyze):** Thu thập ngữ cảnh và hiểu rõ yêu cầu đầu vào.
23
+ 2. **Lên kế hoạch (Plan):** Xác định các bước cần thay đổi/tạo mới dựa trên bộ luật (rules).
24
+ 3. **Thực thi (Execute):** Tiến hành sửa đổi mã nguồn hoặc tạo tài liệu.
25
+ 4. **Xác thực (Verify):** Đảm bảo đầu ra đáp ứng đúng yêu cầu và không vi phạm quy định.
26
+
27
+ ## 🛡️ 3. Ràng Buộc & Quy Tắc (Constraints)
28
+ - CẤM bỏ qua việc kiểm tra `qk-engineering-standard` trước khi viết code.
29
+ - Mọi quyết định kỹ thuật phải dựa trên nội dung tại phần Deep Knowledge (nếu có).
30
+
31
+ ## 🤝 4. Giao Thức Bàn Giao (Handoff Protocol)
32
+ - Đích đến: `none`
33
+ - Nội dung bàn giao: Chuyển toàn bộ ngữ cảnh và kết quả đã thực thi cho bước tiếp theo.
@@ -0,0 +1,171 @@
1
+ ---
2
+ name: qk-engineering-standard
3
+ purpose: Rút trích các bộ luật thép (Folder, Naming, State, Boundary) cần tuân thủ cho task.
4
+ mode_supported: [enterprise]
5
+ input: [Context]
6
+ output: [Validated Context + Rules]
7
+ workflow: [1. Đọc rules/frontend.md... -> 2. Gắn luật vào Context -> 3. Handoff]
8
+ allowed_tools: [read_file]
9
+ handoff_to: [[Target Execution Skill]]
10
+ ---
11
+
12
+ # 🛠️ qk-engineering-standard - Quy Trình Vận Hành Chuẩn (SOP)
13
+
14
+ > **Mô tả:** Rút trích các bộ luật thép (Folder, Naming, State, Boundary) cần tuân thủ cho task.
15
+
16
+ ## 🎯 1. Mục Tiêu (Goal)
17
+ - Hoàn thành thành công tác vụ được giao liên quan đến nhiệm vụ của skill.
18
+ - Đảm bảo chất lượng mã nguồn và tính nhất quán của hệ thống.
19
+
20
+ ## 🔄 2. Chuỗi Hành Động (Chain of Thought / SOP)
21
+ *(Bắt buộc AI phải suy nghĩ và làm theo đúng thứ tự)*
22
+ 1. **Phân tích (Analyze):** Thu thập ngữ cảnh và hiểu rõ yêu cầu đầu vào.
23
+ 2. **Lên kế hoạch (Plan):** Xác định các bước cần thay đổi/tạo mới dựa trên bộ luật (rules).
24
+ 3. **Thực thi (Execute):** Tiến hành sửa đổi mã nguồn hoặc tạo tài liệu.
25
+ 4. **Xác thực (Verify):** Đảm bảo đầu ra đáp ứng đúng yêu cầu và không vi phạm quy định.
26
+
27
+ ## 🛡️ 3. Ràng Buộc & Quy Tắc (Constraints)
28
+ - CẤM bỏ qua việc kiểm tra `qk-engineering-standard` trước khi viết code.
29
+ - Mọi quyết định kỹ thuật phải dựa trên nội dung tại phần Deep Knowledge (nếu có).
30
+
31
+ ## 🤝 4. Giao Thức Bàn Giao (Handoff Protocol)
32
+ - Đích đến: `[Target Execution Skill`
33
+ - Nội dung bàn giao: Chuyển toàn bộ ngữ cảnh và kết quả đã thực thi cho bước tiếp theo.
34
+
35
+ ## 📚 5. Kiến Thức Chuyên Sâu (Deep Knowledge)
36
+
37
+ *(Nền tảng kiến thức và quy tắc chi tiết kế thừa từ kỹ sư)*
38
+
39
+ ---
40
+
41
+
42
+
43
+ # State Management
44
+
45
+ > **Language rule:**
46
+ > Use English for: code, identifiers, file names, architecture terms, technical decisions.
47
+ > Use the user's language for: explanations, questions, summaries, and feedback.
48
+ > The user may write in any language — detect and match it automatically.
49
+
50
+ ---
51
+
52
+ ## Trigger
53
+
54
+ Activate this skill when:
55
+ - User asks to "store this data", "share state between components", or "cache API results"
56
+ - Prop drilling becomes excessive (>3 levels deep)
57
+ - Integrating complex UI interactions that need memory (e.g., shopping cart, multi-step wizard)
58
+ - Managing async server data and loading/error states
59
+
60
+ ---
61
+
62
+ ## Scope
63
+
64
+ - ✅ Decide which state layer to use based on the data's lifecycle and scope
65
+ - ✅ Implement local state (`useState`, `useReducer`, `ref`)
66
+ - ✅ Implement global UI state (Zustand, Pinia, Context, Redux)
67
+ - ✅ Implement server state (React Query, SWR, Apollo)
68
+ - ✅ Ensure state is immutable and updates correctly
69
+ - ✅ Prevent race conditions and stale state bugs
70
+
71
+ ---
72
+
73
+ ## Non-goals
74
+
75
+ - ❌ Do NOT introduce a new state management library if the project already uses one
76
+ - ❌ Do NOT put server data (API responses) in a global UI store (like Redux) if React Query is available
77
+ - ❌ Do NOT use global state for something that should be local (e.g., a modal's `isOpen` state)
78
+
79
+ ---
80
+
81
+ ## Workflow
82
+
83
+ ### Phase 1 — State Classification
84
+
85
+ Analyze the data the user wants to manage and classify it:
86
+
87
+ 1. **Local UI State:** Only needed by one component (e.g., toggle button, input value).
88
+ 2. **Shared UI State:** Needed by multiple components, but not saved to DB (e.g., dark mode, cart items, selected filters).
89
+ 3. **Server State:** Data fetched from an API. Needs caching, refetching, and loading states.
90
+ 4. **URL State:** Data that should be shareable or survive refresh (e.g., search query `?q=shoes`, current page).
91
+
92
+ ---
93
+
94
+ ### Phase 2 — Strategy Selection
95
+
96
+ Based on the classification and project stack (`project-audit`), choose the tool:
97
+
98
+ | State Type | Recommended Tool |
99
+ |------------|------------------|
100
+ | Local UI | `useState`, `useReducer` |
101
+ | Shared UI | Zustand, Pinia, Redux, Context API |
102
+ | Server | React Query, RTK Query, Apollo, SWR |
103
+ | URL | React Router `useSearchParams`, Next.js `useRouter` |
104
+
105
+ **Rule:** Always respect existing project conventions. If they use Redux for everything, use Redux.
106
+
107
+ ---
108
+
109
+ ### Phase 3 — Implementation
110
+
111
+ Generate the required code.
112
+
113
+ **Example for Server State (React Query):**
114
+ - Create query key factory
115
+ - Create custom hook (`useUserList`)
116
+ - Handle `isLoading`, `isError`, and `data`
117
+
118
+ **Example for Global UI State (Zustand):**
119
+ - Create store file (`userStore.ts`)
120
+ - Define state interface and initial values
121
+ - Define update actions (mutations)
122
+
123
+ ---
124
+
125
+ ### Phase 4 — Validation
126
+
127
+ - [ ] Does it update correctly without mutating state directly?
128
+ - [ ] Are unnecessary re-renders avoided?
129
+ - [ ] Is server state properly cached and invalidated after mutations?
130
+ - [ ] Is it placed in the correct directory (e.g., `src/store/` or `src/hooks/`)?
131
+
132
+ ---
133
+
134
+ ## Decision Tree
135
+
136
+ ```
137
+ Is the data fetched from a backend API?
138
+ ├── Yes → Use Server State (React Query / SWR / RTK Query)
139
+ └── No → Is the data only needed in one component and its direct children?
140
+ ├── Yes → Use Local State (`useState`)
141
+ └── No → Is the data used across many distinct branches of the app?
142
+ ├── Yes → Use Global State (Zustand / Redux)
143
+ └── No → Use Context API or lift state up
144
+ ```
145
+
146
+ ---
147
+
148
+ ## Output Format
149
+
150
+ ```
151
+ 🧠 State Management Plan
152
+ ─────────────────────────────────────────────────
153
+ State Type: [Server / Global UI / Local / URL]
154
+ Tool Used: [React Query / Zustand / useState / etc.]
155
+
156
+ Implementation:
157
+ ✅ [File 1] — [Store / Hook definition]
158
+ ✅ [File 2] — [Component integration]
159
+
160
+ ⚠️ Considerations:
161
+ • [Note on caching, stale time, or performance]
162
+
163
+ 🔗 Next Steps:
164
+ State is ready. Use the hook in your component.
165
+ ```
166
+
167
+ ---
168
+
169
+ ## Examples
170
+
171
+ See `examples/` folder.
@@ -0,0 +1,122 @@
1
+ # Backend Rules
2
+
3
+ - Define rules here.
4
+
5
+ ---
6
+
7
+ ## 🔄 [Merged from qk-backend-architecture]
8
+
9
+ # Backend Architecture
10
+
11
+ > **Language rule:**
12
+ > Use English for: code, identifiers, file names, architecture terms, technical decisions.
13
+ > Use the user's language for: explanations, questions, summaries, and feedback.
14
+ > The user may write in any language — detect and match it automatically.
15
+
16
+ ---
17
+
18
+ ## Trigger
19
+
20
+ Activate this skill when:
21
+ - Creating new backend API endpoints, services, or models
22
+ - User asks "where should I put this business logic?"
23
+ - Project audit flags mixed concerns (e.g., SQL queries inside a controller)
24
+ - Inheriting or setting up a Node.js, Python, or Go backend
25
+
26
+ ---
27
+
28
+ ## Scope
29
+
30
+ - ✅ Discover existing backend folder structure
31
+ - ✅ Enforce Layered Architecture (Controller → Service → Data Access)
32
+ - ✅ Enforce Domain/Module-based structure if applicable (`src/users/`, `src/orders/`)
33
+ - ✅ Define where validation, mapping, and error handling should live
34
+ - ✅ Validate file placement before code generation
35
+
36
+ ---
37
+
38
+ ## Non-goals
39
+
40
+ - ❌ Do NOT rewrite the architecture unless requested
41
+ - ❌ Do NOT write the actual database queries (delegate to `database-engineer`)
42
+ - ❌ Do NOT configure server infrastructure (delegate to `deployment`)
43
+
44
+ ---
45
+
46
+ ## Severity Levels
47
+
48
+ | Level | Meaning |
49
+ |-------|---------|
50
+ | P0 | Circular dependency or security bypass in architecture |
51
+ | P1 | Mixed concerns (e.g., ORM logic in route handler) |
52
+ | P2 | Inconsistent folder or file naming |
53
+ | P3 | Minor deviation from convention |
54
+
55
+ ---
56
+
57
+ ## Workflow
58
+
59
+ ### Phase 1 — Architecture Discovery
60
+
61
+ Analyze the project structure:
62
+ 1. **Classic MVC / Layered:** `controllers/`, `services/`, `models/`, `routes/`
63
+ 2. **Domain-Driven (Module):** `src/modules/user/{controller, service, repository}`
64
+ 3. **Framework-specific:** NestJS (`.controller.ts`, `.service.ts`), Django apps, Express monolithic.
65
+ 4. **Serverless:** `functions/`, `handlers/`
66
+
67
+ ---
68
+
69
+ ### Phase 2 — Rule Extraction
70
+
71
+ Extract conventions:
72
+ - **Routes/Controllers:** Should only handle HTTP req/res, params validation, and calling services. No business logic.
73
+ - **Services:** Pure business logic. Does not know about HTTP (`req`/`res`).
74
+ - **Repositories/Data Access:** Only layer that interacts with the DB.
75
+ - **Error Handling:** Centralized error middleware vs local try/catch.
76
+
77
+ ---
78
+
79
+ ### Phase 3 — File Placement & Routing
80
+
81
+ Map a new requirement to the architecture:
82
+
83
+ *Request: "Add an endpoint to update user profile"*
84
+ - Route: `PUT /api/users/:id` mapped in `src/routes/user.routes.ts`
85
+ - Controller: `updateProfile(req, res)` in `src/controllers/user.controller.ts`
86
+ - Service: `updateUserProfile(userId, data)` in `src/services/user.service.ts`
87
+
88
+ ---
89
+
90
+ ## Decision Tree
91
+
92
+ ```
93
+ Does the project group files by Layer or by Domain?
94
+ ├── Layer → Place in `src/controllers/` and `src/services/`
95
+ └── Domain → Place in `src/modules/users/`
96
+
97
+ Where does data validation happen?
98
+ ├── Middleware → Add Zod/Joi validation at the router level
99
+ └── Controller → Validate inside the controller function before calling service
100
+ ```
101
+
102
+ ---
103
+
104
+ ## Output Format
105
+
106
+ ```
107
+ 🏗️ Backend Architecture Plan
108
+ ─────────────────────────────────────────────────
109
+ Structure Type: [Layered / Domain-based / Framework-specific]
110
+
111
+ Layer Mapping:
112
+ ✅ Controller: [path/to/controller.ts] — handles HTTP
113
+ ✅ Service: [path/to/service.ts] — business logic
114
+ ✅ Repo/DB: [handled by database-engineer]
115
+
116
+ ⚠️ Constraints enforced:
117
+ • Do not pass `req` or `res` objects into the Service layer.
118
+ • Validate all inputs at the Controller/Route level.
119
+
120
+ 🔗 Next Steps:
121
+ Proceeding to implement the layers.
122
+ ```
@@ -0,0 +1,3 @@
1
+ # Database Rules
2
+
3
+ - Define rules here.