ai-developer-skill-os 9.1.2 → 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 +37 -19
  5. package/.agents/registry/index.yaml +59 -13
  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 -377
  10. package/.agents/skills/qk-access-policy/SKILL.md +98 -473
  11. package/.agents/skills/qk-agent-observability/SKILL.md +3 -439
  12. package/.agents/skills/qk-ai-builder/SKILL.md +132 -565
  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 -456
  17. package/.agents/skills/qk-bug-resolution/SKILL.md +128 -561
  18. package/.agents/skills/qk-code-review/SKILL.md +142 -420
  19. package/.agents/skills/qk-context-loader/SKILL.md +99 -471
  20. package/.agents/skills/qk-data-engineer/SKILL.md +119 -340
  21. package/.agents/skills/qk-data-lifecycle/SKILL.md +89 -488
  22. package/.agents/skills/qk-db-optimizer/SKILL.md +102 -488
  23. package/.agents/skills/qk-design-system-engineering/SKILL.md +76 -461
  24. package/.agents/skills/qk-devops-platform/SKILL.md +77 -463
  25. package/.agents/skills/qk-docs/SKILL.md +88 -494
  26. package/.agents/skills/qk-engineering-standard/SKILL.md +4 -588
  27. package/.agents/skills/qk-fe-api-integration/SKILL.md +343 -343
  28. package/.agents/skills/qk-fe-api-integration/evals/scorecard.yaml +29 -29
  29. package/.agents/skills/qk-feature-delivery/SKILL.md +137 -445
  30. package/.agents/skills/qk-feature-delivery/evals/scorecard.yaml +1 -1
  31. package/.agents/skills/qk-frontend-architecture/SKILL.md +5 -479
  32. package/.agents/skills/qk-help/evals/scorecard.yaml +13 -13
  33. package/.agents/skills/qk-orchestrator/SKILL.md +63 -502
  34. package/.agents/skills/qk-orchestrator/references/routing-table.md +10 -14
  35. package/.agents/skills/qk-product-specification/SKILL.md +70 -479
  36. package/.agents/skills/qk-production-release/SKILL.md +80 -537
  37. package/.agents/skills/qk-project-audit/SKILL.md +174 -0
  38. package/.agents/skills/qk-project-bootstrap/SKILL.md +243 -471
  39. package/.agents/skills/qk-project-health/SKILL.md +97 -496
  40. package/.agents/skills/qk-project-memory/SKILL.md +76 -21
  41. package/.agents/skills/qk-refactor/SKILL.md +167 -384
  42. package/.agents/skills/qk-security-audit/SKILL.md +141 -463
  43. package/.agents/skills/qk-security-audit/capability.yaml +1 -2
  44. package/.agents/skills/qk-system-evolution/SKILL.md +343 -343
  45. package/.agents/skills/qk-system-evolution/evals/scorecard.yaml +26 -26
  46. package/.agents/skills/qk-test-engineering/SKILL.md +119 -509
  47. package/.agents/skills/qk-ui-audit/SKILL.md +73 -537
  48. package/.agents/skills/qk-ui-builder/SKILL.md +521 -482
  49. package/.agents/skills/qk-ui-system-builder/SKILL.md +68 -514
  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 -603
  54. package/.agents/skills/qk-web-quality-gate/SKILL.md +85 -463
  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-ai-builder
4
- version: 9.1.0
4
+ version: 9.2.0
5
5
  status: stable
6
- description: "Thiết kế Governed AI Agent & RAG pipelines theo chuẩn V8.2 Đóng gói bằng capability.yaml, data discipline 4-folder Eval Pipeline."
6
+ description: "Thiết kế implement AI Agent hoặc RAG pipeline với eval criteria bắt buộc. Dùng skill này khi user nhắc đến: build ai, rag pipeline, prompt engineering, viết prompt, thiết kế agent, llm, vector database, embedding, retrieval, chatbot, ai logic, tạo skill — kể cả khi chỉ nói \"muốn AI trả lời từ tài liệu của mình\"."
7
7
  platforms: [antigravity, claude-code, cursor, windsurf, kilo-code]
8
8
 
9
9
  # ── V9: Classification ─────────────────────────────────────
@@ -21,12 +21,20 @@ complexity:
21
21
  has_external_dependency: true
22
22
  has_breaking_change: false
23
23
 
24
- triggers:
25
- - "build ai"
26
- - "viết prompt"
27
- - "thiết kế bot"
28
- - "ai logic"
29
- - "tạo skill"
24
+ triggers:
25
+ - "build ai"
26
+ - "rag pipeline"
27
+ - "prompt engineering"
28
+ - "viết prompt"
29
+ - "thiết kế agent"
30
+ - "llm"
31
+ - "vector database"
32
+ - "embedding"
33
+ - "retrieval"
34
+ - "chatbot"
35
+ - "ai logic"
36
+ - "tạo skill"
37
+
30
38
 
31
39
  # ── V8: References ─────────────────────────────────────────
32
40
  workflow: feature-delivery
@@ -78,610 +86,169 @@ token_budget:
78
86
  max_shell_commands: 0
79
87
  stop_early: true
80
88
 
