ai-developer-skill-os 9.1.1 → 9.3.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 (63) hide show
  1. package/.agents/AGENTS.md +139 -42
  2. package/.agents/DEV_PROFILE.md +95 -0
  3. package/.agents/registry/capability-graph.yml +171 -334
  4. package/.agents/registry/graph.json +52 -18
  5. package/.agents/registry/index.yaml +66 -12
  6. package/.agents/registry/skills-index.yml +204 -447
  7. package/.agents/rules/coding.md +23 -0
  8. package/.agents/rules/global.md +44 -30
  9. package/.agents/skills/_template/SKILL.md +2 -300
  10. package/.agents/skills/qk-access-policy/SKILL.md +98 -393
  11. package/.agents/skills/qk-agent-observability/SKILL.md +3 -359
  12. package/.agents/skills/qk-ai-builder/SKILL.md +132 -485
  13. package/.agents/skills/qk-api-consumer/SKILL.md +256 -0
  14. package/.agents/skills/qk-api-consumer/capability.yaml +21 -0
  15. package/.agents/skills/qk-api-consumer/evals/scorecard.yaml +29 -0
  16. package/.agents/skills/qk-api-lifecycle/SKILL.md +133 -376
  17. package/.agents/skills/qk-bug-resolution/SKILL.md +128 -481
  18. package/.agents/skills/qk-code-review/SKILL.md +142 -340
  19. package/.agents/skills/qk-context-loader/SKILL.md +99 -391
  20. package/.agents/skills/qk-data-engineer/SKILL.md +253 -0
  21. package/.agents/skills/qk-data-lifecycle/SKILL.md +89 -408
  22. package/.agents/skills/qk-db-optimizer/SKILL.md +102 -408
  23. package/.agents/skills/qk-design-system-engineering/SKILL.md +76 -381
  24. package/.agents/skills/qk-devops-platform/SKILL.md +77 -383
  25. package/.agents/skills/qk-docs/SKILL.md +88 -414
  26. package/.agents/skills/qk-engineering-standard/SKILL.md +4 -508
  27. package/.agents/skills/qk-fe-api-integration/SKILL.md +343 -263
  28. package/.agents/skills/qk-fe-api-integration/evals/scorecard.yaml +29 -29
  29. package/.agents/skills/qk-feature-delivery/SKILL.md +137 -365
  30. package/.agents/skills/qk-feature-delivery/evals/scorecard.yaml +1 -1
  31. package/.agents/skills/qk-frontend-architecture/SKILL.md +5 -399
  32. package/.agents/skills/qk-help/evals/scorecard.yaml +13 -13
  33. package/.agents/skills/qk-orchestrator/SKILL.md +63 -422
  34. package/.agents/skills/qk-orchestrator/references/routing-table.md +10 -14
  35. package/.agents/skills/qk-product-specification/SKILL.md +70 -399
  36. package/.agents/skills/qk-production-release/SKILL.md +80 -457
  37. package/.agents/skills/qk-project-audit/SKILL.md +174 -0
  38. package/.agents/skills/qk-project-bootstrap/SKILL.md +244 -392
  39. package/.agents/skills/qk-project-health/SKILL.md +97 -416
  40. package/.agents/skills/qk-project-memory/SKILL.md +76 -21
  41. package/.agents/skills/qk-refactor/SKILL.md +167 -304
  42. package/.agents/skills/qk-security-audit/SKILL.md +141 -383
  43. package/.agents/skills/qk-security-audit/capability.yaml +1 -2
  44. package/.agents/skills/qk-system-evolution/SKILL.md +343 -263
  45. package/.agents/skills/qk-system-evolution/evals/scorecard.yaml +26 -26
  46. package/.agents/skills/qk-test-engineering/SKILL.md +119 -429
  47. package/.agents/skills/qk-ui-audit/SKILL.md +73 -457
  48. package/.agents/skills/qk-ui-builder/SKILL.md +521 -482
  49. package/.agents/skills/qk-ui-system-builder/SKILL.md +68 -434
  50. package/.agents/skills/qk-upgrade/SKILL.md +301 -0
  51. package/.agents/skills/qk-upgrade/capability.yaml +24 -0
  52. package/.agents/skills/qk-upgrade/evals/scorecard.yaml +26 -0
  53. package/.agents/skills/qk-validation-gate/SKILL.md +4 -523
  54. package/.agents/skills/qk-web-quality-gate/SKILL.md +85 -383
  55. package/.agents/workflows/bug-resolution.yml +6 -6
  56. package/.agents/workflows/context-discovery.yml +94 -0
  57. package/.agents/workflows/feature-delivery.yml +8 -4
  58. package/.agents/workflows/refactor.yml +6 -3
  59. package/.agents/workflows/shared/quality-gate.yml +94 -0
  60. package/.agents/workflows/skin-governance.yml +115 -0
  61. package/README.md +152 -67
  62. package/package.json +2 -2
  63. package/tooling/build-registry.js +30 -8
@@ -1,9 +1,9 @@
1
- ---
1
+ ---
2
2
  # ── Identity ───────────────────────────────────────────────
