ai-developer-skill-os 8.2.0 → 8.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 (79) hide show
  1. package/.agents/LICENSE +21 -21
  2. package/.agents/README.md +90 -90
  3. package/.agents/docs/CHI_TIET_SKILLS.md +125 -125
  4. package/.agents/docs/MIGRATION-CLEANUP-V8.1.3.md +36 -36
  5. package/.agents/docs/MIGRATION-STATUS.md +35 -35
  6. package/.agents/docs/MIGRATION-V8.md +10 -10
  7. package/.agents/docs/V8-CERTIFICATION.md +27 -27
  8. package/.agents/docs/decisions/ADR-001-v8-migration.md +58 -58
  9. package/.agents/docs/decisions/ADR-002-workflow-separation.md +50 -50
  10. package/.agents/docs/decisions/ADR-003-registry-generated.md +54 -54
  11. package/.agents/docs/decisions/ADR-008-skill-boundary-review.md +27 -27
  12. package/.agents/registry/graph.json +4 -8
  13. package/.agents/registry/index.yaml +3 -4
  14. package/.agents/registry/skills-index.yml +525 -525
  15. package/.agents/rules/coding.md +10 -0
  16. package/.agents/rules/command-safety.md +37 -14
  17. package/.agents/rules/priorities.yml +13 -2
  18. package/.agents/rules/security.md +47 -7
  19. package/.agents/rules/skill-quality.md +32 -8
  20. package/.agents/skills/_template/SKILL.md +133 -132
  21. package/.agents/skills/_template/capability.yaml +20 -20
  22. package/.agents/skills/_template/evals/scorecard.yaml +19 -19
  23. package/.agents/skills/qk-access-policy/SKILL.md +4 -1
  24. package/.agents/skills/qk-agent-observability/SKILL.md +111 -0
  25. package/.agents/skills/qk-agent-observability/references/scorecard.yaml +80 -0
  26. package/.agents/skills/qk-ai-builder/SKILL.md +74 -5
  27. package/.agents/skills/qk-api-lifecycle/SKILL.md +4 -2
  28. package/.agents/skills/qk-bug-resolution/SKILL.md +3 -21
  29. package/.agents/skills/qk-code-review/SKILL.md +188 -189
  30. package/.agents/skills/qk-context-loader/SKILL.md +3 -47
  31. package/.agents/skills/qk-data-lifecycle/SKILL.md +7 -2
  32. package/.agents/skills/qk-db-optimizer/SKILL.md +3 -2
  33. package/.agents/skills/qk-design-system-engineering/SKILL.md +235 -112
  34. package/.agents/skills/qk-devops-platform/SKILL.md +241 -117
  35. package/.agents/skills/qk-docs/SKILL.md +3 -1
  36. package/.agents/skills/qk-engineering-standard/SKILL.md +4 -75
  37. package/.agents/skills/qk-engineering-standard/references/anti-patterns.md +121 -0
  38. package/.agents/skills/qk-engineering-standard/rules/frontend.md +1 -1
  39. package/.agents/skills/qk-fe-api-integration/SKILL.md +13 -32
  40. package/.agents/skills/qk-feature-delivery/SKILL.md +54 -202
  41. package/.agents/skills/qk-frontend-architecture/SKILL.md +258 -134
  42. package/.agents/skills/qk-help/SKILL.md +21 -159
  43. package/.agents/skills/qk-orchestrator/SKILL.md +2 -78
  44. package/.agents/skills/qk-orchestrator/references/routing-table.md +15 -3
  45. package/.agents/skills/qk-product-specification/SKILL.md +253 -130
  46. package/.agents/skills/qk-production-release/SKILL.md +32 -67
  47. package/.agents/skills/qk-project-bootstrap/SKILL.md +59 -8
  48. package/.agents/skills/qk-project-health/SKILL.md +4 -2
  49. package/.agents/skills/qk-project-memory/SKILL.md +3 -1
  50. package/.agents/skills/qk-security-audit/SKILL.md +259 -135
  51. package/.agents/skills/qk-system-evolution/SKILL.md +18 -68
  52. package/.agents/skills/qk-test-engineering/SKILL.md +262 -139
  53. package/.agents/skills/qk-ui-audit/SKILL.md +16 -89
  54. package/.agents/skills/qk-ui-audit/references/anti-slop-checklist.md +2 -2
  55. package/.agents/skills/qk-ui-builder/SKILL.md +482 -509
  56. package/.agents/skills/qk-ui-builder/references/component-cookbook.md +455 -1191
  57. package/.agents/skills/qk-ui-system-builder/SKILL.md +1 -5
  58. package/.agents/skills/qk-validation-gate/SKILL.md +0 -74
  59. package/.agents/skills/qk-web-quality-gate/SKILL.md +232 -114
  60. package/.agents/workflows/_schema.yml +146 -109
  61. package/.agents/workflows/bug-resolution.yml +121 -101
  62. package/.agents/workflows/code-review.yml +93 -77
  63. package/.agents/workflows/documentation.yml +90 -75
  64. package/.agents/workflows/feature-delivery.yml +120 -103
  65. package/.agents/workflows/refactor.yml +99 -81
  66. package/.agents/workflows/research.yml +75 -60
  67. package/.agents/workflows/security-audit.yml +115 -72
  68. package/.agents/workflows/skill-evolution.yml +97 -65
  69. package/.agents/workflows/spec-driven-development.yml +87 -57
  70. package/CHANGELOG.md +10 -0
  71. package/README.md +90 -90
  72. package/bin/install.js +330 -180
  73. package/package.json +2 -2
  74. package/.agents/CHANGELOG.md +0 -131
  75. package/.agents/learnings/draft/README.md +0 -37
  76. package/.agents/reports/RELEASE-CHECKLIST.md +0 -29
  77. package/.agents/reports/architecture-audit.md +0 -13
  78. package/.agents/reports/graph-health.md +0 -20
  79. package/.agents/reports/skill-audit.md +0 -215
