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-context-loader
4
- version: 9.1.0
4
+ version: 9.2.0
5
5
  status: stable
6
- description: "Tải context vẽ dependency graph chính xác trước khi code — ngăn hallucination kiến trúc."
6
+ description: "Khảo sát kiến trúc codebase, phân tích import graph, lập bản đồ phụ thuộc và tải context chính xác trước khi code — ngăn hallucination kiến trúc. Dùng skill này khi user nhắc đến: load context, understand project, vẽ dependency graph, analyze architecture, giải thích kiến trúc dự án, tìm hiểu codebase — kể cả khi chỉ hỏi 'dự án này tổ chức thế nào'."
7
7
  platforms: [antigravity, claude-code, cursor, windsurf, kilo-code]
8
8
 
9
9
  # ── V9: Classification ─────────────────────────────────────
@@ -22,19 +22,21 @@ complexity:
22
22
  has_external_dependency: false
23
23
  has_breaking_change: false
24
24
 
25
- triggers:
26
- - "load context"
27
- - "understand project"
28
- - "analyze architecture"
29
- - "vẽ dependency graph"
30
- - "build context"
25
+ triggers:
26
+ - "load context"
27
+ - "understand project"
28
+ - "vẽ dependency graph"
29
+ - "analyze architecture"
30
+ - "giải thích kiến trúc dự án"
31
+ - "tìm hiểu codebase"
32
+
31
33
 
32
34
  selection:
33
35
  priority: high
34
36
  confidence_threshold: 0.75
35
37
 
36
38
  # ── V8: References ─────────────────────────────────────────
37
- workflow: research
39
+ workflow: context-discovery
38
40
 
39
41
  rules:
40
42
  - global
@@ -46,15 +48,16 @@ tools:
46
48
  related_skills:
47
49
  - qk-feature-delivery
48
50
  - qk-orchestrator
51
+ - qk-project-memory
49
52
 
50
53
  knowledge_scope:
51
54
  owns:
52
55
  - project-context
53
56
  - architecture-discovery
57
+ - dependency-mapping
54
58
  references:
55
59
  - coding
56
60
  - repository-structure
57
- - anti-patterns
58
61
 
59
62
  # ── V8: Verification ───────────────────────────────────────
60
63
  verification:
@@ -74,417 +77,122 @@ produces: [context-graph]
74
77
  consumes: [source-code]
75
78
 
76
79
  token_budget:
77
- max_files_read: 5
78
- max_lines_per_read: 100
79
- max_shell_commands: 1
80
+ max_files_read: 10
81
+ max_lines_per_read: 150
82
+ max_shell_commands: 2
80
83
  stop_early: true
81
84
 
82
- exit_codes: [SUCCESS, BLOCKED, FAILED, PARTIAL]
85
+ exit_codes: [SUCCESS, BLOCKED, FAILED, PARTIAL]
83
86
  ---
84
87
 
85
- # qk-context-loader — Dependency Graph Builder
88
+ # qk-context-loader — Dependency Graph & Architecture Discovery
86
89
 
87
90
  > **Language rule:** Code, identifiers, file names → English. Explanations, summaries → Vietnamese.
88
91
 