3
3
  name: qk-bug-resolution
4
- version: 9.1.0
4
+ version: 9.2.0
5
5
  status: stable
6
- description: "Sửa lỗi (bugs) bằng chu trình khép kín: Quan sátGiả thuyếtBằng chứng Sửa."
6
+ description: "Sửa lỗi (bugs) bằng chu trình khép kín: Observe Hypothesize Evidence Fix Verify. Dùng skill này khi user nhắc đến: fix bug, sửa lỗi, crash, error, exception, not working, bị lỗi, debug — kể cả khi chỉ paste stack trace hoặc mô tả triệu chứng không nói rõ là \"bug\"."
7
7
  platforms: [antigravity, claude-code, cursor, windsurf, kilo-code]
8
8
 
9
9
  # ── V9: Classification ─────────────────────────────────────
@@ -22,12 +22,16 @@ complexity:
22
22
  has_external_dependency: false
23
23
  has_breaking_change: false
24
24
 
25
- triggers:
26
- - "fix bug"
27
- - "sửa lỗi"
28
- - "crash"
29
- - "error"
30
- - "not working"
25
+ triggers:
26
+ - "fix bug"
27
+ - "sửa lỗi"
28
+ - "crash"
29
+ - "error"
30
+ - "exception"
31
+ - "not working"
32
+ - "bị lỗi"
33
+ - "debug"
34
+
31
35
 
32
36
  selection:
33
37
  priority: high
@@ -46,7 +50,7 @@ tools:
46
50
 
47
51
  related_skills:
48
52
  - qk-context-loader
49
- - qk-validation-gate
53
+ - qk-test-engineering
50
54
 
51
55
  knowledge_scope:
52
56
  owns:
@@ -82,529 +86,172 @@ token_budget:
82
86
  max_shell_commands: 2
83
87
  stop_early: true
84
88
 
85
- exit_codes: [SUCCESS, BLOCKED, FAILED, PARTIAL]
89
+ exit_codes: [SUCCESS, BLOCKED, FAILED, PARTIAL]
86
90
  ---
87
91
 
88
92
  # qk-bug-resolution — Diagnose & Repair
89
93
 
90
94
  > **Language rule:** Code, identifiers, file names → English. Explanations, summaries → Vietnamese.
91
95
 
96
+ Chịu trách nhiệm chẩn đoán và khắc phục lỗi mã nguồn theo chu trình khép kín: **Observe (Quan sát) → Hypothesize (Giả thuyết) → Evidence (Bằng chứng) → Fix (Sửa chữa) → Verify (Xác thực)**. Tuyệt đối không đoán mò hoặc áp dụng "quick-hack" làm che giấu lỗi gốc.
97
+
92
98
  ---
93
99
 