@@ -1,117 +1,241 @@
1
- ---
2
- # ── Identity ───────────────────────────────────────────────
3
- name: qk-devops-platform
4
- version: 8.1.1
5
- status: experimental
6
- description: "Kỹ sư nền tảng: Chiến lược CI/CD, kiến trúc triển khai, quản lý môi trường và chiến lược rollback."
7
- platforms: [antigravity, claude-code, cursor, windsurf, kilo-code]
8
-
9
- # ── V8: Classification ─────────────────────────────────────
10
- type: capability
11
-
12
- intent:
13
- - devops-strategy
14
- - cicd-pipeline
15
- - deployment-architecture
16
- - environment-management
17
-
18
- complexity:
19
- level: high
20
- criteria:
21
- files_affected: "1-5"
22
- has_behavior_change: true
23
- has_external_dependency: true
24
- has_breaking_change: false
25
-
26
- triggers:
27
- - "cấu hình ci/cd"
28
- - "deployment strategy"
29
- - "quản lý môi trường"
30
- - "devops platform"
31
- - "dockerize"
32
-
33
- # ── V8: References ─────────────────────────────────────────
34
- workflow: feature-delivery
35
-
36
- rules:
37
- - global
38
- - coding
39
- - security
40
-
41
- tools:
42
- - filesystem
43
- - terminal
44
-
45
- related_skills:
46
- - qk-production-release
47
- - qk-security-audit
48
-
49
- knowledge_scope:
50
- domain:
51
- - devops
52
- - platform-engineering
53
- - cloud-infrastructure
54
- concepts:
55
- - continuous-integration
56
- - continuous-deployment
57
- - containerization
58
- - rollback-strategy
59
- references:
60
- - architecture
61
-
62
- decision_boundary:
63
- owns:
64
- - CI/CD strategy
65
- - deployment architecture
66
- - environment management
67
- - rollback strategy
68
- does_not_own:
69
- - application code
70
- - cloud billing
71
- - releasing features
72
- conflicts_with:
73
- - qk-production-release
74
-
75
- # ── V8: Verification ───────────────────────────────────────
76
- verification:
77
- required: true
78
- strategy: feature
79
-
80
- selection:
81
- priority: medium
82
- confidence_threshold: 0.80
83
-
84
- examples: []
85
- learnings: []
86
-
87
- # ── V7 Runtime ─────────────────────────────────────────────
88
- execution_mode: deterministic
89
- cost: medium
90
- latency: medium
91
- risk: high
92
- side_effects: edit_files
93
- produces: [report, plan, code]
94
- consumes: [user-description]
95
-
96
- token_budget:
97
- max_files_read: 5
98
- max_lines_per_read: 150
99
- max_shell_commands: 2
100
- stop_early: false
101
-
102
- exit_codes: [SUCCESS, BLOCKED, FAILED, PARTIAL]
103
- ---
104
-
105
- # qk-devops-platform — Platform Engineer
106
-
107
- > **Language rule:** Code, identifiers, file names → English. Explanations, summaries → Vietnamese.
108
-
109
- ## Preconditions
110
- - [ ] Requirements cho môi trường triển khai đã có sẵn.
111
-
112
- ## Scope
113
- - Thiết kế và thiết lập luồng CI/CD (GitHub Actions, GitLab CI, v.v.).
114
- - Xây dựng kiến trúc deployment, quản lý các container (Docker, Kubernetes).
115
- - Đưa ra chiến lược Rollback an toàn khi sự cố.
116
- - Quản phân tách các môi trường (Dev, Staging, Prod).
117
- - KHÔNG thay thế `qk-production-release` (đóng gói release app), skill này quản lý *hạ tầng và quy trình* bên dưới việc release đó.
1
+ ---
2
+ # ── Identity ───────────────────────────────────────────────
3
+ name: qk-devops-platform
4
+ version: 8.1.1
5
+ status: experimental
6
+ description: "Kỹ sư nền tảng: Chiến lược CI/CD, kiến trúc triển khai, quản lý môi trường và chiến lược rollback."
7
+ platforms: [antigravity, claude-code, cursor, windsurf, kilo-code]
8
+
9
+ # ── V8: Classification ─────────────────────────────────────
10
+ type: capability
11
+
12
+ intent:
13
+ - devops-strategy
14
+ - cicd-pipeline
15
+ - deployment-architecture
16
+ - environment-management
17
+
18
+ complexity:
19
+ level: high
20
+ criteria:
21
+ files_affected: "1-5"
22
+ has_behavior_change: true
23
+ has_external_dependency: true
24
+ has_breaking_change: false
25
+
26
+ triggers:
27
+ - "cấu hình ci/cd"
28
+ - "deployment strategy"
29
+ - "quản lý môi trường"
30
+ - "devops platform"
31
+ - "dockerize"
32
+
33
+ # ── V8: References ─────────────────────────────────────────
34
+ workflow: feature-delivery
35
+
36
+ rules:
37
+ - global
38
+ - coding
39
+ - security
40
+
41
+ tools:
42
+ - filesystem
43
+ - terminal
44
+
45
+ related_skills:
46
+ - qk-production-release
47
+ - qk-security-audit
48
+
49
+ knowledge_scope:
50
+ domain:
51
+ - devops
52
+ - platform-engineering
53
+ - cloud-infrastructure
54
+ concepts:
55
+ - continuous-integration
56
+ - continuous-deployment
57
+ - containerization
58
+ - rollback-strategy
59
+ references:
60
+ - architecture
61
+ - security
62
+ - anti-patterns
63
+
64
+ decision_boundary:
65
+ owns:
66
+ - CI/CD strategy
67
+ - deployment architecture
68
+ - environment management
69
+ - rollback strategy
70
+ does_not_own:
71
+ - application code
72
+ - cloud billing
73
+ - releasing features
74
+ conflicts_with:
75
+ - qk-production-release
76
+
77
+ # ── V8: Verification ───────────────────────────────────────
78
+ verification:
79
+ required: true
80
+ strategy: feature
81
+
82
+ selection:
83
+ priority: medium
84
+ confidence_threshold: 0.80
85
+
86
+ examples: []
87
+ learnings: []
88
+
89
+ # ── V7 Runtime ─────────────────────────────────────────────
90
+ execution_mode: deterministic
91
+ cost: medium
92
+ latency: medium
93
+ risk: high
94
+ side_effects: edit_files
95
+ produces: [report, plan, code]
96
+ consumes: [user-description]
97
+
98
+ token_budget:
99
+ max_files_read: 5
100
+ max_lines_per_read: 150
101
+ max_shell_commands: 2
102
+ stop_early: true
103
+
104
+ exit_codes: [SUCCESS, BLOCKED, FAILED, PARTIAL]
105
+ ---
106
+
107
+ # qk-devops-platform Platform Engineer
108
+
109
+ > **Language rule:** Code, identifiers, file names → English. Explanations, summaries → Vietnamese.
110
+
111
+ ## Preconditions
112
+ - [ ] Requirements cho môi trường triển khai đã có sẵn.
113
+
114
+ ## Scope
115
+ - Thiết kế thiết lập luồng CI/CD (GitHub Actions, GitLab CI, v.v.).
116
+ - Xây dựng kiến trúc deployment, quản lý các container (Docker, Kubernetes).
117
+ - Đưa ra chiến lược Rollback an toàn khi sự cố.
118
+ - Quản lý và phân tách các môi trường (Dev, Staging, Prod).
119
+ - **Bắt buộc tuân thủ R-SEC-04: Mọi secrets/credentials trong CI/CD phải được inject qua biến môi trường an toàn (Github Secrets/Vault), KHÔNG BAO GIỜ hardcode.**
120
+ - KHÔNG thay thế `qk-production-release` (đóng gói và release app), skill này quản lý *hạ tầng và quy trình* bên dưới việc release đó.
121
+
122
+ ## Non-Goals
123
+ - ❌ Provide implementation outside of DevOps & CI/CD scope
124
+ - ❌ Override explicit user directives without explanation
125
+ - ❌ Guess ambiguous requirements without asking
126
+
127
+ ## Priority Order
128
+
129
+ | Priority | Task | Skip Threshold |
130
+ |----------|------|----------------|
131
+ | P1 | Core DevOps & CI/CD analysis and decision making | Never |
132
+ | P2 | Validation of existing patterns | Budget < 30% |
133
+ | P3 | Detailed documentation generation | Budget < 50% |
134
+ | P4 | Edge case exploration | Budget < 70% |
135
+
136
+ ## Workflow
137
+
138
+ ### Phase 1 — Context Loading
139
+ **Steps:**
140
+ 1. Read existing configuration and requirements related to DevOps & CI/CD.
141
+ 2. Check for missing preconditions.
142
+
143
+ **Decision:**
144
+ ```
145
+ IF context is clear
146
+ → Confidence: HIGH → go to Phase 2
147
+ ELSE
148
+ → EXIT: BLOCKED — ask user
149
+ ```
150
+
151
+ ### Phase 2 — Analysis & Strategy
152
+ **Steps:**
153
+ 1. Analyze the current state against DevOps & CI/CD best practices.
154
+ 2. Formulate strategy or audit report based on findings.
155
+
156
+ **Decision:**
157
+ ```
158
+ IF strategy/audit is complete
159
+ → Confidence: HIGH → go to Phase 3
160
+ ELSE IF minor gaps exist
161
+ → Confidence: MEDIUM → proceed with assumptions noted
162
+ ```
163
+
164
+ ### Phase 3 — Finalization
165
+ **Steps:**
166
+ 1. Generate final report or configuration.
167
+ 2. Prepare handoff data for subsequent skills.
168
+
169
+ ## Confidence Model
170
+
171
+ | Level | Condition | Action |
172
+ |-------|-----------|--------|
173
+ | HIGH | All preconditions met, context fully understood | Proceed directly |
174
+ | MEDIUM | Some context missing but safe defaults exist | Proceed and note assumptions |
175
+ | LOW | Core requirements missing | EXIT: BLOCKED |
176
+
177
+ ## Severity (for findings)
178
+
179
+ | Level | Definition |
180
+ |-------|-----------|
181
+ | CRITICAL | Severe violation of DevOps & CI/CD principles |
182
+ | HIGH | Significant risk or technical debt |
183
+ | MEDIUM | Suboptimal pattern but functional |
184
+ | LOW | Minor style or documentation issue |
185
+
186
+ ## Evidence Format
187
+
188
+ ```
189
+ [SEVERITY] Context/File
190
+ Issue: [what was found]
191
+ Confidence: HIGH
192
+ Recommendation: [actionable advice]
193
+ ```
194
+
195
+ ## Retry Policy
196
+ ```
197
+ Task fails due to missing context
198
+ └─ Ask user for clarification
199
+ ├─ Provided → Retry Phase 1
200
+ └─ Not provided → EXIT: BLOCKED
201
+ ```
202
+
203
+ ## Escalation Rules
204
+
205
+ ```
206
+ BLOCKED: Missing critical context for DevOps & CI/CD
207
+ Missing:
208
+ - [Specific requirement]
209
+ Questions:
210
+ 1. Bạn có thể cung cấp thêm thông tin về yêu cầu này không?
211
+ 2. Mục tiêu chính của bạn là gì?
212
+ Recommended Assumptions: none
213
+ ```
214
+
215
+ ## Handoff Contract
216
+
217
+ ### Consumes
218
+ ```json
219
+ {
220
+ "from": "user or qk-orchestrator",
221
+ "required_fields": ["context"],
222
+ "optional_fields": ["existing_config"]
223
+ }
224
+ ```
225
+
226
+ ### Produces
227
+ ```json
228
+ {
229
+ "to": "user or downstream skill",
230
+ "output_fields": ["strategy_report", "exit_code"]
231
+ }
232
+ ```
233
+
234
+ ## Exit Codes
235
+
236
+ | Code | Meaning | When |
237
+ |------|---------|------|
238
+ | SUCCESS | DevOps & CI/CD task completed successfully | Strategy/audit generated |
239
+ | PARTIAL | Task completed with assumptions | Medium confidence |
240
+ | BLOCKED | Missing context | Cannot proceed |
241
+ | FAILED | Critical conflict or error | Unresolvable constraint |
@@ -47,6 +47,8 @@ knowledge_scope:
47
47
  - architecture-docs