89
- ## Memory Workflow
90
-
91
- ### 0. Self-Init Protocol (Khởi Tạo Bộ Nhớ Local & Gitignore)
92
- - 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:
93
- - **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.
94
- - **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.
95
-
96
- ---
97
-
98
- ### Pre-flight Retrieve (Trước khi thực thi)
99
- - Trước các task có tính lặp lại, debug, refactor, kiến trúc hoặc rủi ro cao:
100
- bắt buộc tra cứu:
101
- - `.ai-local/knowledge/index.yaml` (Private Local Knowledge)
102
-
103
- - Ưu tiên sử dụng các Knowledge đang có trạng thái `Active` thuộc:
104
- - Architecture
105
- - Hard Bug
106
- - Convention
107
- - Pattern
108
- - Tech Debt Pattern
109
- - 👉 *Domain Focus:* Pattern / Architecture (vd: sơ đồ phụ thuộc mô-đun, biểu đồ ngữ cảnh O(1)).
110
-
111
- - Memory chỉ đóng vai trò **Navigator (bản đồ chỉ đường)**.
112
- Không được xem Memory là Source of Truth.
113
- 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.
114
-
115
- ---
116
-
117
- ### Learning Flow (AI tự học có kiểm soát)
118
- - 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:
119
- - Hard Bug có khả năng tái diễn.
120
- - Pattern làm việc lặp lại trong dự án.
121
- - Convention hoặc quy tắc kiến trúc mới.
122
- - Quyết định Architecture quan trọng.
123
- - Tech Debt Pattern hoặc Code Smell có tính hệ thống.
124
- - 👉 *Domain Harvest:* Quyết định Architecture hoặc Pattern quan trọng khi ánh xạ dependency.
125
-
126
- - Candidate Memory chỉ là bản nháp quan sát, chưa phải tri thức chính thức.
127
- - Candidate Memory có thể lưu tạm tại: `.ai-local/candidates/`
128
- - AI không được tự động Promote Candidate Memory thành Project Knowledge.
129
-
130
- ---
131
-
132
- ### Post-flight Harvest (Đề xuất → Phê duyệt)
133
- Sau khi hoàn thành task:
134
- - AI đánh giá các Candidate Memory đã tạo.
135
- - Nếu phát hiện tri thức có giá trị tái sử dụng:
136
- - Đề xuất người dùng xem xét.
137
- - Gửi yêu cầu phê duyệt thông qua:
138
- - `/learn`
139
- - `qk-project-memory`
140
- - Chỉ sau khi được phê duyệt, Candidate Memory mới được chuyển thành Knowledge chính thức:
141
-
142
- ```
143
- .ai-local/candidates/ ──(Approve)──> .ai-local/knowledge/index.yaml
144
- ```
145
-
146
- - Project Knowledge phải được xem như tài sản kỹ thuật của dự án:
147
- - Có thể review, cập nhật, loại bỏ và có lịch sử thay đổi.
148
-
149
- ---
150
-
151
- ### Ignore (Không đưa vào Memory)
152
- Không lưu:
153
- - Trace log của một session đơn lẻ.
154
- - Temporary debugging data.
155
- - Output của một lần chạy test/scan.
156
- - Report health tạm thời của một đợt kiểm tra.
157
- - Lỗi nhỏ chỉ xảy ra một lần.
158
- - Thông tin không có khả năng tái sử dụng.
159
- - 👉 *Domain Ignore:* Cache đồ thị ngữ cảnh tạm thời của một lệnh tìm kiếm.
160
-
161
- ---
162
-
163
- ### Golden Rule
164
- > **AI được phép học, nhưng không được tự quyết định tri thức chính thức.**
165
- > **AI quan sát → Đề xuất → Con người phê duyệt → Dự án tiến hóa.**
166
-
167
- ---
168
-
169
-
170
-
171
- ### Pre-flight Retrieve (Trước khi thực thi)
172
- - Trước các task có tính lặp lại, debug, refactor, kiến trúc hoặc rủi ro cao:
173
- bắt buộc tra cứu:
174
- - `.agents/knowledge/index.yaml` (Shared Project Knowledge)
175
- - `.ai-local/knowledge/index.yaml` (Private Local Knowledge)
176
-
177
- - Ưu tiên sử dụng các Knowledge đang có trạng thái `Active` thuộc:
178
- - Architecture
179
- - Hard Bug
180
- - Convention
181
- - Pattern
182
- - Tech Debt Pattern
183
- - 👉 *Domain Focus:* Pattern / Architecture (vd: sơ đồ phụ thuộc mô-đun, biểu đồ ngữ cảnh O(1)).
184
-
185
- - Memory chỉ đóng vai trò **Navigator (bản đồ chỉ đường)**.
186
- Không được xem Memory là Source of Truth.
187
- 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.
188
-
189
- ---
190
-
191
- ### Learning Flow (AI tự học có kiểm soát)
192
- - 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:
193
- - Hard Bug có khả năng tái diễn.
194
- - Pattern làm việc lặp lại trong dự án.
195
- - Convention hoặc quy tắc kiến trúc mới.
196
- - Quyết định Architecture quan trọng.
197
- - Tech Debt Pattern hoặc Code Smell có tính hệ thống.
198
- - 👉 *Domain Harvest:* Quyết định Architecture hoặc Pattern quan trọng khi ánh xạ dependency.
199
-
200
- - Candidate Memory chỉ là bản nháp quan sát, chưa phải tri thức chính thức.
201
- - Candidate Memory có thể lưu tạm tại: `.ai-local/candidates/`
202
- - AI không được tự động Promote Candidate Memory thành Project Knowledge.
203
-
204
- ---
205
-
206
- ### Post-flight Harvest (Đề xuất → Phê duyệt)
207
- Sau khi hoàn thành task:
208
- - AI đánh giá các Candidate Memory đã tạo.
209
- - Nếu phát hiện tri thức có giá trị tái sử dụng:
210
- - Đề xuất người dùng xem xét.
211
- - Gửi yêu cầu phê duyệt thông qua:
212
- - `/learn`
213
- - `qk-project-memory`
214
- - Chỉ sau khi được phê duyệt, Candidate Memory mới được chuyển thành Knowledge chính thức:
215
-
216
- ```
217
- .ai-local/candidates/ ──(Approve)──> .agents/knowledge/index.yaml
218
- ```
219
-
220
- - Project Knowledge phải được xem như tài sản kỹ thuật của dự án:
221
- - Có thể review, cập nhật, loại bỏ và có lịch sử thay đổi.
222
-
223
- ---
224
-
225
- ### Ignore (Không đưa vào Memory)
226
- Không lưu:
227
- - Trace log của một session đơn lẻ.
228
- - Temporary debugging data.
229
- - Output của một lần chạy test/scan.
230
- - Report health tạm thời của một đợt kiểm tra.
231
- - Lỗi nhỏ chỉ xảy ra một lần.
232
- - Thông tin không có khả năng tái sử dụng.
233
- - 👉 *Domain Ignore:* Cache đồ thị ngữ cảnh tạm thời của một lệnh tìm kiếm.
234
-
235
- ---
236
-
237
- ### Golden Rule
238
- > **AI được phép học, nhưng không được tự quyết định tri thức chính thức.**
239
- > **AI quan sát → Đề xuất → Con người phê duyệt → Dự án tiến hóa.**
240
-
241
- ---
242
- ---
243
-
244
- ### Learning Flow (AI tự học có kiểm soát)
245
- - 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:
246
- - Hard Bug có khả năng tái diễn.
247
- - Pattern làm việc lặp lại trong dự án.
248
- - Convention hoặc quy tắc kiến trúc mới.
249
- - Quyết định Architecture quan trọng.
250
- - Tech Debt Pattern hoặc Code Smell có tính hệ thống.
251
- - 👉 *Domain Harvest:* Quyết định Architecture hoặc Pattern quan trọng khi ánh xạ dependency.
252
-
253
- - Candidate Memory chỉ là bản nháp quan sát, chưa phải tri thức chính thức.
254
- - Candidate Memory có thể lưu tạm tại: `.ai-local/candidates/`
255
- - AI không được tự động Promote Candidate Memory thành Project Knowledge.
256
-
257
- ---
258
-
259
- ### Post-flight Harvest (Đề xuất → Phê duyệt)
260
- Sau khi hoàn thành task:
261
- - AI đánh giá các Candidate Memory đã tạo.
262
- - Nếu phát hiện tri thức có giá trị tái sử dụng:
263
- - Đề xuất người dùng xem xét.
264
- - Gửi yêu cầu phê duyệt thông qua:
265
- - `/learn`
266
- - `qk-project-memory`
267
- - Chỉ sau khi được phê duyệt, Candidate Memory mới được chuyển thành Knowledge chính thức:
268
-
269
- ```
270
- .ai-local/candidates/ ──(Approve)──> .agents/knowledge/index.yaml
271
- ```
272
-
273
- - Project Knowledge phải được xem như tài sản kỹ thuật của dự án:
274
- - Có thể review, cập nhật, loại bỏ và có lịch sử thay đổi.
275
-
276
- ---
277
-
278
- ### Ignore (Không đưa vào Memory)
279
- Không lưu:
280
- - Trace log của một session đơn lẻ.
281
- - Temporary debugging data.
282
- - Output của một lần chạy test/scan.
283
- - Report health tạm thời của một đợt kiểm tra.
284
- - Lỗi nhỏ chỉ xảy ra một lần.
285
- - Thông tin không có khả năng tái sử dụng.
286
- - 👉 *Domain Ignore:* Cache đồ thị ngữ cảnh tạm thời của một lệnh tìm kiếm.
287
-
288
- ---
289
-
290
- ### Golden Rule
291
- > **AI được phép học, nhưng không được tự quyết định tri thức chính thức.**
292
- > **AI quan sát → Đề xuất → Con người phê duyệt → Dự án tiến hóa.**
293
-
294
- ---
295
- ---
296
-
297
- ### Learning Flow (AI tự học có kiểm soát)
298
- - 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:
299
- - Hard Bug có khả năng tái diễn.
300
- - Pattern làm việc lặp lại trong dự án.
301
- - Convention hoặc quy tắc kiến trúc mới.
302
- - Quyết định Architecture quan trọng.
303
- - Tech Debt Pattern hoặc Code Smell có tính hệ thống.
304
- - 👉 *Domain Harvest:* Quyết định Architecture hoặc Pattern quan trọng khi ánh xạ dependency.
305
-
306
- - Candidate Memory chỉ là bản nháp quan sát, chưa phải tri thức chính thức.
307
- - Candidate Memory có thể lưu tạm tại: `.ai-local/candidates/`
308
- - AI không được tự động Promote Candidate Memory thành Project Knowledge.
309
-
310
- ---
311
-
312
- ### Post-flight Harvest (Đề xuất → Phê duyệt)
313
- Sau khi hoàn thành task:
314
- - AI đánh giá các Candidate Memory đã tạo.
315
- - Nếu phát hiện tri thức có giá trị tái sử dụng:
316
- - Đề xuất người dùng xem xét.
317
- - Gửi yêu cầu phê duyệt thông qua:
318
- - `/learn`
319
- - `qk-project-memory`
320
- - Chỉ sau khi được phê duyệt, Candidate Memory mới được chuyển thành Knowledge chính thức:
321
-
322
- ```
323
- .ai-local/candidates/ ──(Approve)──> .agents/knowledge/index.yaml
324
- ```
325
-
326
- - Project Knowledge phải được xem như tài sản kỹ thuật của dự án:
327
- - Có thể review, cập nhật, loại bỏ và có lịch sử thay đổi.
328
-
329
- ---
330
-
331
- ### Ignore (Không đưa vào Memory)
332
- Không lưu:
333
- - Trace log của một session đơn lẻ.
334
- - Temporary debugging data.
335
- - Output của một lần chạy test/scan.
336
- - Report health tạm thời của một đợt kiểm tra.
337
- - Lỗi nhỏ chỉ xảy ra một lần.
338
- - Thông tin không có khả năng tái sử dụng.
339
- - 👉 *Domain Ignore:* Cache đồ thị ngữ cảnh tạm thời của một lệnh tìm kiếm.
340
-
341
- ---
342
-
343
- ### Golden Rule
344
- > **AI được phép học, nhưng không được tự quyết định tri thức chính thức.**
345
- > **AI quan sát → Đề xuất → Con người phê duyệt → Dự án tiến hóa.**
346
-
347
- ---
348
- ---
349
- ---
350
- ---
351
-
352
- ## Preconditions
353
- - [ ] Entry point file or module name is specified
354
- - [ ] Repository is accessible
355
-
356
- ```
357
- On missing precondition:
358
- EXIT: BLOCKED
359
- Message: "Vui lòng chỉ định entry point (file hoặc module cần map)."
360
- ```
92
+ Chịu trách nhiệm thấu hiểu cấu trúc dự án và thiết lập bản đồ phụ thuộc (Dependency Graph) chuẩn xác trước khi viết bất kỳ dòng code nào. **Mục tiêu tối thượng: Ngăn chặn triệt để AI hallucination về kiến trúc, conventions và vị trí đặt file**.
361
93
 