94
- ## Memory Workflow
95
-
96
- ### 0. Self-Init Protocol (Khởi Tạo Bộ Nhớ Local & Gitignore)
97
- - Trước khi tra cứu hoặc lưu trữ tri thức, BẮT BUỘC kiểm tra sự tồn tại của thư mục `.ai-local/` tại gốc dự án:
98
- - **Tự động tạo mới:** Nếu `.ai-local/` chưa tồn tại, AI phải tự động tạo cấu trúc thư mục `.ai-local/knowledge/` (và file `index.yaml` nếu cần thiết) cùng `.ai-local/candidates/`. Tuyệt đối không ngưng chạy hay hỏi ý kiến người dùng về thao tác khởi tạo tiêu chuẩn này.
99
- - **Bảo mật Gitignore:** BẮT BUỘC kiểm tra file `.gitignore` của dự án, nếu chưa có dòng `.ai-local/` thì phải tự động thêm vào để tuyệt đối bảo mật tri thức cá nhân và tránh lộ lọt lên Git.
100
-
101
- ---
102
-
103
- ### Pre-flight Retrieve (Trước khi thực thi)
104
- - Trước các task có tính lặp lại, debug, refactor, kiến trúc hoặc rủi ro cao:
105
- bắt buộc tra cứu:
106
- - `.ai-local/knowledge/index.yaml` (Private Local Knowledge)
107
-
108
- - Ưu tiên sử dụng các Knowledge đang có trạng thái `Active` thuộc:
109
- - Architecture
110
- - Hard Bug
111
- - Convention
112
- - Pattern
113
- - Tech Debt Pattern
114
- - 👉 *Domain Focus:* Hard Bug (vd: lỗi memory leak, race condition, lỗi thư viện tương tự từng gặp).
115
-
116
- - Memory chỉ đóng vai trò **Navigator (bản đồ chỉ đường)**.
117
- Không được xem Memory là Source of Truth.
118
- Luôn xác minh lại bằng source code, configuration và trạng thái hiện tại của dự án trước khi áp dụng.
119
-
120
- ---
121
-
122
- ### Learning Flow (AI tự học có kiểm soát)
123
- - Trong quá trình làm việc, AI được phép tự phát hiện và tạo **Candidate Memory** khi nhận thấy:
124
- - Hard Bug có khả năng tái diễn.
125
- - Pattern làm việc lặp lại trong dự án.
126
- - Convention hoặc quy tắc kiến trúc mới.
127
- - Quyết định Architecture quan trọng.
128
- - Tech Debt Pattern hoặc Code Smell có tính hệ thống.
129
- - 👉 *Domain Harvest:* Hard Bug mới có khả năng tái diễn (vd: nguyên nhân sâu xa của crash/leak để phòng ngừa).
130
-
131
- - Candidate Memory chỉ là bản nháp quan sát, chưa phải tri thức chính thức.
132
- - Candidate Memory có thể lưu tạm tại: `.ai-local/candidates/`
133
- - AI không được tự động Promote Candidate Memory thành Project Knowledge.
134
-
135
- ---
136
-
137
- ### Post-flight Harvest (Đề xuất → Phê duyệt)
138
- Sau khi hoàn thành task:
139
- - AI đánh giá các Candidate Memory đã tạo.
140
- - Nếu phát hiện tri thức có giá trị tái sử dụng:
141
- - Đề xuất người dùng xem xét.
142
- - Gửi yêu cầu phê duyệt thông qua:
143
- - `/learn`
144
- - `qk-project-memory`
145
- - Chỉ sau khi được phê duyệt, Candidate Memory mới được chuyển thành Knowledge chính thức:
146
-
147
- ```
148
- .ai-local/candidates/ ──(Approve)──> .ai-local/knowledge/index.yaml
149
- ```
150
-
151
- - Project Knowledge phải được xem như tài sản kỹ thuật của dự án:
152
- - Có thể review, cập nhật, loại bỏ và có lịch sử thay đổi.
153
-
154
- ---
155
-
156
- ### Ignore (Không đưa vào Memory)
157
- Không lưu:
158
- - Trace log của một session đơn lẻ.
159
- - Temporary debugging data.
160
- - Output của một lần chạy test/scan.
161
- - Report health tạm thời của một đợt kiểm tra.
162
- - Lỗi nhỏ chỉ xảy ra một lần.
163
- - Thông tin không có khả năng tái sử dụng.
164
- - 👉 *Domain Ignore:* Lỗi nhỏ chỉ xảy ra một lần (vd: typo, quên import, thiếu ngoặc đơn giản).
165
-
166
- ---
167
-
168
- ### Golden Rule
169
- > **AI được phép học, nhưng không được tự quyết định tri thức chính thức.**
170
- > **AI quan sát → Đề xuất → Con người phê duyệt → Dự án tiến hóa.**
171
-
172
- ---
173
-
174
-
175
-
176
- ### Pre-flight Retrieve (Trước khi thực thi)
177
- - Trước các task có tính lặp lại, debug, refactor, kiến trúc hoặc rủi ro cao:
178
- bắt buộc tra cứu:
179
- - `.agents/knowledge/index.yaml` (Shared Project Knowledge)
180
- - `.ai-local/knowledge/index.yaml` (Private Local Knowledge)
181
-
182
- - Ưu tiên sử dụng các Knowledge đang có trạng thái `Active` thuộc:
183
- - Architecture
184
- - Hard Bug
185
- - Convention
186
- - Pattern
187
- - Tech Debt Pattern
188
- - 👉 *Domain Focus:* Hard Bug (vd: lỗi memory leak, race condition, lỗi thư viện tương tự từng gặp).
189
-
190
- - Memory chỉ đóng vai trò **Navigator (bản đồ chỉ đường)**.
191
- Không được xem Memory là Source of Truth.
192
- Luôn xác minh lại bằng source code, configuration và trạng thái hiện tại của dự án trước khi áp dụng.
193
-
194
- ---
195
-
196
- ### Learning Flow (AI tự học có kiểm soát)
197
- - Trong quá trình làm việc, AI được phép tự phát hiện và tạo **Candidate Memory** khi nhận thấy:
198
- - Hard Bug có khả năng tái diễn.
199
- - Pattern làm việc lặp lại trong dự án.
200
- - Convention hoặc quy tắc kiến trúc mới.
201
- - Quyết định Architecture quan trọng.
202
- - Tech Debt Pattern hoặc Code Smell có tính hệ thống.
203
- - 👉 *Domain Harvest:* Hard Bug mới có khả năng tái diễn (vd: nguyên nhân sâu xa của crash/leak để phòng ngừa).
204
-
205
- - Candidate Memory chỉ là bản nháp quan sát, chưa phải tri thức chính thức.
206
- - Candidate Memory có thể lưu tạm tại: `.ai-local/candidates/`
207
- - AI không được tự động Promote Candidate Memory thành Project Knowledge.
208
-
209
- ---
210
-
211
- ### Post-flight Harvest (Đề xuất → Phê duyệt)
212
- Sau khi hoàn thành task:
213
- - AI đánh giá các Candidate Memory đã tạo.
214
- - Nếu phát hiện tri thức có giá trị tái sử dụng:
215
- - Đề xuất người dùng xem xét.
216
- - Gửi yêu cầu phê duyệt thông qua:
217
- - `/learn`
218
- - `qk-project-memory`
219
- - Chỉ sau khi được phê duyệt, Candidate Memory mới được chuyển thành Knowledge chính thức:
220
-
221
- ```
222
- .ai-local/candidates/ ──(Approve)──> .agents/knowledge/index.yaml
223
- ```
224
-
225
- - Project Knowledge phải được xem như tài sản kỹ thuật của dự án:
226
- - Có thể review, cập nhật, loại bỏ và có lịch sử thay đổi.
227
-
228
- ---
229
-
230
- ### Ignore (Không đưa vào Memory)
231
- Không lưu:
232
- - Trace log của một session đơn lẻ.
233
- - Temporary debugging data.
234
- - Output của một lần chạy test/scan.
235
- - Report health tạm thời của một đợt kiểm tra.
236
- - Lỗi nhỏ chỉ xảy ra một lần.
237
- - Thông tin không có khả năng tái sử dụng.
238
- - 👉 *Domain Ignore:* Lỗi nhỏ chỉ xảy ra một lần (vd: typo, quên import, thiếu ngoặc đơn giản).
239
-
240
- ---
241
-
242
- ### Golden Rule
243
- > **AI được phép học, nhưng không được tự quyết định tri thức chính thức.**
244
- > **AI quan sát → Đề xuất → Con người phê duyệt → Dự án tiến hóa.**
245
-
246
- ---
247
- ---
248
-
249
- ### Learning Flow (AI tự học có kiểm soát)
250
- - Trong quá trình làm việc, AI được phép tự phát hiện và tạo **Candidate Memory** khi nhận thấy:
251
- - Hard Bug có khả năng tái diễn.
252
- - Pattern làm việc lặp lại trong dự án.
253
- - Convention hoặc quy tắc kiến trúc mới.
254
- - Quyết định Architecture quan trọng.
255
- - Tech Debt Pattern hoặc Code Smell có tính hệ thống.
256
- - 👉 *Domain Harvest:* Hard Bug mới có khả năng tái diễn (vd: nguyên nhân sâu xa của crash/leak để phòng ngừa).
257
-
258
- - Candidate Memory chỉ là bản nháp quan sát, chưa phải tri thức chính thức.
259
- - Candidate Memory có thể lưu tạm tại: `.ai-local/candidates/`
260
- - AI không được tự động Promote Candidate Memory thành Project Knowledge.
261
-
262
- ---
263
-
264
- ### Post-flight Harvest (Đề xuất → Phê duyệt)
265
- Sau khi hoàn thành task:
266
- - AI đánh giá các Candidate Memory đã tạo.
267
- - Nếu phát hiện tri thức có giá trị tái sử dụng:
268
- - Đề xuất người dùng xem xét.
269
- - Gửi yêu cầu phê duyệt thông qua:
270
- - `/learn`
271
- - `qk-project-memory`
272
- - Chỉ sau khi được phê duyệt, Candidate Memory mới được chuyển thành Knowledge chính thức:
273
-
274
- ```
275
- .ai-local/candidates/ ──(Approve)──> .agents/knowledge/index.yaml
276
- ```
277
-
278
- - Project Knowledge phải được xem như tài sản kỹ thuật của dự án:
279
- - Có thể review, cập nhật, loại bỏ và có lịch sử thay đổi.
280
-
281
- ---
282
-
283
- ### Ignore (Không đưa vào Memory)
284
- Không lưu:
285
- - Trace log của một session đơn lẻ.
286
- - Temporary debugging data.
287
- - Output của một lần chạy test/scan.
288
- - Report health tạm thời của một đợt kiểm tra.
289
- - Lỗi nhỏ chỉ xảy ra một lần.
290
- - Thông tin không có khả năng tái sử dụng.
291
- - 👉 *Domain Ignore:* Lỗi nhỏ chỉ xảy ra một lần (vd: typo, quên import, thiếu ngoặc đơn giản).
292
-
293
- ---
294
-
295
- ### Golden Rule
296
- > **AI được phép học, nhưng không được tự quyết định tri thức chính thức.**
297
- > **AI quan sát → Đề xuất → Con người phê duyệt → Dự án tiến hóa.**
298
-
299
- ---
300
- ---
301
-
302
- ### Learning Flow (AI tự học có kiểm soát)
303
- - Trong quá trình làm việc, AI được phép tự phát hiện và tạo **Candidate Memory** khi nhận thấy:
304
- - Hard Bug có khả năng tái diễn.
305
- - Pattern làm việc lặp lại trong dự án.
306
- - Convention hoặc quy tắc kiến trúc mới.
307
- - Quyết định Architecture quan trọng.
308
- - Tech Debt Pattern hoặc Code Smell có tính hệ thống.
309
- - 👉 *Domain Harvest:* Hard Bug mới có khả năng tái diễn (vd: nguyên nhân sâu xa của crash/leak để phòng ngừa).
310
-
311
- - Candidate Memory chỉ là bản nháp quan sát, chưa phải tri thức chính thức.
312
- - Candidate Memory có thể lưu tạm tại: `.ai-local/candidates/`
313
- - AI không được tự động Promote Candidate Memory thành Project Knowledge.
314
-
315
- ---
316
-
317
- ### Post-flight Harvest (Đề xuất → Phê duyệt)
318
- Sau khi hoàn thành task:
319
- - AI đánh giá các Candidate Memory đã tạo.
320
- - Nếu phát hiện tri thức có giá trị tái sử dụng:
321
- - Đề xuất người dùng xem xét.
322
- - Gửi yêu cầu phê duyệt thông qua:
323
- - `/learn`
324
- - `qk-project-memory`
325
- - Chỉ sau khi được phê duyệt, Candidate Memory mới được chuyển thành Knowledge chính thức:
326
-
327
- ```
328
- .ai-local/candidates/ ──(Approve)──> .agents/knowledge/index.yaml
329
- ```
330
-
331
- - Project Knowledge phải được xem như tài sản kỹ thuật của dự án:
332
- - Có thể review, cập nhật, loại bỏ và có lịch sử thay đổi.
333
-
334
- ---
335
-
336
- ### Ignore (Không đưa vào Memory)
337
- Không lưu:
338
- - Trace log của một session đơn lẻ.
339
- - Temporary debugging data.
340
- - Output của một lần chạy test/scan.
341
- - Report health tạm thời của một đợt kiểm tra.
342
- - Lỗi nhỏ chỉ xảy ra một lần.
343
- - Thông tin không có khả năng tái sử dụng.
344
- - 👉 *Domain Ignore:* Lỗi nhỏ chỉ xảy ra một lần (vd: typo, quên import, thiếu ngoặc đơn giản).
345
-
346
- ---
347
-
348
- ### Golden Rule
349
- > **AI được phép học, nhưng không được tự quyết định tri thức chính thức.**
350
- > **AI quan sát → Đề xuất → Con người phê duyệt → Dự án tiến hóa.**
351
-
352
- ---
353
- ---
354
- ---
355
- ---
356
-
357
100
  ## Preconditions