48
48
  references:
49
49
  - source-code
50
+ - security
51
+ - anti-patterns
50
52
 
51
53
  # ── V8: Verification ───────────────────────────────────────
52
54
  verification:
@@ -202,7 +204,7 @@ Fix: [specific correction]
202
204
  ## Severity
203
205
  | Level | Definition | Example |
204
206
  |-------|-----------|---------|
205
- | CRITICAL | Docs instruct user to do something dangerous | Documenting destructive API without warnings |
207
+ | CRITICAL | Docs instruct user to do something dangerous, bypass auth, or expose secrets | Documenting destructive API without warnings, or writing guides to call internal APIs unauthenticated |
206
208
  | HIGH | API params documented incorrectly | Says string instead of object |
207
209
  | MEDIUM | Missing docs for edge cases | Doesn't explain error throws |
208
210
  | LOW | Typo or poor formatting | Misaligned markdown table |
@@ -49,6 +49,8 @@ knowledge_scope:
49
49
  - best-practices
50
50
  references:
51
51
  - architecture
52
+ - security
53
+ - anti-patterns
52
54
 
53
55
  # ── V8: Verification ───────────────────────────────────────
54
56
  verification:
@@ -93,11 +95,6 @@ On missing precondition:
93
95
  Message: "Vui lòng chỉ định file hoặc module cần kiểm tra."