81
- exit_codes: [SUCCESS, BLOCKED, FAILED, PARTIAL]
89
+ exit_codes: [SUCCESS, BLOCKED, FAILED, PARTIAL]
82
90
  ---
83
91
 
84
92
  # qk-ai-builder — AI Integration Designer
85
93
 
86
94
  > **Language rule:** Code, identifiers, file names → English. Explanations, summaries → Vietnamese.
87
95
 
88
- ---
89
-
90
- ## Memory Workflow
91
-
92
- ### 0. Self-Init Protocol (Khởi Tạo Bộ Nhớ Local & Gitignore)
93
- - 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:
94
- - **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.
95
- - **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.
96
-
97
- ---
98
-
99
- ### Pre-flight Retrieve (Trước khi thực thi)
100
- - Trước các task có tính lặp lại, debug, refactor, kiến trúc hoặc rủi ro cao:
101
- bắt buộc tra cứu:
102
- - `.ai-local/knowledge/index.yaml` (Private Local Knowledge)
103
-
104
- - Ưu tiên sử dụng các Knowledge đang có trạng thái `Active` thuộc:
105
- - Architecture
106
- - Hard Bug
107
- - Convention
108
- - Pattern
109
- - Tech Debt Pattern
110
- - 👉 *Domain Focus:* Architecture/Pattern (vd: cấu hình provider LLM, chuẩn RAG pipeline, prompt template).
111
-
112
- - Memory chỉ đóng vai trò **Navigator (bản đồ chỉ đường)**.
113
- Không được xem Memory là Source of Truth.
114
- 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.
115
-
116
- ---
117
-
118
- ### Learning Flow (AI tự học có kiểm soát)
119
- - 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:
120
- - Hard Bug có khả năng tái diễn.
121
- - Pattern làm việc lặp lại trong dự án.
122
- - Convention hoặc quy tắc kiến trúc mới.
123
- - Quyết định Architecture quan trọng.
124
- - Tech Debt Pattern hoặc Code Smell có tính hệ thống.
125
- - 👉 *Domain Harvest:* Pattern hoặc Convention mới (vd: quy chuẩn JSON schema cho prompt, scorecard định lượng).
126
-
127
- - Candidate Memory chỉ là bản nháp quan sát, chưa phải tri thức chính thức.
128
- - Candidate Memory có thể lưu tạm tại: `.ai-local/candidates/`
129
- - AI không được tự động Promote Candidate Memory thành Project Knowledge.
130
-
131
- ---
132
-
133
- ### Post-flight Harvest (Đề xuất → Phê duyệt)
134
- Sau khi hoàn thành task:
135
- - AI đánh giá các Candidate Memory đã tạo.
136
- - Nếu phát hiện tri thức có giá trị tái sử dụng:
137
- - Đề xuất người dùng xem xét.
138
- - Gửi yêu cầu phê duyệt thông qua:
139
- - `/learn`
140
- - `qk-project-memory`
141
- - Chỉ sau khi được phê duyệt, Candidate Memory mới được chuyển thành Knowledge chính thức:
142
-
143
- ```
144
- .ai-local/candidates/ ──(Approve)──> .ai-local/knowledge/index.yaml
145
- ```
146
-
147
- - Project Knowledge phải được xem như tài sản kỹ thuật của dự án:
148
- - Có thể review, cập nhật, loại bỏ và có lịch sử thay đổi.
149
-
150
- ---
151
-
152
- ### Ignore (Không đưa vào Memory)
153
- Không lưu:
154
- - Trace log của một session đơn lẻ.
155
- - Temporary debugging data.
156
- - Output của một lần chạy test/scan.
157
- - Report health tạm thời của một đợt kiểm tra.
158
- - Lỗi nhỏ chỉ xảy ra một lần.
159
- - Thông tin không có khả năng tái sử dụng.
160
- - 👉 *Domain Ignore:* Các thao tác tinh chỉnh từ ngữ prompt tạm thời cho 1 task đơn lẻ.
161
-
162
- ---
163
-
164
- ### Golden Rule
165
- > **AI được phép học, nhưng không được tự quyết định tri thức chính thức.**
166
- > **AI quan sát → Đề xuất → Con người phê duyệt → Dự án tiến hóa.**
167
-
168
- ---
169
-
170
-
171
-
172
- ### 0. Self-Init Protocol (Khởi Tạo Bộ Nhớ Local & Gitignore)
173
- - 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:
174
- - **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.
175
- - **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.
176
-
177
- ---
178
-
179
- ### Pre-flight Retrieve (Trước khi thực thi)
180
- - Trước các task có tính lặp lại, debug, refactor, kiến trúc hoặc rủi ro cao:
181
- bắt buộc tra cứu:
182
- - `.ai-local/knowledge/index.yaml` (Private Local Knowledge)
183
-
184
- - Ưu tiên sử dụng các Knowledge đang có trạng thái `Active` thuộc:
185
- - Architecture
186
- - Hard Bug
187
- - Convention
188
- - Pattern
189
- - Tech Debt Pattern
190
- - 👉 *Domain Focus:* Architecture/Pattern (vd: cấu hình provider LLM, chuẩn RAG pipeline, prompt template).
191
-
192
- - Memory chỉ đóng vai trò **Navigator (bản đồ chỉ đường)**.
193
- Không được xem Memory là Source of Truth.
194
- 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.
195
-
196
- ---
197
-
198
- ### Learning Flow (AI tự học có kiểm soát)
199
- - 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:
200
- - Hard Bug có khả năng tái diễn.
201
- - Pattern làm việc lặp lại trong dự án.
202
- - Convention hoặc quy tắc kiến trúc mới.
203
- - Quyết định Architecture quan trọng.
204
- - Tech Debt Pattern hoặc Code Smell có tính hệ thống.
205
- - 👉 *Domain Harvest:* Pattern hoặc Convention mới (vd: quy chuẩn JSON schema cho prompt, scorecard định lượng).
206
-
207
- - Candidate Memory chỉ là bản nháp quan sát, chưa phải tri thức chính thức.
208
- - Candidate Memory có thể lưu tạm tại: `.ai-local/candidates/`
209
- - AI không được tự động Promote Candidate Memory thành Project Knowledge.
210
-
211
- ---
212
-
213
- ### Post-flight Harvest (Đề xuất → Phê duyệt)
214
- Sau khi hoàn thành task:
215
- - AI đánh giá các Candidate Memory đã tạo.
216
- - Nếu phát hiện tri thức có giá trị tái sử dụng:
217
- - Đề xuất người dùng xem xét.
218
- - Gửi yêu cầu phê duyệt thông qua:
219
- - `/learn`
220
- - `qk-project-memory`
221
- - Chỉ sau khi được phê duyệt, Candidate Memory mới được chuyển thành Knowledge chính thức:
222
-
223
- ```
224
- .ai-local/candidates/ ──(Approve)──> .ai-local/knowledge/index.yaml
225
- ```
226
-
227
- - Project Knowledge phải được xem như tài sản kỹ thuật của dự án:
228
- - Có thể review, cập nhật, loại bỏ và có lịch sử thay đổi.
229
-
230
- ---
231
-
232
- ### Ignore (Không đưa vào Memory)
233
- Không lưu:
234
- - Trace log của một session đơn lẻ.
235
- - Temporary debugging data.
236
- - Output của một lần chạy test/scan.
237
- - Report health tạm thời của một đợt kiểm tra.
238
- - Lỗi nhỏ chỉ xảy ra một lần.
239
- - Thông tin không có khả năng tái sử dụng.
240
- - 👉 *Domain Ignore:* Các thao tác tinh chỉnh từ ngữ prompt tạm thời cho 1 task đơn lẻ.
241
-
242
- ---
243
-
244
- ### Golden Rule
245
- > **AI được phép học, nhưng không được tự quyết định tri thức chính thức.**
246
- > **AI quan sát → Đề xuất → Con người phê duyệt → Dự án tiến hóa.**
247
-
248
- ---
249
-
250
-
251
-
252
- ### Pre-flight Retrieve (Trước khi thực thi)
253
- - Trước các task có tính lặp lại, debug, refactor, kiến trúc hoặc rủi ro cao:
254
- bắt buộc tra cứu:
255
- - `.agents/knowledge/index.yaml` (Shared Project Knowledge)
256
- - `.ai-local/knowledge/index.yaml` (Private Local Knowledge)
257
-
258
- - Ưu tiên sử dụng các Knowledge đang có trạng thái `Active` thuộc:
259
- - Architecture
260
- - Hard Bug
261
- - Convention
262
- - Pattern
263
- - Tech Debt Pattern
264
- - 👉 *Domain Focus:* Architecture/Pattern (vd: cấu hình provider LLM, chuẩn RAG pipeline, prompt template).
265
-
266
- - Memory chỉ đóng vai trò **Navigator (bản đồ chỉ đường)**.
267
- Không được xem Memory là Source of Truth.
268
- 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.
269
-
270
- ---
271
-
272
- ### Learning Flow (AI tự học có kiểm soát)
273
- - 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:
274
- - Hard Bug có khả năng tái diễn.
275
- - Pattern làm việc lặp lại trong dự án.
276
- - Convention hoặc quy tắc kiến trúc mới.
277
- - Quyết định Architecture quan trọng.
278
- - Tech Debt Pattern hoặc Code Smell có tính hệ thống.
279
- - 👉 *Domain Harvest:* Pattern hoặc Convention mới (vd: quy chuẩn JSON schema cho prompt, scorecard định lượng).
280
-
281
- - Candidate Memory chỉ là bản nháp quan sát, chưa phải tri thức chính thức.
282
- - Candidate Memory có thể lưu tạm tại: `.ai-local/candidates/`
283
- - AI không được tự động Promote Candidate Memory thành Project Knowledge.
284
-
285
- ---
286
-
287
- ### Post-flight Harvest (Đề xuất → Phê duyệt)
288
- Sau khi hoàn thành task:
289
- - AI đánh giá các Candidate Memory đã tạo.
290
- - Nếu phát hiện tri thức có giá trị tái sử dụng:
291
- - Đề xuất người dùng xem xét.
292
- - Gửi yêu cầu phê duyệt thông qua:
293
- - `/learn`
294
- - `qk-project-memory`
295
- - Chỉ sau khi được phê duyệt, Candidate Memory mới được chuyển thành Knowledge chính thức:
296
-
297
- ```
298
- .ai-local/candidates/ ──(Approve)──> .agents/knowledge/index.yaml
299
- ```
300
-
301
- - Project Knowledge phải được xem như tài sản kỹ thuật của dự án:
302
- - Có thể review, cập nhật, loại bỏ và có lịch sử thay đổi.
303
-
304
- ---
305
-
306
- ### Ignore (Không đưa vào Memory)
307
- Không lưu:
308
- - Trace log của một session đơn lẻ.
309
- - Temporary debugging data.
310
- - Output của một lần chạy test/scan.
311
- - Report health tạm thời của một đợt kiểm tra.
312
- - Lỗi nhỏ chỉ xảy ra một lần.
313
- - Thông tin không có khả năng tái sử dụng.
314
- - 👉 *Domain Ignore:* Các thao tác tinh chỉnh từ ngữ prompt tạm thời cho 1 task đơn lẻ.
315
-
316
- ---
317
-
318
- ### Golden Rule
319
- > **AI được phép học, nhưng không được tự quyết định tri thức chính thức.**
320
- > **AI quan sát → Đề xuất → Con người phê duyệt → Dự án tiến hóa.**
321
-
322
- ---
323
- ---
324
-
325
- ### Learning Flow (AI tự học có kiểm soát)
326
- - 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:
327
- - Hard Bug có khả năng tái diễn.
328
- - Pattern làm việc lặp lại trong dự án.
329
- - Convention hoặc quy tắc kiến trúc mới.
330
- - Quyết định Architecture quan trọng.
331
- - Tech Debt Pattern hoặc Code Smell có tính hệ thống.
332
- - 👉 *Domain Harvest:* Pattern hoặc Convention mới (vd: quy chuẩn JSON schema cho prompt, scorecard định lượng).
333
-
334
- - Candidate Memory chỉ là bản nháp quan sát, chưa phải tri thức chính thức.
335
- - Candidate Memory có thể lưu tạm tại: `.ai-local/candidates/`
336
- - AI không được tự động Promote Candidate Memory thành Project Knowledge.
337
-
338
- ---
339
-
340
- ### Post-flight Harvest (Đề xuất → Phê duyệt)
341
- Sau khi hoàn thành task:
342
- - AI đánh giá các Candidate Memory đã tạo.
343
- - Nếu phát hiện tri thức có giá trị tái sử dụng:
344
- - Đề xuất người dùng xem xét.
345
- - Gửi yêu cầu phê duyệt thông qua:
346
- - `/learn`
347
- - `qk-project-memory`
348
- - Chỉ sau khi được phê duyệt, Candidate Memory mới được chuyển thành Knowledge chính thức:
349
-
350
- ```
351
- .ai-local/candidates/ ──(Approve)──> .agents/knowledge/index.yaml
352
- ```
353
-
354
- - Project Knowledge phải được xem như tài sản kỹ thuật của dự án:
355
- - Có thể review, cập nhật, loại bỏ và có lịch sử thay đổi.
356
-
357
- ---
358
-
359
- ### Ignore (Không đưa vào Memory)
360
- Không lưu:
361
- - Trace log của một session đơn lẻ.
362
- - Temporary debugging data.
363
- - Output của một lần chạy test/scan.
364
- - Report health tạm thời của một đợt kiểm tra.
365
- - Lỗi nhỏ chỉ xảy ra một lần.
366
- - Thông tin không có khả năng tái sử dụng.
367
- - 👉 *Domain Ignore:* Các thao tác tinh chỉnh từ ngữ prompt tạm thời cho 1 task đơn lẻ.
368
-
369
- ---
370
-
371
- ### Golden Rule
372
- > **AI được phép học, nhưng không được tự quyết định tri thức chính thức.**
373
- > **AI quan sát → Đề xuất → Con người phê duyệt → Dự án tiến hóa.**
374
-
375
- ---
376
- ---
377
-
378
- ### Learning Flow (AI tự học có kiểm soát)
379
- - 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:
380
- - Hard Bug có khả năng tái diễn.
381
- - Pattern làm việc lặp lại trong dự án.
382
- - Convention hoặc quy tắc kiến trúc mới.
383
- - Quyết định Architecture quan trọng.
384
- - Tech Debt Pattern hoặc Code Smell có tính hệ thống.
385
- - 👉 *Domain Harvest:* Pattern hoặc Convention mới (vd: quy chuẩn JSON schema cho prompt, scorecard định lượng).
386
-
387
- - Candidate Memory chỉ là bản nháp quan sát, chưa phải tri thức chính thức.
388
- - Candidate Memory có thể lưu tạm tại: `.ai-local/candidates/`
389
- - AI không được tự động Promote Candidate Memory thành Project Knowledge.
390
-
391
- ---
392
-
393
- ### Post-flight Harvest (Đề xuất → Phê duyệt)
394
- Sau khi hoàn thành task:
395
- - AI đánh giá các Candidate Memory đã tạo.
396
- - Nếu phát hiện tri thức có giá trị tái sử dụng:
397
- - Đề xuất người dùng xem xét.
398
- - Gửi yêu cầu phê duyệt thông qua:
399
- - `/learn`
400
- - `qk-project-memory`
401
- - Chỉ sau khi được phê duyệt, Candidate Memory mới được chuyển thành Knowledge chính thức:
402
-
403
- ```
404
- .ai-local/candidates/ ──(Approve)──> .agents/knowledge/index.yaml
405
- ```
406
-
407
- - Project Knowledge phải được xem như tài sản kỹ thuật của dự án:
408
- - Có thể review, cập nhật, loại bỏ và có lịch sử thay đổi.
409
-
410
- ---
411
-
412
- ### Ignore (Không đưa vào Memory)
413
- Không lưu:
414
- - Trace log của một session đơn lẻ.
415
- - Temporary debugging data.
416
- - Output của một lần chạy test/scan.
417
- - Report health tạm thời của một đợt kiểm tra.
418
- - Lỗi nhỏ chỉ xảy ra một lần.
419
- - Thông tin không có khả năng tái sử dụng.
420
- - 👉 *Domain Ignore:* Các thao tác tinh chỉnh từ ngữ prompt tạm thời cho 1 task đơn lẻ.
421
-
422
- ---
423
-
424
- ### Golden Rule
425
- > **AI được phép học, nhưng không được tự quyết định tri thức chính thức.**
426
- > **AI quan sát → Đề xuất → Con người phê duyệt → Dự án tiến hóa.**
427
-
428
- ---
429
- ---
430
- ---
431
- ---
432
-
433
- ## Preconditions
434
- - [ ] AI task is defined: what input → what output
435
- - [ ] LLM provider is specified (OpenAI, Anthropic, Gemini, local)
436
-
437
- ---
438
-
439
- ## Scope & V8.2 Governed Capability Design
440
- - ✅ **Capability Packaging:** Design modular AI capabilities paired with machine-readable `capability.yaml` and `scorecard.yaml` eval rubrics. *(Note: This packaging requirement applies only to new AI-agent/RAG capabilities generated by this skill, not to general-purpose dev-tooling skills).*
441
- - ✅ **Universal 4-Folder Discipline:** Enforce clean separation of Prompt Engineering (`prompts/`), Immutable Raw Data vs Clean Processed Chunks (`data/`), Modular Micro-skills (`agents/`), and Empirical Evals (`evals/`).
442
- - ✅ **Eval-Driven Pipeline:** Move from static `Prompt -> Output` to the closed-loop V8.2 workflow:
443
- `Prompt -> Execution -> Trace Log -> Evaluation (scorecard) -> Quality Gate -> Release Report`
444
- - ✅ Design strict, deterministic system prompts with structured JSON outputs.
445
- - ✅ Sanitize user inputs before LLM ingestion (Anti-Injection).
446
-
447
- ## Non-Goals
448
- - ❌ Modify or override files located in `data/raw/` (must remain immutable ground-truth)
449
- - ❌ Create unguided AI chat loops without structured eval criteria or trace records
450
- - ❌ Trust LLM output for critical logic without quantitative verification via `qk-validation-gate`
451
- - ❌ Use raw user input directly in prompts without sanitization
96
+ Chịu trách nhiệm thiết kế và hiện thực hóa AI Agent, RAG pipelines, prompt systems và eval criteria. Cam kết chống hallucination, tối ưu hóa token budget, quản lý context window và bảo vệ dữ liệu nhạy cảm.
452
97
 