358
- - [ ] A specific symptom is provided (error message, wrong behavior, crash)
359
- - [ ] The affected file or feature area is identifiable
360
- - [ ] Reproduction steps or stack trace provided
361
101
 
362
- ```
363
- On missing precondition:
364
- EXIT: BLOCKED
365
- Message: "Cần thêm thông tin: [error message / stack trace / bước tái hiện lỗi]"
366
- ```
102
+ Trước khi sửa bất kỳ dòng code nào, AI BẮT BUỘC kiểm tra:
103
+
104
+ - [ ] Thu thập đầy đủ triệu chứng lỗi: error message, stack trace, hoặc mô tả hành vi sai lệch (reproduction steps).
105
+ - [ ] Xác định file/hàm nghi vấn đọc source code thực tế.
106
+ - [ ] Tái hiện hoặc tìm được bằng chứng trực tiếp xác nhận nguyên nhân gốc (root cause).
107
+ - [ ] Nếu không có đủ thông tin hoặc không thể xác định được nguyên nhân:
108
+ → **EXIT: BLOCKED**
109
+ → Báo cáo user yêu cầu bổ sung context, logs hoặc reproduction steps.
367
110
 
368
111
  ---
369
112
 
370
113
  ## Scope
371
- - ✅ Diagnose existing defects with concrete evidence
372
- - ✅ Apply minimal targeted patches directly to source files
373
- - ✅ Verify fix with evidence (static or runtime)
374
-
375
- ## Non-Goals
376
- - ❌ Refactor code outside the buggy area
377
- - ❌ Bypass ranh giới bảo mật Zero-Trust (R-SEC-04) chỉ để "làm cho chạy được".
378
- - ❌ Create Node.js/Python/shell scripts to apply patches — edit source files directly
379
- - ❌ Read entire files > 150 lines — use `grep_search` or targeted `view_file[StartLine:EndLine]`
380
- - ❌ Run shell commands > 2 times per cycle
381
- - ❌ Guess root cause without concrete evidence
382
- - ❌ Mark as done without verifying the fix
383
- - ❌ Proceed with MEDIUM confidence — only HIGH confidence is acceptable for fix
384
- - ❌ Use `?.` or `!` to silence errors instead of fixing root cause
385
114
 