94
96
  ```
95
97
 
96
- skill_version: 7.5.0
97
- runtime_version: 1
98
- schema_version: 2
99
- ---
100
-
101
98
  ## Scope
102
99
  - ✅ Detect violations with exact file:line references
103
100
  - ✅ Classify by severity with concrete thresholds
@@ -108,12 +105,8 @@ schema_version: 2
108
105
  - ❌ Rewrite architecture
109
106
  - ❌ Touch files outside the specified scope
110
107
 
111
- skill_version: 7.5.0
112
- runtime_version: 1
113
- schema_version: 2
114
- ---
115
-
116
108
  ## Concrete Thresholds (Non-Negotiable)
109
+ **Các giới hạn dưới đây được dùng để định lượng vi phạm rác mã (R-C-09) và bảo mật (R-SEC-04):**
117
110
 
118
111
  ```yaml
119
112
  function:
@@ -139,11 +132,6 @@ dependency:
139
132
  max_imports_per_file: 15 # Beyond this: likely a God File
140
133
  ```
141
134
 
142
- skill_version: 7.5.0
143
- runtime_version: 1
144
- schema_version: 2
145
- ---
146
-
147
135
  ## Priority Order
148
136
 
149
137
  | Priority | Check | Severity | Skip Threshold |
@@ -156,11 +144,6 @@ schema_version: 2
156
144
  | P6 | Naming convention violations | LOW | Budget < 70% |
157
145
  | P7 | Excessive imports / coupling | LOW | Budget < 80% |
158
146
 
159
- skill_version: 7.5.0
160
- runtime_version: 1
161
- schema_version: 2
162
- ---
163
-
164
147
  ## Workflow
165
148
 
166
149
  ### Phase 1 — Scan for Critical & High Violations
@@ -187,11 +170,6 @@ IF file line count > 300
187
170
  - All P1+P2+P3 checks done → go to Phase 2
188
171
  - Token budget < 30% → go to Phase 3 directly with PARTIAL flag
189
172
 
190
- skill_version: 7.5.0
191
- runtime_version: 1
192
- schema_version: 2
193
- ---
194
-
195
173
  ### Phase 2 — Scan for Medium & Low Violations
196
174
 
197
175
  **Steps:**
@@ -211,11 +189,6 @@ IF token budget < 50%
211
189
  → Skip P6+P7, go to Phase 3
212
190
  ```
