ai-developer-skill-os 7.0.2 → 7.5.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.
- package/.agents/AGENTS.md +44 -88
- package/.agents/CHANGELOG.md +69 -0
- package/.agents/LICENSE +21 -0
- package/.agents/README.md +59 -0
- package/.agents/_template/BEHAVIOR_SPEC.md +96 -0
- package/.agents/_template/examples/example-en.md +49 -0
- package/.agents/_template/examples/example-vi.md +49 -0
- package/.agents/docs/CHI_TIET_SKILLS.md +125 -0
- package/.agents/docs/GOVERNANCE.md +40 -0
- package/.agents/docs/HUONG_DAN_SU_DUNG.md +120 -0
- package/.agents/docs/SPEC.md +87 -0
- package/.agents/docs/adr/0001-intent-based-architecture.md +19 -0
- package/.agents/docs/adr/0002-kernel-freeze.md +21 -0
- package/.agents/docs/adr/0003-risk-based-verification.md +20 -0
- package/.agents/docs/adr/0004-progressive-evidence.md +19 -0
- package/.agents/docs/skill-classification.md +25 -0
- package/.agents/skills/qk-access-policy/SKILL.md +179 -0
- package/.agents/skills/qk-ai-builder/SKILL.md +215 -0
- package/.agents/skills/qk-api-lifecycle/SKILL.md +176 -0
- package/.agents/skills/qk-bug-resolution/SKILL.md +307 -0
- package/.agents/skills/qk-context-loader/SKILL.md +218 -0
- package/.agents/skills/qk-data-lifecycle/SKILL.md +192 -0
- package/.agents/skills/qk-db-optimizer/SKILL.md +196 -0
- package/.agents/skills/qk-design-to-code/SKILL.md +285 -0
- package/.agents/skills/qk-docs/SKILL.md +198 -0
- package/.agents/skills/qk-engineering-standard/SKILL.md +351 -0
- package/.agents/skills/qk-engineering-standard/rules/backend.md +122 -0
- package/.agents/skills/qk-engineering-standard/rules/database.md +3 -0
- package/.agents/skills/qk-engineering-standard/rules/frontend.md +152 -0
- package/.agents/skills/qk-engineering-standard/rules/security.md +3 -0
- package/.agents/skills/qk-engineering-standard/rules/testing.md +3 -0
- package/.agents/skills/qk-fe-api-integration/SKILL.md +326 -0
- package/.agents/skills/qk-feature-delivery/SKILL.md +305 -0
- package/.agents/skills/qk-help/SKILL.md +193 -0
- package/.agents/skills/qk-orchestrator/SKILL.md +277 -0
- package/.agents/skills/qk-orchestrator/references/routing-table.md +77 -0
- package/.agents/skills/qk-production-release/SKILL.md +284 -0
- package/.agents/skills/qk-project-bootstrap/SKILL.md +234 -0
- package/.agents/skills/qk-project-health/SKILL.md +199 -0
- package/.agents/skills/qk-project-memory/SKILL.md +172 -0
- package/.agents/skills/qk-system-evolution/SKILL.md +281 -0
- package/.agents/skills/qk-ui-audit/SKILL.md +314 -0
- package/.agents/skills/qk-ui-audit/references/anti-slop-checklist.md +136 -0
- package/.agents/skills/qk-ui-system-builder/SKILL.md +221 -0
- package/.agents/skills/qk-validation-gate/SKILL.md +359 -0
- package/.agents/skills.json +819 -0
- package/.github/workflows/ci.yml +1 -1
- package/.qk-ai-skill-os/CHANGELOG.md +69 -0
- package/.qk-ai-skill-os/LICENSE +21 -0
- package/.qk-ai-skill-os/README.md +59 -0
- package/.qk-ai-skill-os/_template/BEHAVIOR_SPEC.md +96 -0
- package/.qk-ai-skill-os/_template/examples/example-en.md +49 -0
- package/.qk-ai-skill-os/_template/examples/example-vi.md +49 -0
- package/.qk-ai-skill-os/docs/CHI_TIET_SKILLS.md +125 -0
- package/.qk-ai-skill-os/docs/GOVERNANCE.md +40 -0
- package/.qk-ai-skill-os/docs/HUONG_DAN_SU_DUNG.md +120 -0
- package/.qk-ai-skill-os/docs/SPEC.md +87 -0
- package/.qk-ai-skill-os/docs/adr/0001-intent-based-architecture.md +19 -0
- package/.qk-ai-skill-os/docs/adr/0002-kernel-freeze.md +21 -0
- package/.qk-ai-skill-os/docs/adr/0003-risk-based-verification.md +20 -0
- package/.qk-ai-skill-os/docs/adr/0004-progressive-evidence.md +19 -0
- package/.qk-ai-skill-os/docs/skill-classification.md +25 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-accessibility-audit/SKILL.md +121 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-agent-orchestrator/SKILL.md +179 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-api-integration/SKILL.md +389 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-auth-security/SKILL.md +96 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-backend-architecture/SKILL.md +125 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-bug-fix/SKILL.md +213 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-component-generator/SKILL.md +136 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-context-manager/SKILL.md +175 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-database-engineer/SKILL.md +104 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-deployment/SKILL.md +96 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-design-system/SKILL.md +137 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-form-builder/SKILL.md +140 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-frontend-architecture/SKILL.md +155 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-frontend-debug/SKILL.md +133 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-frontend-performance/SKILL.md +129 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-frontend-testing/SKILL.md +146 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-git-engineer/SKILL.md +304 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-help/SKILL.md +68 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-migration/SKILL.md +284 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-project-audit/SKILL.md +280 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-refactor/SKILL.md +222 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-state-management/SKILL.md +140 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-table-crud-generator/SKILL.md +127 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-ui-builder/SKILL.md +152 -0
- package/.qk-ai-skill-os/skills/_template/SKILL.md +238 -0
- package/.qk-ai-skill-os/skills/qk-access-policy/SKILL.md +179 -0
- package/.qk-ai-skill-os/skills/qk-ai-builder/SKILL.md +221 -0
- package/.qk-ai-skill-os/skills/qk-api-lifecycle/SKILL.md +176 -0
- package/.qk-ai-skill-os/skills/qk-bug-resolution/SKILL.md +307 -0
- package/.qk-ai-skill-os/skills/qk-context-loader/SKILL.md +218 -0
- package/.qk-ai-skill-os/skills/qk-data-lifecycle/SKILL.md +192 -0
- package/.qk-ai-skill-os/skills/qk-db-optimizer/SKILL.md +196 -0
- package/.qk-ai-skill-os/skills/qk-design-to-code/SKILL.md +291 -0
- package/.qk-ai-skill-os/skills/qk-docs/SKILL.md +198 -0
- package/.qk-ai-skill-os/skills/qk-engineering-standard/SKILL.md +351 -0
- package/.qk-ai-skill-os/skills/qk-engineering-standard/rules/backend.md +122 -0
- package/.qk-ai-skill-os/skills/qk-engineering-standard/rules/database.md +3 -0
- package/.qk-ai-skill-os/skills/qk-engineering-standard/rules/frontend.md +152 -0
- package/.qk-ai-skill-os/skills/qk-engineering-standard/rules/security.md +3 -0
- package/.qk-ai-skill-os/skills/qk-engineering-standard/rules/testing.md +3 -0
- package/.qk-ai-skill-os/skills/qk-fe-api-integration/SKILL.md +326 -0
- package/.qk-ai-skill-os/skills/qk-feature-delivery/SKILL.md +305 -0
- package/.qk-ai-skill-os/skills/qk-help/SKILL.md +193 -0
- package/.qk-ai-skill-os/skills/qk-orchestrator/SKILL.md +277 -0
- package/.qk-ai-skill-os/skills/qk-orchestrator/references/routing-table.md +77 -0
- package/.qk-ai-skill-os/skills/qk-production-release/SKILL.md +290 -0
- package/.qk-ai-skill-os/skills/qk-project-bootstrap/SKILL.md +240 -0
- package/.qk-ai-skill-os/skills/qk-project-health/SKILL.md +199 -0
- package/.qk-ai-skill-os/skills/qk-project-memory/SKILL.md +172 -0
- package/.qk-ai-skill-os/skills/qk-system-evolution/SKILL.md +285 -0
- package/.qk-ai-skill-os/skills/qk-ui-audit/SKILL.md +314 -0
- package/.qk-ai-skill-os/skills/qk-ui-audit/references/anti-slop-checklist.md +136 -0
- package/.qk-ai-skill-os/skills/qk-ui-system-builder/SKILL.md +225 -0
- package/.qk-ai-skill-os/skills/qk-validation-gate/SKILL.md +361 -0
- package/.qk-ai-skill-os/skills.json +819 -0
- package/CLAUDE.md +110 -0
- package/README.md +25 -3
- package/add_lang.js +21 -0
- package/add_lang.py +25 -0
- package/add_sections.py +53 -0
- package/bin/install.js +225 -170
- package/bin/lint.js +122 -0
- package/docs/CHI_TIET_SKILLS.md +26 -26
- package/docs/HUONG_DAN_SU_DUNG.md +3 -3
- package/docs/SPEC.md +70 -20
- package/framework/skill-schema.md +310 -0
- package/package.json +15 -4
- package/patch.js +15 -0
- package/patch.py +89 -0
- package/patch2.py +83 -0
- package/skills/_archive_old_skills/qk-accessibility-audit/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-agent-orchestrator/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-api-integration/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-auth-security/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-backend-architecture/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-bug-fix/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-component-generator/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-context-manager/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-database-engineer/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-deployment/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-design-system/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-form-builder/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-frontend-architecture/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-frontend-debug/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-frontend-performance/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-frontend-testing/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-git-engineer/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-help/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-migration/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-project-audit/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-refactor/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-state-management/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-table-crud-generator/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-ui-builder/SKILL.md +1 -0
- package/skills/_template/SKILL.md +238 -0
- package/skills/qk-access-policy/SKILL.md +179 -39
- package/skills/qk-ai-builder/SKILL.md +215 -40
- package/skills/qk-api-lifecycle/SKILL.md +176 -46
- package/skills/qk-bug-resolution/SKILL.md +307 -46
- package/skills/qk-context-loader/SKILL.md +218 -43
- package/skills/qk-data-lifecycle/SKILL.md +192 -44
- package/skills/qk-db-optimizer/SKILL.md +196 -41
- package/skills/qk-design-to-code/SKILL.md +285 -46
- package/skills/qk-docs/SKILL.md +198 -40
- package/skills/qk-engineering-standard/SKILL.md +351 -42
- package/skills/qk-fe-api-integration/SKILL.md +326 -55
- package/skills/qk-feature-delivery/SKILL.md +305 -48
- package/skills/qk-help/SKILL.md +178 -23
- package/skills/qk-orchestrator/SKILL.md +277 -42
- package/skills/qk-orchestrator/references/routing-table.md +77 -0
- package/skills/qk-production-release/SKILL.md +284 -41
- package/skills/qk-project-bootstrap/SKILL.md +234 -38
- package/skills/qk-project-health/SKILL.md +199 -40
- package/skills/qk-project-memory/SKILL.md +172 -40
- package/skills/qk-system-evolution/SKILL.md +281 -40
- package/skills/qk-ui-audit/SKILL.md +314 -42
- package/skills/qk-ui-audit/references/anti-slop-checklist.md +136 -0
- package/skills/qk-ui-system-builder/SKILL.md +221 -43
- package/skills/qk-validation-gate/SKILL.md +359 -40
- package/skills.json +813 -824
- package/specs/fixtures/user-payload.json +12 -0
- package/specs/regressions/api-integration-null-fields.yaml +19 -0
- package/temp_fix.js +61 -0
- package/tests/registry.test.js +1 -1
- package/update_template.js +28 -0
- package/skills/qk-policy-engine/SKILL.md +0 -39
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: qk-context-loader
|
|
3
|
+
category: utilities
|
|
4
|
+
version: 7.5.0
|
|
5
|
+
description: "Tải context và vẽ dependency graph chính xác trước khi code — ngăn hallucination kiến trúc."
|
|
6
|
+
platforms: [antigravity, claude-code, cursor, windsurf, kilo-code]
|
|
7
|
+
execution_mode: deterministic
|
|
8
|
+
|
|
9
|
+
cost: low
|
|
10
|
+
latency: fast
|
|
11
|
+
risk: low
|
|
12
|
+
side_effects: read_only
|
|
13
|
+
produces: [context-graph]
|
|
14
|
+
consumes: [source-code]
|
|
15
|
+
|
|
16
|
+
token_budget:
|
|
17
|
+
max_files_read: 5
|
|
18
|
+
max_lines_per_read: 100
|
|
19
|
+
max_shell_commands: 1
|
|
20
|
+
stop_early: true
|
|
21
|
+
|
|
22
|
+
exit_codes: [SUCCESS, BLOCKED, FAILED, PARTIAL]
|
|
23
|
+
skill_version: 7.5.0
|
|
24
|
+
runtime_version: 1
|
|
25
|
+
schema_version: 2
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
# qk-context-loader — Dependency Graph Builder
|
|
29
|
+
|
|
30
|
+
> **Language rule:** Code, identifiers, file names ? English. Explanations, summaries ? Vietnamese.
|
|
31
|
+
|
|
32
|
+
skill_version: 7.5.0
|
|
33
|
+
runtime_version: 1
|
|
34
|
+
schema_version: 2
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Preconditions
|
|
38
|
+
- [ ] Entry point file or module name is specified
|
|
39
|
+
- [ ] Repository is accessible
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
On missing precondition:
|
|
43
|
+
EXIT: BLOCKED
|
|
44
|
+
Message: "Vui lòng chỉ định entry point (file hoặc module cần map)."
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
skill_version: 7.5.0
|
|
48
|
+
runtime_version: 1
|
|
49
|
+
schema_version: 2
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Scope
|
|
53
|
+
- ✅ Trace imports/exports from entry point
|
|
54
|
+
- ✅ Build topological dependency graph (max depth 3)
|
|
55
|
+
- ✅ Identify risk level per module
|
|
56
|
+
|
|
57
|
+
## Non-Goals
|
|
58
|
+
- ❌ Modify any code
|
|
59
|
+
- ❌ Load `node_modules` or vendor directories
|
|
60
|
+
- ❌ Guess file names — only follow explicit imports
|
|
61
|
+
- ❌ Load entire repo (max 5 files)
|
|
62
|
+
|
|
63
|
+
skill_version: 7.5.0
|
|
64
|
+
runtime_version: 1
|
|
65
|
+
schema_version: 2
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Priority Order
|
|
69
|
+
|
|
70
|
+
| Priority | Task | Skip Threshold |
|
|
71
|
+
|----------|------|----------------|
|
|
72
|
+
| P1 | Trace direct imports of entry point | Never |
|
|
73
|
+
| P2 | Trace 2nd-level dependencies | Budget < 40% |
|
|
74
|
+
| P3 | Identify shared/risky modules | Budget < 60% |
|
|
75
|
+
| P4 | Annotate with risk levels | Budget < 70% |
|
|
76
|
+
|
|
77
|
+
skill_version: 7.5.0
|
|
78
|
+
runtime_version: 1
|
|
79
|
+
schema_version: 2
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Workflow
|
|
83
|
+
|
|
84
|
+
### Phase 1 — Entry Point Analysis
|
|
85
|
+
|
|
86
|
+
**Steps:**
|
|
87
|
+
1. `grep_search` — search for import/export statements in entry file
|
|
88
|
+
2. `view_file[StartLine:EndLine]` — read import block only (first ~30 lines)
|
|
89
|
+
3. List direct dependencies
|
|
90
|
+
|
|
91
|
+
**Decision:**
|
|
92
|
+
```
|
|
93
|
+
IF entry file found and imports readable
|
|
94
|
+
→ go to Phase 2
|
|
95
|
+
|
|
96
|
+
ELSE IF entry file not found
|
|
97
|
+
→ EXIT: BLOCKED — ask for correct path
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
skill_version: 7.5.0
|
|
101
|
+
runtime_version: 1
|
|
102
|
+
schema_version: 2
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
### Phase 2 — Graph Traversal (Max Depth 3)
|
|
106
|
+
|
|
107
|
+
**Steps:**
|
|
108
|
+
1. For each direct dependency → `grep_search` for its imports
|
|
109
|
+
2. Build adjacency list: `{ file → [imports] }`
|
|
110
|
+
3. Stop at depth 3 OR max_files_read reached
|
|
111
|
+
|
|
112
|
+
**Decision:**
|
|
113
|
+
```
|
|
114
|
+
IF depth 3 reached OR max_files_read (5) hit
|
|
115
|
+
→ EXIT: PARTIAL — note graph is truncated at depth N
|
|
116
|
+
|
|
117
|
+
IF circular dependency detected
|
|
118
|
+
→ Flag as [HIGH RISK] in output
|
|
119
|
+
→ Continue building rest of graph
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
skill_version: 7.5.0
|
|
123
|
+
runtime_version: 1
|
|
124
|
+
schema_version: 2
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
### Phase 3 — Risk Assessment & Output
|
|
128
|
+
|
|
129
|
+
**Steps:**
|
|
130
|
+
1. Identify: shared modules (imported by 3+ files) = HIGH risk to change
|
|
131
|
+
2. Identify: entry points with many dependents = CRITICAL to change carefully
|
|
132
|
+
3. Generate graph in standard JSON + Markdown format
|
|
133
|
+
|
|
134
|
+
skill_version: 7.5.0
|
|
135
|
+
runtime_version: 1
|
|
136
|
+
schema_version: 2
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Output Format (Mandatory Schema)
|
|
140
|
+
|
|
141
|
+
```json
|
|
142
|
+
{
|
|
143
|
+
"entry": "src/modules/auth/auth.service.ts",
|
|
144
|
+
"depth_reached": 3,
|
|
145
|
+
"truncated": false,
|
|
146
|
+
"nodes": [
|
|
147
|
+
{
|
|
148
|
+
"file": "src/modules/auth/auth.service.ts",
|
|
149
|
+
"imports": ["src/common/jwt.util.ts", "src/users/users.repository.ts"],
|
|
150
|
+
"exports": ["AuthService"],
|
|
151
|
+
"risk_level": "high",
|
|
152
|
+
"imported_by_count": 4
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
"risks": [
|
|
156
|
+
{
|
|
157
|
+
"file": "src/common/jwt.util.ts",
|
|
158
|
+
"reason": "Imported by 6 modules — changes here have wide blast radius",
|
|
159
|
+
"risk_level": "critical"
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
skill_version: 7.5.0
|
|
166
|
+
runtime_version: 1
|
|
167
|
+
schema_version: 2
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Evidence Format
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
[RISK] path/to/file.ts
|
|
174
|
+
Reason: [why this file is risky to change]
|
|
175
|
+
Imported by: [N files]
|
|
176
|
+
Exports: [key exports]
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
skill_version: 7.5.0
|
|
180
|
+
runtime_version: 1
|
|
181
|
+
schema_version: 2
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Handoff Contract
|
|
185
|
+
|
|
186
|
+
### Consumes
|
|
187
|
+
```json
|
|
188
|
+
{
|
|
189
|
+
"from": "user or qk-orchestrator",
|
|
190
|
+
"required_fields": ["entry_point"],
|
|
191
|
+
"optional_fields": ["max_depth", "exclude_patterns"]
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Produces
|
|
196
|
+
```json
|
|
197
|
+
{
|
|
198
|
+
"to": "qk-feature-delivery | qk-bug-resolution | qk-data-lifecycle | qk-api-lifecycle",
|
|
199
|
+
"output_fields": ["dependency_graph_json", "risk_summary", "exit_code"]
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
skill_version: 7.5.0
|
|
204
|
+
runtime_version: 1
|
|
205
|
+
schema_version: 2
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Exit Codes
|
|
209
|
+
|
|
210
|
+
| Code | Meaning | When |
|
|
211
|
+
|------|---------|------|
|
|
212
|
+
| SUCCESS | Full graph built within depth limit | All imports traced |
|
|
213
|
+
| PARTIAL | Graph truncated at token/depth limit | Note where it was cut |
|
|
214
|
+
| BLOCKED | Entry point not found or inaccessible | Ask for correct path |
|
|
215
|
+
| FAILED | Cannot determine architecture (circular imports, obfuscated code) | Report and escalate |
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: qk-data-lifecycle
|
|
3
|
+
category: backend
|
|
4
|
+
version: 7.5.0
|
|
5
|
+
description: "Quản lý Schema, Migrations an toàn — schema freeze → backward-compat migration → cleanup."
|
|
6
|
+
platforms: [antigravity, claude-code, cursor, windsurf, kilo-code]
|
|
7
|
+
execution_mode: deterministic
|
|
8
|
+
cost: high
|
|
9
|
+
latency: slow
|
|
10
|
+
risk: high
|
|
11
|
+
side_effects: edit_files
|
|
12
|
+
produces: [code, schema]
|
|
13
|
+
consumes: [context-graph, user-description]
|
|
14
|
+
token_budget:
|
|
15
|
+
max_files_read: 4
|
|
16
|
+
max_lines_per_read: 100
|
|
17
|
+
max_shell_commands: 1
|
|
18
|
+
stop_early: false
|
|
19
|
+
exit_codes: [SUCCESS, BLOCKED, FAILED, PARTIAL]
|
|
20
|
+
skill_version: 7.5.0
|
|
21
|
+
runtime_version: 1
|
|
22
|
+
schema_version: 2
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
# qk-data-lifecycle — Database Schema & Repository Manager
|
|
26
|
+
|
|
27
|
+
> **Language rule:** Code, identifiers, file names ? English. Explanations, summaries ? Vietnamese.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Preconditions
|
|
32
|
+
- [ ] Existing schema is identified (ORM model files)
|
|
33
|
+
- [ ] Change intent is clear (add field / modify field / drop field)
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
On missing precondition:
|
|
37
|
+
EXIT: BLOCKED
|
|
38
|
+
Message: "Cần xác định: schema hiện tại + loại thay đổi (add/modify/drop)."
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Scope
|
|
44
|
+
- ✅ Define strict schema BEFORE writing repository code
|
|
45
|
+
- ✅ Always backward-compatible migrations (never destructive in first pass)
|
|
46
|
+
- ✅ Separate schema (models) from business logic (services)
|
|
47
|
+
|
|
48
|
+
## Non-Goals
|
|
49
|
+
- ❌ DROP columns without deprecation phase first
|
|
50
|
+
- ❌ Write complex business logic inside repositories
|
|
51
|
+
- ❌ Dynamic queries without schema definitions
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Priority Order
|
|
56
|
+
| P | Task | Skip Threshold |
|
|
57
|
+
|---|------|----------------|
|
|
58
|
+
| P1 | Read existing schema | Never |
|
|
59
|
+
| P2 | Design migration (backward-compat) | Never |
|
|
60
|
+
| P3 | Write migration file | Never |
|
|
61
|
+
| P4 | Update repository layer | Budget < 30% |
|
|
62
|
+
| P5 | Update affected service layer | Budget < 50% |
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Migration Safety Rules
|
|
67
|
+
```yaml
|
|
68
|
+
add_column:
|
|
69
|
+
strategy: nullable OR has default value (never NOT NULL without default)
|
|
70
|
+
|
|
71
|
+
modify_column:
|
|
72
|
+
strategy: add new column → migrate data → drop old column (3-phase)
|
|
73
|
+
|
|
74
|
+
drop_column:
|
|
75
|
+
strategy: Phase 1 — mark deprecated (keep in schema)
|
|
76
|
+
Phase 2 — next release — remove from queries
|
|
77
|
+
Phase 3 — next migration — DROP COLUMN
|
|
78
|
+
|
|
79
|
+
rename_table:
|
|
80
|
+
strategy: create new table → migrate → drop old (never ALTER TABLE RENAME in prod)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Workflow
|
|
86
|
+
|
|
87
|
+
### Phase 1 — Schema Read
|
|
88
|
+
1. `grep_search` for existing model/entity file
|
|
89
|
+
2. Read current schema (targeted, ≤ 100 lines)
|
|
90
|
+
3. Identify impact of proposed change
|
|
91
|
+
|
|
92
|
+
### Phase 2 — Migration Design
|
|
93
|
+
1. Choose safety strategy (see Migration Safety Rules)
|
|
94
|
+
2. Write migration file (up + down)
|
|
95
|
+
3. Verify down() is always defined (rollback support)
|
|
96
|
+
|
|
97
|
+
### Phase 3 — Repository Update
|
|
98
|
+
1. Update repository methods to use new schema
|
|
99
|
+
2. Verify no raw queries reference old column names
|
|
100
|
+
|
|
101
|
+
**Decision:**
|
|
102
|
+
```
|
|
103
|
+
IF migration is backward-compat AND down() defined → EXIT: SUCCESS
|
|
104
|
+
ELSE IF destructive migration attempted → EXIT: BLOCKED — apply 3-phase strategy
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Evidence Format
|
|
110
|
+
```
|
|
111
|
+
[SEVERITY] migration: [filename]
|
|
112
|
+
Issue: [NOT NULL without default | missing down() | direct DROP]
|
|
113
|
+
Confidence: HIGH
|
|
114
|
+
Fix: [specific safer strategy]
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Exit Codes
|
|
120
|
+
| Code | Meaning | When |
|
|
121
|
+
|------|---------|------|
|
|
122
|
+
| SUCCESS | Schema, migration, and repository complete | Validated execution |
|
|
123
|
+
| PARTIAL | Migration generated but untested | Missing DB connection |
|
|
124
|
+
| BLOCKED | Fields or relationships ambiguous | Missing entity data |
|
|
125
|
+
| FAILED | Migration involves destructive DROP without backup | Architecture violation |
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Confidence Model
|
|
130
|
+
| Level | Condition | Action |
|
|
131
|
+
|-------|-----------|--------|
|
|
132
|
+
| HIGH | Entity schema completely defined by user | Implement immediately |
|
|
133
|
+
| MEDIUM | Schema inferred from JSON or forms | Ask for review before generating migration |
|
|
134
|
+
| LOW | "Add database" request with no schema | EXIT: BLOCKED |
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Severity
|
|
139
|
+
| Level | Definition | Example |
|
|
140
|
+
|-------|-----------|---------|
|
|
141
|
+
| CRITICAL | Data loss risk in migration | Direct `DROP TABLE` without data copy |
|
|
142
|
+
| HIGH | Missing index on foreign key | Performance degrade on JOIN |
|
|
143
|
+
| MEDIUM | N+1 query vulnerability in repository | Fetching related entities in a loop |
|
|
144
|
+
| LOW | Naming convention violation | `userId` instead of `user_id` in DB |
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Retry Policy
|
|
149
|
+
```
|
|
150
|
+
Migration generation fails
|
|
151
|
+
└─ Syntax error in SQL/ORM
|
|
152
|
+
├─ Fix syntax based on engine (Postgres/MySQL)
|
|
153
|
+
└─ Do NOT retry more than 1 time — risk of bad migration state
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Escalation Rules
|
|
159
|
+
```
|
|
160
|
+
BLOCKED: Entity schema undefined
|
|
161
|
+
Missing:
|
|
162
|
+
- List of fields (types, constraints)
|
|
163
|
+
- Relationships (1:1, 1:N, M:N)
|
|
164
|
+
Questions:
|
|
165
|
+
1. Bảng này cần lưu những trường dữ liệu nào?
|
|
166
|
+
2. Bảng này có liên kết với bảng nào khác không? (ví dụ User)
|
|
167
|
+
Recommended Assumptions:
|
|
168
|
+
- Add standard created_at, updated_at timestamps
|
|
169
|
+
- UUID primary keys
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Handoff Contract
|
|
175
|
+
### Consumes
|
|
176
|
+
```json
|
|
177
|
+
{
|
|
178
|
+
"from": "user",
|
|
179
|
+
"required_fields": ["entity_name", "fields"],
|
|
180
|
+
"optional_fields": ["relationships", "db_engine"]
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
### Produces
|
|
184
|
+
```json
|
|
185
|
+
{
|
|
186
|
+
"to": "user or db-optimizer",
|
|
187
|
+
"output_fields": ["schema_file", "migration_file", "repository_file", "exit_code"]
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: qk-db-optimizer
|
|
3
|
+
category: backend
|
|
4
|
+
version: 7.5.0
|
|
5
|
+
description: "Tối ưu Database dựa trên bằng chứng: EXPLAIN → phân tích → index/join — không đoán mò."
|
|
6
|
+
platforms: [antigravity, claude-code, cursor, windsurf, kilo-code]
|
|
7
|
+
execution_mode: deterministic
|
|
8
|
+
cost: medium
|
|
9
|
+
latency: medium
|
|
10
|
+
risk: medium
|
|
11
|
+
side_effects: edit_files
|
|
12
|
+
produces: [code, report]
|
|
13
|
+
consumes: [query-log, source-code]
|
|
14
|
+
token_budget:
|
|
15
|
+
max_files_read: 3
|
|
16
|
+
max_lines_per_read: 100
|
|
17
|
+
max_shell_commands: 2
|
|
18
|
+
stop_early: true
|
|
19
|
+
exit_codes: [SUCCESS, BLOCKED, FAILED, PARTIAL]
|
|
20
|
+
skill_version: 7.5.0
|
|
21
|
+
runtime_version: 1
|
|
22
|
+
schema_version: 2
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
# qk-db-optimizer — Database Performance Tuner
|
|
26
|
+
|
|
27
|
+
> **Language rule:** Code, identifiers, file names ? English. Explanations, summaries ? Vietnamese.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Preconditions
|
|
32
|
+
- [ ] Slow query log OR specific slow query is provided
|
|
33
|
+
- [ ] Database schema/ORM models accessible
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
On missing precondition:
|
|
37
|
+
EXIT: BLOCKED
|
|
38
|
+
Message: "Cần: slow query log hoặc query cụ thể cần tối ưu."
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Scope
|
|
44
|
+
- ✅ Analyze EXPLAIN/query plans before adding indexes
|
|
45
|
+
- ✅ Solve N+1 with Data Loaders or explicit Joins
|
|
46
|
+
- ✅ Validate performance improvement
|
|
47
|
+
|
|
48
|
+
## Non-Goals
|
|
49
|
+
- ❌ Add indexes without slow query evidence
|
|
50
|
+
- ❌ Add overlapping or redundant indexes
|
|
51
|
+
- ❌ Optimize queries not shown in slow query log
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Priority Order
|
|
56
|
+
| P | Issue Type | Action | Skip Threshold |
|
|
57
|
+
|---|-----------|--------|----------------|
|
|
58
|
+
| P1 | Sequential scan on large table (> 10k rows) | Add composite index | Never |
|
|
59
|
+
| P2 | N+1 query pattern | Eager load / DataLoader | Budget < 30% |
|
|
60
|
+
| P3 | Missing JOIN (multiple queries for related data) | Rewrite with JOIN | Budget < 50% |
|
|
61
|
+
| P4 | SELECT * (over-fetching) | Select specific columns | Budget < 60% |
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## EXPLAIN Decision Tree
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
Run EXPLAIN ANALYZE on slow query
|
|
69
|
+
|
|
70
|
+
IF "Seq Scan" on table > 10k rows
|
|
71
|
+
→ Check cardinality of filter column
|
|
72
|
+
→ IF cardinality > 100 → add B-tree index
|
|
73
|
+
→ IF low cardinality → add partial index or reconsider query
|
|
74
|
+
|
|
75
|
+
IF "Nested Loop" with many iterations
|
|
76
|
+
→ Check: is this N+1?
|
|
77
|
+
→ IF yes → rewrite as single JOIN or use DataLoader
|
|
78
|
+
|
|
79
|
+
IF "Sort" without index
|
|
80
|
+
→ Add index on ORDER BY column
|
|
81
|
+
|
|
82
|
+
IF index exists but not used ("Index Scan" missing)
|
|
83
|
+
→ Check: is WHERE clause using non-leading column of composite index?
|
|
84
|
+
→ Reorder composite index columns
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Workflow
|
|
90
|
+
|
|
91
|
+
### Phase 1 — Evidence Collection
|
|
92
|
+
1. Read slow query log or provided query
|
|
93
|
+
2. Run EXPLAIN ANALYZE (1 command) — or analyze ORM-generated SQL
|
|
94
|
+
3. Identify bottleneck pattern (seq scan / N+1 / sort / over-fetch)
|
|
95
|
+
|
|
96
|
+
### Phase 2 — Solution Design
|
|
97
|
+
1. Apply Decision Tree above
|
|
98
|
+
2. Design minimal index or query rewrite
|
|
99
|
+
|
|
100
|
+
### Phase 3 — Apply & Verify
|
|
101
|
+
1. Apply change (add index migration OR rewrite query via `replace_file_content`)
|
|
102
|
+
2. (Optional) Re-run EXPLAIN to verify improvement (2nd command)
|
|
103
|
+
|
|
104
|
+
**Decision:**
|
|
105
|
+
```
|
|
106
|
+
IF improvement verified → EXIT: SUCCESS
|
|
107
|
+
IF improvement not measurable → EXIT: PARTIAL, note "verify in production"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Evidence Format
|
|
113
|
+
```
|
|
114
|
+
[SEVERITY] query in src/repositories/[name].ts:LINE
|
|
115
|
+
Pattern: [SEQ_SCAN | N+1 | MISSING_JOIN | OVER_FETCH | UNUSED_INDEX]
|
|
116
|
+
Table: [table_name] (~N rows estimated)
|
|
117
|
+
Confidence: HIGH
|
|
118
|
+
Fix: [specific index or rewrite]
|
|
119
|
+
Estimated improvement: [X% reduction in scan rows]
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Exit Codes
|
|
125
|
+
| Code | Meaning | When |
|
|
126
|
+
|------|---------|------|
|
|
127
|
+
| SUCCESS | Index added or query rewritten, improvement verified | Post-optimization |
|
|
128
|
+
| PARTIAL | Optimization applied but could not verify via EXPLAIN | DB access blocked |
|
|
129
|
+
| BLOCKED | Log not provided or DB engine unknown | Missing inputs |
|
|
130
|
+
| FAILED | Optimization breaks existing test or query syntax | Logic error |
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Confidence Model
|
|
135
|
+
| Level | Condition | Action |
|
|
136
|
+
|-------|-----------|--------|
|
|
137
|
+
| HIGH | EXPLAIN plan shows SEQ SCAN, user confirms index is missing | Add index / rewrite |
|
|
138
|
+
| MEDIUM | Query looks inefficient but no EXPLAIN available | Ask to run EXPLAIN |
|
|
139
|
+
| LOW | "Make DB faster" with no slow query log | EXIT: BLOCKED |
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Severity
|
|
144
|
+
| Level | Definition | Example |
|
|
145
|
+
|-------|-----------|---------|
|
|
146
|
+
| CRITICAL | Query locking table in production | Long running UPDATE |
|
|
147
|
+
| HIGH | Missing index on frequently joined table | Full scan on million rows |
|
|
148
|
+
| MEDIUM | N+1 queries due to missing JOIN | ORM fetching relations in loop |
|
|
149
|
+
| LOW | Over-fetching columns | `SELECT *` instead of specific |
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Retry Policy
|
|
154
|
+
```
|
|
155
|
+
EXPLAIN query fails
|
|
156
|
+
└─ Check SQL syntax error vs connection error
|
|
157
|
+
├─ Syntax error → correct SQL → retry EXPLAIN
|
|
158
|
+
└─ Do NOT retry more than 1 time — risk of locking
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Escalation Rules
|
|
164
|
+
```
|
|
165
|
+
BLOCKED: Slow query log not provided
|
|
166
|
+
Missing:
|
|
167
|
+
- The actual slow query SQL
|
|
168
|
+
- Current schema of the involved tables
|
|
169
|
+
Questions:
|
|
170
|
+
1. Câu query nào đang bị chậm? (Xin SQL / ORM log)
|
|
171
|
+
2. Bảng này hiện đang có những index nào?
|
|
172
|
+
Recommended Assumptions:
|
|
173
|
+
- Do NOT assume table size or indexes blindly
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Handoff Contract
|
|
179
|
+
### Consumes
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"from": "user",
|
|
183
|
+
"required_fields": ["slow_query"],
|
|
184
|
+
"optional_fields": ["schema", "explain_plan", "db_engine"]
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
### Produces
|
|
188
|
+
```json
|
|
189
|
+
{
|
|
190
|
+
"to": "user",
|
|
191
|
+
"output_fields": ["optimized_query", "migration_file", "explain_diff", "exit_code"]
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|