386
- ---
115
+ ✅ Skill này làm:
116
+ - Phân tích stack traces, server logs, console errors.
117
+ - Điều tra nguyên nhân gốc rễ (Root Cause Analysis) tại tầng logic, type mismatch, hoặc concurrency.
118
+ - Đưa ra giải pháp khắc phục triệt để (surgical fix) nhắm đúng nguyên nhân gốc.
119
+ - Thêm hoặc cập nhật test cases để tái hiện bug và ngăn chặn hiện tượng hồi quy (regression).
120
+ - Bảo toàn hành vi ban đầu của các tính năng không liên quan.
387
121
 
388
- ## Priority Order
389
-
390
- | Priority | Check | Skip Threshold |
391
- |----------|-------|----------------|
392
- | P1 | Identify exact file:line of failure | Never |
393
- | P2 | Trace data flow to root cause | Budget < 30% → EXIT: BLOCKED |
394
- | P3 | Check adjacent code for similar bugs | Budget < 50% |
395
- | P4 | Suggest regression test | Budget < 70% |
122
+ Skill này KHÔNG làm:
123
+ - Viết lại toàn bộ module hoặc đổi kiến trúc lớn chỉ để sửa 1 bug (→ `qk-refactor`).
124
+ - Xây dựng thêm tính năng mới chưa từng tồn tại (→ `qk-feature-delivery`).
125
+ - Tự động thay đổi DB schema nếu chưa đánh giá tính tương thích ngược (→ `qk-data-lifecycle`).
396
126
 