453
98
  ---
454
99
 
455
- ## System Prompt Template (Required Structure)
456
-
457
- ```
458
- [ROLE]
459
- You are a [specific role]. You [specific expertise].
460
-
461
- [TASK]
462
- Your task is to [exact task description].
463
-
464
- [CONSTRAINTS]
465
- - Always [constraint 1]
466
- - Never [constraint 2]
467
- - If [edge case] → [specific action]
468
-
469
- [OUTPUT FORMAT]
470
- Return ONLY valid JSON matching this schema:
471
- {
472
- "field1": "string",
473
- "field2": number,
474
- "confidence": "high|medium|low"
475
- }
476
-
477
- [EXAMPLES]
478
- Input: [example]
479
- Output: {"field1": "...", "field2": 0, "confidence": "high"}
480
- ```
481
-
482
- ---
483
-
484
- ## Anti-Injection Checklist (Tuân thủ R-SEC-04)
485
- ```
486
- [ ] User input is wrapped in XML tags: <user_input>{input}</user_input>
487
- [ ] System instructions are separate from user content
488
- [ ] Input is validated/sanitized before injection (no raw HTML/JS)
489
- [ ] Max token limit set for user input
490
- [ ] Output is parsed as JSON (not eval'd)
491
- [ ] Confidence field in output triggers human review if "low"
492
- ```
100
+ ## Preconditions
493
101
 