362
- ## Scope
363
- - ✅ Trace imports/exports from entry point
364
- - ✅ Build topological dependency graph (max depth 3)
365
- - ✅ Identify risk level per module
94
+ ---
366
95
 
367
- ## Non-Goals
368
- - ❌ Modify any code
369
- - ❌ Load `node_modules` or vendor directories
370
- - ❌ Guess file names — only follow explicit imports
371
- - ❌ Load entire repo (max 5 files)
96
+ ## Preconditions
372
97
 
373
- ## Priority Order
98
+ Trước khi chạy khảo sát, AI BẮT BUỘC kiểm tra:
374
99
 
375
- | Priority | Task | Skip Threshold |
376
- |----------|------|----------------|
377
- | P1 | Trace direct imports of entry point | Never |
378
- | P2 | Trace 2nd-level dependencies | Budget < 40% |
379
- | P3 | Identify shared/risky modules | Budget < 60% |
380
- | P4 | Annotate with risk levels | Budget < 70% |
100
+ - [ ] Workspace chứa nguồn thực tế (tồn tại ít nhất 1 file manifest: `package.json`, `go.mod`, `pyproject.toml`, `Cargo.toml`, `pom.xml`, v.v.).
101
+ - [ ] Xác định rõ phạm vi cần load: Toàn bộ repo (Full system) hay Module / Feature cụ thể.
102
+ - [ ] Đọc `.ai-local/knowledge/index.yaml` (nếu có) để tái sử dụng kiến thức đã lưu thay vì quét lại từ đầu.
381
103
 