397
127
  ---
398
128
 
399
- ## Workflow
400
-
401
- ### Phase 1 — Triage (Read Only)
129
+ ## Execution Steps
402
130
 
403
- **Steps:**
404
- 1. `grep_search` — search for error message, function name, or symptom keyword
405
- 2. `view_file[StartLine:EndLine]` — read ONLY the relevant section (≤ 150 lines)
406
- 3. Identify the exact file and approximate line of failure
407
-
408
- **Exit When:**
409
- - Exact file:line identified → go to Phase 2
410
- - `max_files_read` (3) reached without exact identification → EXIT: BLOCKED
411
-
412
- **Decision:**
131
+ ### Step 1 — Observe & Reproduce
413
132
  ```
414
- IF stack trace provided
415
- → Parse top frame inside project code → go to Phase 2
416
-
417
- ELSE IF error message provided
418
- grep_search for error string → go to Phase 2
419
-
420
- ELSE
421
- → EXIT: BLOCKED — ask for reproduction steps
133
+ Inputs: Error logs, Stack trace, Mô tả từ user
134
+ Actions:
135
+ - Phân tích vị trí file, dòng code gây lỗi.
136
+ - Xác định điều kiện biên (edge cases) hoặc trạng thái dữ liệu kích hoạt bug.
137
+ Output: Symptom breakdown & Target files
422
138
  ```
423
139
 
424
- **On Blocked:**
140
+ ### Step 2 — Hypothesize & Evidence Gathering
425
141
  ```
426
- EXIT: BLOCKED
427
- Missing: Reproduction steps or error output
428
- Questions:
429
- 1. Lỗi xảy ra bước nào? (URL / action / input)
430
- 2. Error message hoặc stack trace cụ thể gì?
431
- Recommended Assumptions: none — cannot proceed without this
142
+ Inputs: Target code, Runtime environment
143
+ Actions:
144
+ - Đặt giả thuyết về nguyên nhân cốt lõi (null pointer, race condition, state mutation, network failure).
145
+ - Đọc code liên quan để kiểm chứng giả thuyết (xem callers, callees, data flow).
146
+ Exit: BLOCKED nếu giả thuyết không bằng chứng logic chứng minh.
432
147
  ```
433
148
 
434
- ---
435
-
436
- ### Phase 2 — Root Cause Analysis
437
-
438
- **Steps:**
439
- 1. Read the identified file section (`view_file[StartLine:EndLine]`, ≤ 150 lines)
440
- 2. Trace: What condition triggers the failure?
441
- 3. Check context graph for blast radius assessment
442
- 4. Assign confidence level
443
-
444
- **Common Root Cause Categories:**
445
- - Logic error (wrong condition, wrong operator)
446
- - Null / undefined / missing data
447
- - Async timing or race condition
448
- - Type mismatch or stale state
449
- - API contract change
450
-
451
- **Decision:**
149
+ ### Step 3 — Surgical Fix
452
150
  ```
453
- IF root cause found with direct evidence (file:line + stack trace confirms)
454
- → Confidence: HIGH → go to Phase 3
455
-
456
- ELSE IF root cause still unclear after reading identified file
457
- Read 1 more file (budget check)
458
- Still unclear → EXIT: BLOCKED
459
-
460
- ELSE IF root cause inferred from pattern (no direct evidence)
461
- → EXIT: BLOCKED — cannot fix without concrete evidence
151
+ Inputs: Verified root cause
152
+ Actions:
153
+ - Sửa lỗi chính xác tại nơi phát sinh (surgical modification).
154
+ - Đảm bảo xử triệt để các edge cases liên đới.
155
+ - Giữ nguyên coding style quy ước hiện hữu của dự án.
156
+ Output: Targeted code fix
462
157
  ```
463
158
 
464
- ---
465
-
466
- ### Phase 3 — Apply Fix (Direct Edit Only)
467
-
468
- **Steps:**
469
- 1. Apply fix using `replace_file_content` or `multi_replace_file_content`
470
- - **NEVER** create a helper script to do the patching
471
- - Keep the change minimal smallest diff that resolves the issue
472
- 2. Re-read the fixed section to confirm correctness (static verification)
473
- 3. Run shell command ONLY if runtime verification is strictly required (counts toward max 2)
474
-
475
- **Exit When:**
476
- - Fix applied and verified statically → EXIT: SUCCESS
477
- - Fix applied but runtime verification needed and command budget exhausted → EXIT: FAILED — cannot verify
159
+ ### Step 4 — Verify & Prevent Regression
160
+ ```
161
+ Inputs: Targeted code fix
162
+ Actions:
163
+ - Kiểm tra xem lỗi đã được khắc phục hoàn toàn chưa.
164
+ - Chạy linter, typecheck unit tests liên quan.
165
+ - Đề xuất hoặc viết regression test để đảm bảo lỗi không tái diễn.
166
+ Exit: SUCCESS nếu verification pass không phát sinh side effects.
167
+ ```
478
168
 