494
- ---
102
+ Trước khi triển khai bất kỳ hệ thống AI nào, AI BẮT BUỘC kiểm tra:
495
103
 
496
- ## RAG Pipeline Pattern
497
- ```
498
- User Query
499
- └─ Sanitize + embed query
500
- └─ Vector search (top-K = 5)
501
- └─ Re-rank by relevance
502
- └─ Build prompt: [System] + [Retrieved Context] + [User Query]
503
- └─ LLM call
504
- └─ Validate output schema
505
- └─ Return to user
506
- ```
104
+ - [ ] Xác định AI stack từ `.agents/DEV_PROFILE.md` (LLM provider, Vector DB, Framework như LangChain/LlamaIndex/Vercel AI SDK).
105
+ - [ ] Xác định rõ Evaluation criteria: Tiêu chí đo lường độ chính xác (Relevance, Faithfulness, Hallucination rate).
106
+ - [ ] Kiểm tra chính sách dữ liệu: Có dữ liệu PII (thông tin định danh cá nhân) hoặc secrets cần sanitize trước khi gửi LLM không?
107
+ - [ ] Nếu không có phương án kiểm thử / eval criteria đo lường chất lượng AI:
108
+ **EXIT: BLOCKED**
109
+ Báo cáo user: Bắt buộc định nghĩa Eval criteria trước khi tiến hành code pipeline.
507
110
 