382
- ## Workflow
104
+ *Nếu thư mục dự án hoàn toàn trống:*
105
+ → **EXIT: BLOCKED**
106
+ → Gợi ý: "Dự án chưa có mã nguồn. Vui lòng chạy `./qk-project-bootstrap` để khởi tạo framework và scaffolding ban đầu."
383
107
 
384
- ### Phase 1 — V1 Memory Consultation & Entry Point Analysis
108
+ ---
385
109
 
386
- **Steps:**
387
- 0. **Pre-flight V1 Memory Check:** Check for `.ai-local/knowledge/index.yaml` or `.agents/knowledge/index.yaml`. If an established architecture fact or module mapping exists in memory (`status: Active`), read it immediately to discover target symbols and entry points in seconds without performing redundant searches.
388
- 1. `grep_search` — search for import/export statements in entry file (only if not already resolved via V1 memory)
389
- 2. `view_file[StartLine:EndLine]` — read import block only (first ~30 lines)
390
- 3. List direct dependencies
110
+ ## Scope
391
111
 
392
- **Decision:**
393
- ```
394
- IF entry file found and imports readable
395
- go to Phase 2
112
+ ✅ Skill này làm:
113
+ - Đọc các tệp manifest và xác định chính xác Tech Stack, Runtime, State library, CSS framework, ORM.
114
+ - Khảo sát cây thư mục theo độ sâu hợp lý (Max depth = 3) để nhận diện mô hình tổ chức (Modular, Layered, Feature-sliced, Domain-driven, Monorepo).
115
+ - Phân tích Entry Point (`main`, `index`, `server`, `App`, router configuration).
116
+ - Lập sơ đồ phụ thuộc (Dependency Flow / Architecture Diagram bằng Mermaid) từ Controller/Route → Service/UseCase → Repository/Model.
117
+ - Trích xuất Conventions: đặt tên file, patterns xử lý lỗi, cơ chế Dependency Injection.
118
+ - Cập nhật thông tin vào bộ nhớ phiên làm việc của AI.
396
119
 
397
- ELSE IF entry file not found
398
- EXIT: BLOCKED ask for correct path
399
- ```
120
+ Skill này KHÔNG làm:
121
+ - Sửa đổi bất kỳ file nào trong dự án (`side_effects: read_only`).
122
+ - Dump toàn bộ code files vào context làm cạn kiệt token budget.
123
+ - Đánh giá chất lượng chi tiết code smells (thuộc `qk-project-health`).
400
124
 