479
169
  ---
480
170
 
481
- ## Confidence Model
171
+ ## Prompt Template
482
172
 
483
- | Level | Condition | Action |
484
- |-------|-----------|--------|
485
- | HIGH | Direct evidence — exact file:line + stack trace confirms it | Proceed with fix |
486
- | MEDIUM | Inferred from code patterns, similar bugs nearby | EXIT: BLOCKED — collect more evidence |
487
- | LOW | Assumption without code evidence | STOP — ask user before applying fix |
488
-
489
- ---
173
+ AI đọc `DEV_PROFILE.md` để biết stack. Paste đúng error — AI sẽ đọc code, không đoán mò.
490
174
 
491
- ## Severity
492
-
493
- | Level | Definition | Example |
494
- |-------|-----------|---------|
495
- | CRITICAL | Data loss / security / app crash | Hardcoded secret, unhandled null crash on login |
496
- | HIGH | Core feature broken, blocking users | API returns 500, form submission fails |
497
- | MEDIUM | Degraded UX, workaround exists | Wrong label, minor calculation off |
498
- | LOW | Cosmetic, non-blocking | Console.log left in code |
175
+ ```
176
+ Lỗi: [Error message / stack trace đầy đủ — paste nguyên văn]
177
+ Xảy ra khi: [Thao tác / điều kiện / input nào trigger lỗi]
178
+ Tần suất: [Luôn luôn / đôi khi / chỉ trên production / chỉ với user X]
179
+ File nghi ngờ: [Đường dẫn nếu biết]
180
+ Đã thử: [Những đã làm để AI không lặp lại]
181
+ ```
499
182
 
500
183
  ---
501
184
 
502
- ## Evidence Format
185
+ ### Theo Role — AI điều tra theo chiều sâu khác nhau:
503
186
 
187
+ **role: fe**
504
188
  ```
505
- [SEVERITY] path/to/file.ts:LINE
506
- Reason: [why this causes the bug]
507
- Impact: [which modules/users are affected]
508
- Confidence: [HIGH|MEDIUM|LOW]
509
- Fix: [what was changed]
189
+ Lỗi: Uncaught TypeError: Cannot read properties of null (reading 'userId')
190
+ at ProfileCard.tsx:47
191
+ Xảy ra khi: Vào /profile sau khi logout rồi login lại bằng account khác
192
+ Tần suất: Luôn luôn reproduce được
193
+ File nghi ngờ: src/components/ProfileCard.tsx, src/store/authStore.ts
194
+ Đã thử: Thêm null check ở line 47 nhưng lỗi chuyển sang line 52
510
195
  ```
196
+ → AI điều tra: stale state trong Zustand/Redux khi re-login, component lifecycle
197
+ vs store reset timing, race condition giữa auth state và component render.
511
198
 
512
- **Example:**
199
+ **role: be**
513
200
  ```
514
- [HIGH] src/services/auth.service.ts:87
515
- Reason: Missing null check on `user.profile` crashes when profile is not yet loaded
516
- Impact: Affects all login flows; 100% of users hitting this path
517
- Confidence: HIGH
518
- Fix: Added `user.profile?.email ?? ''` guard
201
+ Lỗi: PrismaClientKnownRequestError: Unique constraint failed on field `email`
202
+ at POST /api/auth/registerstatus 500 thay 409
203
+ Xảy ra khi: Register với email đã tồn tại
204
+ Tần suất: Luôn luôn
205
+ File nghi ngờ: src/routes/auth/register.ts
206
+ Đã thử: Chưa thử gì, mới phát hiện
519
207
  ```
208
+ → AI điều tra: missing error type guard cho Prisma errors, HTTP status code mapping,
209
+ idempotency của endpoint, có nên check trước (findUnique) hay catch lỗi.
520
210
 
521
- ---
522
-
523
- ## Retry Policy
524
-
211
+ **role: fullstack**
525
212
  ```
526
- Fix applied
527
- └─ Static verification (re-read fixed section)
528
- ├─ PASS EXIT: SUCCESS
529
- └─ Issue detected attempt 1 correction
530
- └─ Re-verify
531
- ├─ PASS → EXIT: SUCCESS
532
- └─ FAIL → EXIT: FAILED + report both attempts
533
- └─ Do NOT attempt 3rd fix — ESCALATE to user
213
+ Lỗi: Optimistic update trên FE hiện sai data, sau 2s mới sync về đúng
214
+ Xảy ra khi: Xóa item trong danh sách → item biến mất → reload lại → item vẫn còn
215
+ Tần suất: Chỉ xảy ra khi network chậm (> 1s)
216
+ File nghi ngờ: FE: useDeleteItem.ts / BE: DELETE /api/items/:id
217
+ Đã thử: Đã kiểm tra BE trả 200 đúng
534
218
  ```