213
191
 
214
- skill_version: 7.5.0
215
- runtime_version: 1
216
- schema_version: 2
217
- ---
218
-
219
192
  ### Phase 3 — Score & Report
220
193
 
221
194
  **Steps:**
@@ -243,11 +216,6 @@ IF score < 60 OR any CRITICAL violations
243
216
  → EXIT: FAILED — requires immediate action
244
217
  ```
245
218
 
246
- skill_version: 7.5.0
247
- runtime_version: 1
248
- schema_version: 2
249
- ---
250
-
251
219
  ## Confidence Model
252
220
 
253
221
  | Level | Condition | Action |
@@ -256,11 +224,6 @@ schema_version: 2
256
224
  | MEDIUM | Inferred cyclomatic complexity without tool | Note estimate |
257
225
  | LOW | Architectural smell inferred from structure | Mark as "suspected — verify manually" |
258
226
 
259
- skill_version: 7.5.0
260
- runtime_version: 1
261
- schema_version: 2
262
- ---
263
-
264
227
  ## Severity
265
228
 
266
229
  | Level | Definition | Example |
@@ -270,11 +233,6 @@ schema_version: 2
270
233
  | MEDIUM | DRY or SoC violation, fixable in < 1 hour | Same validation logic in 3 components |
271
234
  | LOW | Style/naming issue, non-blocking | Single-letter variable `x` outside loop |
272
235
 
273
- skill_version: 7.5.0
274
- runtime_version: 1
275
- schema_version: 2
276
- ---
277
-
278
236
  ## Evidence Format
279
237
 
280
238
  ```