508
111
  ---
509
112
 
510
- ---
113
+ ## Scope
511
114
 
512
- ## Priority Order
115
+ Skill này làm:
116
+ - Thiết kế luồng RAG (Chunking, Embedding, Vector Search, Re-ranking, Context Augmentation).
117
+ - Xây dựng Agent logic (Tool use, Function calling, Structured output, Memory loop).
118
+ - Tối ưu hóa System Prompt: Vai trò, nhiệm vụ, định dạng output (JSON schema/Markdown), guardrails.
119
+ - Xây dựng Eval suite và bộ test cases đánh giá định lượng câu trả lời của AI.
120
+ - Quản lý token budget, streaming response, và cơ chế fallback khi LLM timeout/rate-limit.
513
121
 
514
- | Priority | Task | Skip Threshold |
515
- |----------|------|----------------|
516
- | P1 | System Prompt structure defined | Never |
517
- | P2 | Anti-Injection checklist applied | Never |
518
- | P3 | Output schema validated | Budget < 30% |
519
- | P4 | 4-folder discipline (prompts/data/agents/evals) set up | Budget < 50% |
520
- | P5 | Examples/few-shot added | Budget < 70% |
122
+ Skill này KHÔNG làm:
123
+ - Huấn luyện hoặc fine-tune foundation models từ đầu (pre-training).
124
+ - Viết giao diện Frontend Chatbot hoàn chỉnh (→ `qk-ui-builder` hoặc `qk-api-consumer`).
125
+ - Quản hạ tầng GPU / Kubernetes cluster chạy model (→ `qk-devops-platform`).
521
126
 