219
+ → AI điều tra: React Query mutation onMutate/onError/onSettled sequence,
220
+ cache invalidation timing, BE rollback khi constraint violation,
221
+ contract mismatch giữa FE optimistic state và BE response.
535
222
 
536
- ---
537
-
538
- ## Escalation Rules
539
-
223
+ **role: data**
540
224
  ```
541
- BLOCKED: [Specific reason]
542
- Missing:
543
- - [Stack trace / error message / reproduction steps]
544
- Questions:
545
- 1. Lỗi xuất hiện khi nào? (action/URL/input cụ thể)
546
- 2. Lỗi tái hiện được không?
547
- Recommended Assumptions (if proceeding without full info):
548
- - [Safe assumption based on available context]
225
+ Lỗi: DuplicateKeyError trên BigQuery sau khi re-run DAG ngày 2024-01-15
226
+ Job: daily_sales_load — task: load_to_bq
227
+ Xảy ra khi: Manual re-run sau khi pipeline fail giữa chừng
228
+ Tần suất: Mỗi lần re-run partial load
229
+ File nghi ngờ: dags/daily_sales_load.py, transforms/sales_transform.sql
230
+ Đã thử: Xóa data ngày đó trên BQ rồi re-run — OK, nhưng không scalable
549
231
  ```
232
+ → AI điều tra: idempotency gap (thiếu MERGE/UPSERT), partition-based delete trước load,
233
+ task atomicity design, watermark checkpoint bị reset sai.
550
234
 
551
- ---
552
-
553
- ## Handoff Contract
554
-
555
- ### Consumes
556
- ```json
557
- {
558
- "from": "user or qk-orchestrator",
559
- "required_fields": ["symptom_description", "context_graph"],
560
- "optional_fields": ["stack_trace", "error_message", "affected_file"]
561
- }
235
+ **role: ai-engineer**
562
236
  ```
563
-
564
- ### Produces
565
- ```json
566
- {
567
- "to": "user",
568
- "output_fields": ["changed_files", "root_cause", "impact", "severity", "confidence", "exit_code"]
569
- }
237
+ Lỗi: RAG trả lời sai — cite đúng document nhưng nội dung không liên quan
238
+ Xảy ra khi: Câu hỏi có nhiều từ khóa overlap với nhiều document khác nhau
239
+ Tần suất: ~30% queries liên quan đến chủ đề "pricing"
240
+ File nghi ngờ: retrieval/vector_search.py, prompts/rag_system.txt
241
+ Đã thử: Tăng top_k từ 3 lên 5 — không cải thiện
570
242
  ```
243
+ → AI điều tra: embedding model semantic mismatch, chunk boundary cắt mất context,
244
+ thiếu reranking layer, system prompt không enforce grounding,
245
+ cần hybrid search (BM25 + dense) cho domain-specific terms.
571
246
 
572
- ---
573
-
574
- ## Output Format
575
-
247
+ **role: devops**
576
248
  ```
577
- 🐛 Bug Report
578
- ─────────────────────────────────────────────────
579
- Symptom: [What broke + how to reproduce]
580
- Root cause: [file:line exact reason]
581
- Severity: [CRITICAL | HIGH | MEDIUM | LOW]
582
- Confidence: [HIGH | MEDIUM | LOW]
583
- Impact: [Which modules/users affected]
584
-
585
- 🔧 Fix Applied
586
- ─────────────────────────────────────────────────
587
- File: [path/to/file.ts]
588
- Change: [What changed and why it's minimal]
589
-
590
- ✅ Verification
591
- ─────────────────────────────────────────────────
592
- Static: [Re-read section — looks correct]
593
- Runtime: [PASS | SKIPPED — reason]
594
-
595
- Exit Code: [SUCCESS | PARTIAL | BLOCKED | FAILED]
249
+ Lỗi: GitHub Actions deploy job fail: "Error: EACCES: permission denied, open '/app/logs'"
250
+ Stage: production — chỉ xảy ra sau khi update Docker base image
251
+ Xảy ra khi: Deploy lên production container
252
+ Tần suất: 100% sau khi merge PR #247
253
+ File nghi ngờ: Dockerfile, docker-compose.prod.yml, .github/workflows/deploy.yml
254
+ Đã thử: Revert base image — OK, nhưng cần base image mới để patch CVE
596
255
  ```
597
-
598
- ---
599
-
600
- ## Exit Codes
601
-
602
- | Code | Meaning | When |
603
- |------|---------|------|
604
- | SUCCESS | Bug fixed and verified | Fix applied + static/runtime check passed |
605
- | PARTIAL | Fix applied, verification inconclusive | Budget exhausted or environment inaccessible |
606
- | BLOCKED | Cannot diagnose without more info | Missing stack trace / reproduction steps |
607
- | FAILED | Fix attempted, issue persists after 2 retries OR budget exhausted without verification | Complex race condition or architectural issue |
608
-
609
- ---
610
-
256
+ → AI điều tra: USER directive trong Dockerfile thay đổi giữa image versions,
257
+ volume mount permission, non-root user setup, security vs functionality trade-off.