401
- ### Phase 2 — Graph Traversal (Max Depth 3)
125
+ ---
402
126
 
403
- **Steps:**
404
- 1. For each direct dependency → `grep_search` for its imports
405
- 2. Build adjacency list: `{ file → [imports] }`
406
- 3. Stop at depth 3 OR max_files_read reached
127
+ ## Execution Steps
407
128
 
408
- **Decision:**
129
+ ### Step 1 — Nhận diện Tech Stack & Manifest
409
130
  ```
410
- IF depth 3 reached OR max_files_read (5) hit
411
- → EXIT: PARTIAL — note graph is truncated at depth N
412
-
413
- IF circular dependency detected
414
- Flag as [HIGH RISK] in output
415
- Continue building rest of graph
131
+ Inputs: Thư mục gốc của project
132
+ Actions:
133
+ - Đọc file manifest chính (package.json, pyproject.toml, go.mod...).
134
+ - Trích xuất: ngôn ngữ chính, runtime version, framework, ORM, state library, test runner.
135
+ - Đối chiếu với DEV_PROFILE.md nếu có.
136
+ Outputs: Stack Profile tóm tắt
416
137
  ```
417
138
 
418
- ### Phase 3Risk Assessment & Output
419
-
420
- **Steps:**
421
- 1. Identify: shared modules (imported by 3+ files) = HIGH risk to change
422
- 2. Identify: entry points with many dependents = CRITICAL to change carefully
423
- 3. **Identify: file trộn lẫn Server Logic và Client UI, hoặc vi phạm ranh giới bảo mật R-SEC-04 = Bắt buộc flag [HIGH RISK].**
424
- 4. Generate graph in standard JSON + Markdown format
425
-
426
- ## Output Format (Mandatory Schema)
427
-
428
- ```json
429
- {
430
- "entry": "src/modules/auth/auth.service.ts",
431
- "depth_reached": 3,
432
- "truncated": false,
433
- "nodes": [
434
- {
435
- "file": "src/modules/auth/auth.service.ts",
436
- "imports": ["src/common/jwt.util.ts", "src/users/users.repository.ts"],
437
- "exports": ["AuthService"],
438
- "risk_level": "high",
439
- "imported_by_count": 4
440
- }
441
- ],
442
- "risks": [
443
- {
444
- "file": "src/common/jwt.util.ts",
445
- "reason": "Imported by 6 modules — changes here have wide blast radius",
446
- "risk_level": "critical"
447
- }
448
- ]
449
- }
139
+ ### Step 2Khảo sát Cấu trúc Thư mục & Entry Points
140
+ ```
141
+ Actions:
142
+ - Chạy `list_dir` hoặc `find_by_name` với MaxDepth=2 trên src/ hoặc app/.
143
+ - Xác định vị trí các tầng:
144
+ - Routes / Controllers / API Handlers
145
+ - Business Logic / Services / Use Cases
146
+ - Data Access / Repositories / Entities / Models
147
+ - Shared / Utils / Components / Middleware
148
+ - Đọc entry point file chính (max 80 dòng đầu).
149
+ Outputs: Sơ đồ phân tầng kiến trúc (Architectural Layers)
450
150
  ```
451
151
 
452
- ## Evidence Format
152
+ ### Step 3 — Phân tích Luồng phụ thuộc (Dependency Tracing)
153
+ ```
154
+ Actions:
155
+ - Chọn 1 feature tiêu biểu, trace import statements từ UI/Controller xuống DB.
156
+ - Xác định:
157
+ - Có dùng Dependency Injection không?
158
+ - Shared types/DTOs nằm ở đâu?
159
+ - Data fetching pattern: Client-side hook, Server Component, hay REST client?
160
+ Outputs: Dependency Graph (Mermaid flowchart)
161
+ ```
453
162
 
163
+ ### Step 4 — Tổng hợp Context Report
454
164
  ```