522
127
  ---
523
128
 
524
- ## Workflow
129
+ ## Execution Steps
525
130
 
526
- ### Phase 1 — Prompt Design
527
- **Steps:**
528
- 1. Define the system prompt using the Required Structure (ROLE, TASK, CONSTRAINTS).
529
- 2. Explicitly specify the OUTPUT FORMAT as structured JSON.
530
- 3. Add few-shot EXAMPLES to guide the LLM.
531
-
532
- **Decision:**
131
+ ### Step 1 — Architecture & Pipeline Design
533
132
  ```
534
- IF prompt has all sections
535
- → Confidence: HIGH → go to Phase 2
536
- ELSE
537
- EXIT: BLOCKED request missing details
133
+ Inputs: Yêu cầu từ user, Data sources, DEV_PROFILE.md
134
+ Actions:
135
+ - Lựa chọn mô hình: Direct prompting vs RAG vs Agentic tool calling.
136
+ - Thiết kế chiến lược chia nhỏ dữ liệu (Chunk size, chunk overlap) và vector embedding.
137
+ - Xác định schema cho Structured Output (JSON Schema / Zod).
138
+ Output: AI Architecture Specification
538
139
  ```
539
140
 
540
- ### Phase 2 — Security & Validation
541
- **Steps:**
542
- 1. Apply the Anti-Injection Checklist.
543
- 2. Validate that user inputs are wrapped in XML tags and sanitized.
544
- 3. Ensure the output schema contains a confidence score field.
545
-
546
- **Decision:**
141
+ ### Step 2 — Prompt Engineering & Guardrails
547
142
  ```
548
- IF all security checks pass
549
- → Confidence: HIGH → go to Phase 3
550
- ELSE
551
- EXIT: FAILED fix security gaps
143
+ Inputs: AI Architecture Specification
144
+ Actions:
145
+ - Viết System Prompt có cấu trúc rõ ràng: Role, Capabilities, Boundaries, Output Format.
146
+ - Thiết lập Guardrails: Khử jailbreak, cấm hallucination khi thiếu dữ liệu, lọc PII.
147
+ - Thiết lập vài ví dụ minh họa (Few-shot learning) nếu cần chuẩn hóa logic phức tạp.
148
+ Output: Production-grade Prompt definitions
552
149
  ```
553
150
 
554
- ### Phase 3 — Pipeline & Packaging
555
- **Steps:**
556
- 1. Map the process to the RAG Pipeline Pattern if context retrieval is needed.
557
- 2. Ensure files are organized into the 4-Folder Discipline (prompts/, data/, agents/, evals/).
558
- 3. Generate `capability.yaml` and `scorecard.yaml` for evaluation.
559
-
560
- **Decision:**
151
+ ### Step 3 — Pipeline Implementation & Integration
561
152
  ```
562
- IF packaging complete
563
- → EXIT: SUCCESS
564
- ELSE
565
- EXIT: PARTIAL note missing folder structure or evals
153
+ Inputs: Prompts, Schemas, AI SDK
154
+ Actions:
155
+ - Code pipeline tích hợp LLM client với error handling, retry backoff và fallback logic.
156
+ - Kết nối Vector store / Document retriever reranker (nếu là RAG).
157
+ - Tích hợp function calling và parse structured outputs an toàn.
158
+ Output: Functional AI Pipeline code
566
159
  ```