@@ -296,22 +254,12 @@ Fix: Extract payment logic to `processPayment()`, shipping to `scheduleSh
296
254
  Deduction: -10 pts
297
255
  ```
298
256
 
299
- skill_version: 7.5.0
300
- runtime_version: 1
301
- schema_version: 2
302
- ---
303
-
304
257
  ## Retry Policy
305
258
  ```
306
259
  Audit is read-only — no retry needed.
307
260
  If file is inaccessible → skip and note in report as PARTIAL.
308
261
  ```
309
262
 
310
- skill_version: 7.5.0
311
- runtime_version: 1
312
- schema_version: 2
313
- ---
314
-
315
263
  ## Escalation Rules
316
264
 
317
265
  ```
@@ -323,11 +271,6 @@ Questions:
323
271
  2. Có ngưỡng cụ thể nào bạn muốn thay đổi không? (mặc định: 30 lines/function)
324
272
  ```
325
273
 
326
- skill_version: 7.5.0
327
- runtime_version: 1
328
- schema_version: 2
329
- ---
330
-
331
274
  ## Handoff Contract
332
275
 
333
276
  ### Consumes
@@ -347,11 +290,6 @@ schema_version: 2
347
290
  }
348
291
  ```
349
292
 
350
- skill_version: 7.5.0
351
- runtime_version: 1
352
- schema_version: 2
353
- ---
354
-
355
293
  ## Output Format
356
294
 
357
295
  ```
@@ -375,11 +313,6 @@ Required Actions:
375
313
  Exit Code: [SUCCESS | PARTIAL | FAILED]