455
- [RISK] path/to/file.ts
456
- Reason: [why this file is risky to change]
457
- Imported by: [N files]
458
- Exports: [key exports]
165
+ Actions:
166
+ - Xuất báo cáo ngắn gọn, súc tích (dưới 40 dòng) gồm:
167
+ 1. Kiến trúc tổng quan (Pattern & Style).
168
+ 2. Quy ước đặt file & Naming conventions.
169
+ 3. Đường đi của luồng dữ liệu (Data Flow).
170
+ 4. Sơ đồ Mermaid trực quan.
459
171
  ```
460
172
 
461
- ## Handoff Contract
173
+ ---
462
174
 
463
- ### Consumes
464
- ```json
465
- {
466
- "from": "user or qk-orchestrator",
467
- "required_fields": ["entry_point"],
468
- "optional_fields": ["max_depth", "exclude_patterns"]
469
- }
470
- ```
175
+ ## Prompt Template
471
176
 
472
- ### Produces
473
- ```json
474
- {
475
- "to": "qk-feature-delivery | qk-bug-resolution | qk-data-lifecycle | qk-api-lifecycle",
476
- "output_fields": ["dependency_graph_json", "risk_summary", "exit_code"]
477
- }
177
+ ```
178
+ Phạm vi: [Toàn bộ dự án / Module X / Tính năng Y]
179
+ Mục tiêu: [Tìm hiểu kiến trúc trước khi thêm feature / refactor / debug]
180
+ Câu hỏi cần: [Data flow đi như thế nào? / Types đặt ở đâu? / Service kết nối DB ra sao?]
478
181
  ```