567
160
 
568
- ---
569
-
570
- ## Output Format
571
-
161
+ ### Step 4 — Verification & Eval Execution
572
162
  ```
573
- 🤖 AI Builder Output
574
- ─────────────────────────────────────────────────
575
- Task: [Description of the AI task]
576
- Confidence: [HIGH | MEDIUM | LOW]
577
-
578
- Design:
579
- ✅ System Prompt Template created
580
- ✅ Output JSON Schema defined
581
- ✅ [N] few-shot examples included
582
-
583
- Security & Validation:
584
- ✅ User input wrapped in <user_input> tags
585
- ✅ Anti-Injection checklist passed
586
-
587
- Packaging:
588
- ✅ 4-folder structure initialized
589
- ✅ capability.yaml & scorecard.yaml generated
590
-
591
- Exit Code: [SUCCESS | PARTIAL | BLOCKED | FAILED]
163
+ Inputs: AI Pipeline, Test dataset
164
+ Actions:
165
+ - Chạy eval test cases để đo lường: Faithfulness (độ trung thực), Retrieval recall, Latency.
166
+ - Đảm bảo token cost nằm trong ngân sách cho phép.
167
+ Exit: SUCCESS nếu vượt qua các ngưỡng benchmark chất lượng đã cam kết.
592
168
  ```
593
169
 
594
- ---
595
- ## Exit Codes
596
- | Code | Meaning | When |
597
- |------|---------|------|
598
- | SUCCESS | Prompt designed with all required sections, anti-injection applied | All checks passed |
599
- | PARTIAL | Prompt works but missing examples or output validation | Medium confidence result |
600
- | BLOCKED | Task or output format not defined clearly enough | Cannot design without clear spec |
601
- | FAILED | Prompt design has security vulnerability (direct injection risk) | Security gate failure |
602
-
603
170
  ---
604
171
 
605
- ## Confidence Model
606
- | Level | Condition | Action |
607
- |-------|-----------|--------|
608
- | HIGH | Task clearly defined, output format specified, examples provided | Build directly |
609
- | MEDIUM | Task clear but output format ambiguous | Note assumption, add validation layer |
610
- | LOW | Task too vague ("make an AI assistant") | EXIT: BLOCKED — define specific task |
172
+ ## Prompt Template
611
173
 
612
- ---
174
+ AI đọc `DEV_PROFILE.md` để biết LLM, vector DB, và pipeline framework đang dùng.
175
+ Mô tả agent/pipeline cần build — AI thiết kế đúng kiến trúc, không generic.
613
176
 
614
- ## Severity
615
- | Level | Definition | Example |
616
- |-------|-----------|---------|
617
- | CRITICAL | Prompt injection attack possible | User input directly in system prompt |
618
- | HIGH | LLM output used without validation in business logic | JSON parse without schema check |
619
- | MEDIUM | Missing examples leads to inconsistent output | No few-shot examples in prompt |
620
- | LOW | Output format not explicitly stated | Returns text instead of JSON |
177
+ ```
178
+ Build: [RAG pipeline / AI agent / prompt chain / eval suite / ...]
179
+ Mục đích: [System này làm gì, cho ai dùng]
180
+ Input: [User query / document / event / ...]
181
+ Output: [Response format, citation style, action taken]
182
+ Constraints: [Latency budget, cost/query, context window limit, PII rules]
183
+ Eval: [Thành công trông như thế nào metric cụ thể]
184
+ ```
621
185
 
622
186
  ---
623
187
 
624
- ## Evidence Format
625
- ```
626
- [SEVERITY] src/prompts/[name].ts:LINE
627
- Issue: [specific vulnerability or gap]
628
- Confidence: HIGH
629
- Fix: [specific change]
630
- ```
188
+ ### dụ theo use case:
631
189
 
632
- **Example:**
190
+ **RAG — Tài liệu nội bộ (OpenAI + pgvector + LangChain)**
633
191
  ```
634
- [CRITICAL] src/prompts/chat.ts:34
635
- Issue: User input `${userMessage}` injected directly in system promptinjection risk
636
- Confidence: HIGH
637
- Fix: Wrap in <user_input>{userMessage}</user_input> XML tags
192
+ Build: RAG pipeline cho Q&A tài liệu nội bộ công ty
193
+ Mục đích: Nhân viên hỏi về policy, quy trình, handbookAI trả lời có citation
194
+ Input: User question (text), corpus: 500 PDF files (~50k pages)
195
+ Output: { answer: string, citations: [{doc, page, excerpt}], confidence: high|low }
196
+ Constraints: Latency < 3s, cost < $0.01/query, không trả lời ngoài corpus
197
+ Eval: Faithfulness > 0.85, Answer relevance > 0.80, No hallucination on factual Q
638
198
  ```