376
314
  ```
377
315
 
378
- skill_version: 7.5.0
379
- runtime_version: 1
380
- schema_version: 2
381
- ---
382
-
383
316
  ## Exit Codes
384
317
 
385
318
  | Code | Meaning | When |
@@ -389,13 +322,9 @@ schema_version: 2
389
322
  | BLOCKED | No target specified | Cannot audit without scope |
390
323
  | FAILED | Score < 60 or CRITICAL found | Immediate action required |
391
324
 
392
- skill_version: 7.5.0
393
- runtime_version: 1
394
- schema_version: 2
395
- ---
396
-
397
325
  ## References
398
326
  - Detailed thresholds with rationale: `references/thresholds.md`
327
+ - Anti-Patterns Blacklist: `references/anti-patterns.md`
399
328
 
400
329
  ---
401
330
 
@@ -0,0 +1,121 @@
1
+ # 🚫 Anti-Patterns Blacklist — Engineering Standard
2
+
3
+ > Đây là danh sách đỏ. AI Agent **KHÔNG ĐƯỢC PHÉP** tạo ra code vi phạm các mục dưới đây,
4
+ > trừ khi người dùng yêu cầu tường minh và chấp nhận rủi ro (kèm comment giải thích lý do).
5
+ > Mục tiêu: chống "code rác" (slop), giữ codebase dễ bảo trì, an toàn kiểu dữ liệu, và có thể mở rộng.
6
+
7
+ ---
8
+
9
+ ## 1. TypeScript
10
+
11
+ | Cấm | Thay bằng |
12
+ |---|---|
13
+ | `any` tùy tiện | `unknown` + type guard, hoặc định nghĩa type/interface cụ thể |
14
+ | `// @ts-ignore` không có lý do | `// @ts-expect-error: <lý do cụ thể>` chỉ khi thực sự cần thiết tạm thời |
15
+ | Ép kiểu ép buộc (`as unknown as X`, `!` non-null assertion tràn lan) | Type guard, Zod/valibot schema validation ở boundary (API, form input) |
16
+ | Kiểu `object`, `Function` mơ hồ | Định nghĩa interface/type rõ ràng, dùng generic khi cần tái sử dụng |
17
+ | Enum số học không rõ nghĩa | `as const` object hoặc string union type |
18
+ | Interface/type định nghĩa lặp lại nhiều nơi | Tách vào `types/` hoặc co-locate cạnh feature, export dùng chung |
19
+
20
+ **Ví dụ SAI:**
21
+ ```ts
22
+ function handleData(data: any) {
23
+ return data.value; // không có gì đảm bảo `value` tồn tại
24
+ }
25
+ ```
26
+
27
+ **Ví dụ ĐÚNG:**
28
+ ```ts
29
+ interface ApiResponse {
30
+ value: string;
31
+ }
32
+ function handleData(data: ApiResponse) {
33
+ return data.value;
34
+ }
35
+ ```
36
+
37
+ ---
38
+
39
+ ## 2. React / UI
40
+
41
+ | Cấm | Thay bằng |
42
+ |---|---|
43
+ | Mutate state trực tiếp (`state.items.push(...)`, `state.x = y`) | Tạo object/array mới (`setState(prev => [...prev, item])`) hoặc dùng Immer |
44
+ | Spaghetti component: logic nghiệp vụ + fetch + JSX trộn chung 1 hàm khổng lồ | Tách Custom Hook (logic) khỏi Component (JSX thuần) — xem `component-cookbook.md` |
45
+ | Inline style (`style={{color: 'red'}}`) thay vì Design Token | Dùng class Tailwind ánh xạ token (`text-danger`), hoặc CSS variable đã định nghĩa |
46
+ | `useEffect` dùng để đồng bộ state phái sinh (derived state) | Tính toán trực tiếp trong render, hoặc `useMemo` nếu tốn kém |
47
+ | `useEffect` không có dependency array hoặc dependency sai (gây vòng lặp/render thừa) | Khai báo đầy đủ dependency, dùng ESLint `react-hooks/exhaustive-deps` |
48
+ | Component nhận > 5-6 props rời rạc không liên quan | Gom nhóm thành object prop, hoặc tách nhỏ component |
49
+ | Key trong list dùng `index` khi list có thể reorder/filter | Dùng ID ổn định (`item.id`) |
50
+ | Hardcode text UI trực tiếp (không chuẩn bị cho i18n) khi dự án có đa ngôn ngữ | Đưa qua lớp i18n / constants |
51
+ | Bỏ qua trạng thái loading / error / empty khi render dữ liệu async | Luôn xử lý đủ 3 trạng thái: loading, error, empty, success |
52
+ | Bỏ ARIA attributes / semantic HTML (`<div onClick>` thay vì `<button>`) | Dùng đúng thẻ semantic, thêm `aria-*` khi cần |
53
+
54
+ ---
55
+
56
+ ## 3. Kiến trúc (Architecture)
57
+
58
+ | Cấm | Thay bằng |
59
+ |---|---|
60
+ | Import chéo tạo circular dependency giữa các module | Tách shared logic ra module trung lập (`shared/`, `lib/`), kiểm tra bằng `madge` hoặc lint rule |
61
+ | Gọi API trực tiếp trong UI Component (`fetch()` ngay trong JSX/handler của component trình bày) | Tách vào `services/` hoặc data-layer hook (`useXxxQuery`) — component chỉ gọi hook |
62
+ | Business logic nằm trong Component thay vì layer riêng | Tách `hooks/`, `utils/`, `services/` — Component chỉ điều phối |
63
+ | Global mutable state ngoài store chính thức (biến module-level bị mutate) | Dùng Context/Zustand store có kiểm soát |
64
+ | Magic number/string rải rác trong code | Đưa vào `constants.ts` |
65
+ | Folder structure lộn xộn (component, hook, style của cùng 1 feature nằm rải rác nhiều nơi) | Co-location theo feature: `features/xxx/{components,hooks,services,types}` |
66
+ | Duplicate logic dán đè (copy-paste) ở nhiều nơi thay vì tái sử dụng | Trích xuất thành hàm/hook dùng chung |
67
+ | Commit code có `console.log` debug, code chết (dead code), TODO không có ticket | Dọn dẹp trước khi merge, hoặc gắn issue tracking rõ ràng |
68
+
69
+ ---
70
+
71
+ ## 4. React Query / TanStack Query
72
+
73
+ | Cấm | Thay bằng |
74
+ |---|---|
75
+ | Copy dữ liệu từ `useQuery` vào `useState` cục bộ (`const [x,setX]=useState(); useEffect(()=>setX(data),[data])`) | Dùng thẳng `data` trả về từ `useQuery` — nó đã là single source of truth |
76
+ | Tự quản lý loading/error bằng `useState` song song với `useQuery` | Dùng `isPending`/`isError`/`isFetching` có sẵn |
77
+ | `queryKey` viết tay rải rác nhiều nơi (`["user", id]` gõ lại ở 5 file khác nhau) | Tập trung vào 1 file `queryKeys.ts` theo factory pattern |
78
+ | Gọi `queryFn` chứa logic biến đổi dữ liệu phức tạp (mapping, tính toán nặng) | `queryFn` chỉ fetch thô; biến đổi dữ liệu qua `select` option hoặc hook riêng |
79
+ | Dùng `useQuery` cho dữ liệu thuần client (không đến từ server) | Đó là client state → dùng `useState`/Context/Zustand |
80
+ | `staleTime: 0` mặc định cho mọi query, gây refetch liên tục không cần thiết | Đặt `staleTime` phù hợp với tần suất đổi của dữ liệu |
81
+ | `invalidateQueries` tràn lan sau mọi mutation dù chỉ đổi 1 field nhỏ | Ưu tiên `setQueryData` cập nhật cache trực tiếp khi biết chính xác dữ liệu mới |
82
+ | Gọi `useQuery`/`useMutation` bên trong service/utility function (không phải React component/hook) | Hooks của React Query chỉ được gọi trong component hoặc custom hook |
83
+ | Nuốt lỗi mutation im lặng (không xử lý `onError`, không hiển thị gì cho user) | Luôn xử lý `onError` hoặc kiểm tra `error` để phản hồi UI |
84
+ | Trộn React Query với Redux/Zustand để lưu cùng một loại server-state ở 2 nơi | Server-state chỉ sống trong React Query cache, không đồng bộ ngược vào store khác |
85
+
86
+ ---
87
+
88
+ ## 5. TanStack Router / Table / Form / Virtual / Store
89
+
90
+ | Cấm | Thay bằng |
91
+ |---|---|
92
+ | Định nghĩa route bằng object thường, params/search không có type (dễ gõ sai tên param) | TanStack Router — dùng `createFileRoute`/`createRoute`, params & search suy kiểu tự động |
93
+ | Fetch dữ liệu trang trong component sau khi route đã mount (waterfall: chờ route load → mới fetch) | Prefetch trong `loader` của route (`loader: ({context}) => context.queryClient.ensureQueryData(...)`) |
94
+ | Đọc/ghi query string bằng `URLSearchParams` tay khi đã dùng TanStack Router | Dùng `useSearch`/`Route.useSearch()` có type-safe, validate qua schema (Zod) |
95
+ | Tự viết sort/filter/pagination state rời rạc bằng nhiều `useState` cho bảng dữ liệu | TanStack Table — quản lý qua `state` + `onXxxChange`, tách rõ khỏi cách render |
96
+ | Trộn logic tính toán dữ liệu bảng (sort/filter) vào trong JSX render row | Định nghĩa `columns` + xử lý qua Table instance (`table.getRowModel()`), JSX chỉ map render |
97
+ | Render toàn bộ hàng trăm/nghìn row DOM node cùng lúc trong Table/List | Kết hợp TanStack Virtual (`useVirtualizer`) để chỉ render row trong viewport |
98
+ | Tự quản lý field, error, touched bằng `useState` rời rạc cho form nhiều field | TanStack Form (`useForm`, `field.state`) — validate đồng bộ/bất đồng bộ tập trung, tránh re-render toàn form mỗi keystroke |
99
+ | Validate form chỉ ở client, không đồng bộ schema với backend | Dùng chung 1 schema (Zod) cho cả TanStack Form validator và backend validation |
100
+ | Đưa state UI đơn giản (theme, sidebar open/close) vào Redux/Context nặng nề | TanStack Store (hoặc `useState` cục bộ) cho state nhỏ gọn, framework-agnostic |
101
+ | Gọi trực tiếp DOM API để đo scroll/kích thước item thay vì dùng API của Virtual | Dùng `measureElement`/`estimateSize` của TanStack Virtual, tránh đọc/ghi layout thủ công gây jank |
102
+
103
+ ---
104
+
105
+ ## 6. Nguyên tắc review nhanh (Checklist trước khi xuất code)
106
+
107
+ - [ ] Không còn `any`/`ts-ignore` không giải thích
108
+ - [ ] Component tách rõ Logic (hook) / UI (JSX thuần)
109
+ - [ ] State được update immutable
110
+ - [ ] Không gọi API trực tiếp trong component trình bày
111
+ - [ ] Có xử lý loading/error/empty cho dữ liệu async
112
+ - [ ] Dùng Design Token, không inline style tùy tiện
113
+ - [ ] Không có circular dependency
114
+ - [ ] Không có console.log / code chết còn sót lại
115
+ - [ ] Server-state đi qua React Query, không bị copy lại vào `useState`/store khác
116
+ - [ ] `queryKey` lấy từ factory tập trung, không viết tay rải rác
117
+ - [ ] Bảng/list dữ liệu lớn dùng TanStack Table/Virtual thay vì tự viết + render toàn bộ DOM
118
+ - [ ] Form nhiều field dùng TanStack Form (hoặc RHF nếu đã có sẵn), không rời rạc `useState`
119
+ - [ ] Route params/search có type-safe qua TanStack Router, không parse tay
120
+
121
+ > Ghi chú: Nếu dự án dùng Redux thay vì Context/Zustand, áp dụng thêm quy tắc "không dispatch action trực tiếp trong component con sâu — đi qua thunk/selector có kiểm soát". Redux (nếu có) chỉ nên giữ **client state**; server-state luôn thuộc về React Query.