479
182
 
480
- ## Exit Codes
481
-
482
- | Code | Meaning | When |
483
- |------|---------|------|
484
- | SUCCESS | Full graph built within depth limit | All imports traced |
485
- | PARTIAL | Graph truncated at token/depth limit | Note where it was cut |
486
- | BLOCKED | Entry point not found or inaccessible | Ask for correct path |
487
- | FAILED | Cannot determine architecture (circular imports, obfuscated code) | Report and escalate |
183
+ ### dụ theo Role:
488
184
 
489
- ---
185
+ **role: fullstack (Khảo sát Next.js 14 Monorepo)**
186
+ ```
187
+ Phạm vi: apps/web và packages/api
188
+ Mục tiêu: Nắm rõ cách web gọi API và chia sẻ types giữa FE và BE.
189
+ ```
190
+ → AI trace: `packages/api/src/routers` → xuất `tRPC router` → `apps/web/src/utils/trpc.ts` → import types trong `apps/web/src/app/page.tsx`.
191
+ → AI vẽ sơ đồ Mermaid luồng type-safe RPC từ client tới DB query.
490
192
 
193
+ **role: be (Khảo sát Clean Architecture NestJS)**
194
+ ```
195
+ Phạm vi: src/modules/orders
196
+ Mục tiêu: Hiểu luồng xử lý Order: DTO -> Controller -> UseCase -> Prisma Repository.
197
+ ```
198
+ → AI liệt kê cấu trúc layers, quy ước DTO validation, và cách inject repository vào service.