199
+ → AI thiết kế: chunking strategy (semantic vs fixed với overlap),
200
+ embedding model (text-embedding-3-small vs large — cost vs quality),
201
+ pgvector index type (ivfflat vs hnsw), retrieval pipeline (vector search → rerank),
202
+ system prompt với grounding enforcement, citation extraction,
203
+ eval harness (RAGAS metrics), fallback khi confidence thấp.
639
204
 
640
- ---
641
-
642
- ## Retry Policy
205
+ **Agentic — Tool-calling Agent (OpenAI + LangGraph)**
643
206
  ```
644
- LLM output validation fails
645
- └─ Retry with stronger output format instruction (add explicit JSON schema)
646
- ├─ PASS on retry → EXIT: SUCCESS, note "required stronger schema enforcement"
647
- └─ FAIL on retry EXIT: PARTIAL add human review gate
648
- └─ Do NOT auto-retry more than 1 time — risk of infinite loop
207
+ Build: Customer support agent tự động xử lý refund requests
208
+ Mục đích: Giảm ticket cho support team tự xử 80% refund đơn giản
209
+ Input: Customer message qua chat widget
210
+ Output: Tự động: approve/reject refund, update order status, gửi email
211
+ Escalate: chuyển human agent nếu case phức tạp
212
+ Constraints: Không approve refund > $500 tự động, log mọi quyết định,
213
+ PII không được gửi sang LLM ngoài (dùng on-premise model)
214
+ Eval: Accuracy > 95% trên refund eligibility, escalation rate < 20%,
215
+ False approve rate = 0% cho orders > $500
649
216
  ```
217
+ → AI thiết kế: tool definitions (check_order, process_refund, escalate_to_human),
218
+ LangGraph state machine cho multi-turn conversation,
219
+ guardrails cho financial limits (rule-based, không phụ thuộc LLM),
220
+ audit trail cho mọi action, PII redaction trước khi gửi LLM,
221
+ human-in-the-loop node, eval test cases với adversarial inputs.
650
222
 
651
- ---
652
-
653
- ## Escalation Rules
223
+ **Prompt Engineering — Structured Output (Anthropic Claude)**
654
224
  ```
655
- BLOCKED: AI task not specific enough to design prompt
656
- Missing:
657
- - Specific task description (what input what output)
658
- - Output format specification (JSON schema or text structure)
659
- Questions:
660
- 1. Input cụ thể là gì? (user text, document, structured data)
661
- 2. Output cần trả về dạng gì? (JSON với field gì / plain text)
662
- Recommended Assumptions (if proceeding):
663
- - Structured JSON output with confidence field
664
- - Deny-by-default: reject off-topic requests in system prompt
225
+ Build: Pipeline extract thông tin từ hóa đơn PDF → JSON
226
+ Mục đích: Tự động hóa nhập liệu kế toán — xử lý 1000 hóa đơn/ngày
227
+ Input: PDF hóa đơn (scan hoặc digital), đa ngôn ngữ (VN, EN, JP)
228
+ Output: { vendor, date, total, currency, lineItems: [], taxAmount, invoiceNumber }
229
+ Constraints: Accuracy > 99% trên digital PDFs, > 95% trên scanned,
230
+ Latency < 5s/invoice, cost < $0.005/invoice
231
+ Eval: Field-level accuracy per invoice type, error rate theo language
665
232
  ```
233
+ → AI thiết kế: PDF parsing strategy (PyMuPDF vs vision model),
234
+ structured output với JSON schema (tool_use / response_format),
235
+ few-shot examples cho từng invoice format,
236
+ confidence scoring per field, human review queue cho low-confidence,
237
+ batch processing pipeline, cost tracking per document type,
238
+ A/B test prompt versions.
666
239
 
667
- ---
668
-
669
- ## Handoff Contract
670
- ### Consumes
671
- ```json
672
- {
673
- "from": "user",
674
- "required_fields": ["task_description", "input_type", "output_format"],
675
- "optional_fields": ["examples", "llm_provider", "max_tokens"]
676
- }
240
+ **Eval Suite — Đánh giá AI system hiện có**
677
241
  ```
678
- ### Produces
679
- ```json
680
- {
681
- "to": "user or qk-validation-gate",
682
- "output_fields": ["system_prompt", "output_schema", "anti_injection_checklist", "exit_code"]
683
- }
242
+ Build: Eval pipeline cho RAG system đang chạy production
243
+ Mục đích: Detect regression khi thay đổi prompt hoặc retrieval config
244
+ Input: Golden dataset: 200 Q&A pairs có ground truth answers
245
+ Output: Eval report: faithfulness, relevance, correctness per category,
246
+ comparison vs baseline version
247
+ Constraints: Eval phải chạy trong CI/CD, kết quả trong < 10 phút
248
+ Eval: Chính eval này cần được validate bằng human judgment sample
684
249
  ```
685
-
686
- ---
687
-
250
+ → AI thiết kế: RAGAS framework setup, golden dataset format,
251
+ LLM-as-judge prompt design (với rubric rõ ràng),
252
+ metric thresholds cho CI gate (fail build nếu faithfulness < 0.80),
253
+ regression detection (compare vs previous run),
254
+ human calibration workflow cho judge prompts.