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,222 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: qk-refactor
|
|
3
|
+
description: >-
|
|
4
|
+
Tái cấu trúc và dọn dẹp mã nguồn để dễ bảo trì hơn mà không làm thay đổi logic hoạt động bên ngoài.
|
|
5
|
+
version: 1.0.0
|
|
6
|
+
category: engineering
|
|
7
|
+
tags: [refactor, clean-code, restructure, technical-debt, maintainability]
|
|
8
|
+
platforms: [antigravity, claude-code, kilo-code, cursor, windsurf]
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Refactor — Safe Restructuring
|
|
12
|
+
|
|
13
|
+
> **Language rule:**
|
|
14
|
+
> Use English for: code, identifiers, file names, architecture terms, technical decisions.
|
|
15
|
+
> Use the user's language for: explanations, questions, summaries, and feedback.
|
|
16
|
+
> The user may write in any language — detect and match it automatically.
|
|
17
|
+
|
|
18
|
+
> ⚠️ **Core constraint: Refactoring must NOT change observable behavior.**
|
|
19
|
+
> If behavior changes are needed → that is a feature, not a refactor.
|
|
20
|
+
> Stop and clarify with the user before proceeding.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Trigger
|
|
25
|
+
|
|
26
|
+
Activate this skill when:
|
|
27
|
+
- User says "clean up", "refactor", "it's too messy", "hard to maintain"
|
|
28
|
+
- Code has grown beyond its original design (God component, fat service, spaghetti logic)
|
|
29
|
+
- Duplicate patterns exist across multiple files
|
|
30
|
+
- `project-audit` identified architecture issues (P2/P3) ready to be addressed
|
|
31
|
+
- User asks to "improve code quality" without changing functionality
|
|
32
|
+
|
|
33
|
+
**Not this skill** → Use `bug-fix` if behavior is wrong. Use `migration` if upgrading dependencies.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Scope
|
|
38
|
+
|
|
39
|
+
- ✅ Rename for clarity (variables, functions, files, components)
|
|
40
|
+
- ✅ Extract reusable logic into functions, hooks, services, or utilities
|
|
41
|
+
- ✅ Remove dead code, unused imports, and orphaned files
|
|
42
|
+
- ✅ Split large components / functions into focused units
|
|
43
|
+
- ✅ Apply consistent patterns across the codebase
|
|
44
|
+
- ✅ Improve type coverage (replace `any`, add missing types)
|
|
45
|
+
- ✅ Reduce complexity (flatten nested conditions, simplify logic)
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Non-goals
|
|
50
|
+
|
|
51
|
+
- ❌ Do NOT change behavior — if you must, stop and discuss first
|
|
52
|
+
- ❌ Do NOT change public APIs or exported interfaces without explicit approval
|
|
53
|
+
- ❌ Do NOT rewrite everything — prefer incremental, targeted changes
|
|
54
|
+
- ❌ Do NOT apply opinionated style changes (formatting belongs to linter/prettier)
|
|
55
|
+
- ❌ Do NOT introduce new dependencies
|
|
56
|
+
- ❌ Do NOT refactor code unrelated to the stated scope
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Severity Levels (for issues found during analysis)
|
|
61
|
+
|
|
62
|
+
| Level | Meaning |
|
|
63
|
+
|-------|---------|
|
|
64
|
+
| P0 | Refactor introduces breaking change — stop immediately |
|
|
65
|
+
| P1 | High coupling or duplication blocking feature work |
|
|
66
|
+
| P2 | Code smell reducing maintainability |
|
|
67
|
+
| P3 | Minor naming or style inconsistency |
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Workflow
|
|
72
|
+
|
|
73
|
+
### Phase 1 — Understand Current State
|
|
74
|
+
|
|
75
|
+
Before changing anything:
|
|
76
|
+
1. Read the target code thoroughly
|
|
77
|
+
2. Identify what it does (behavior, inputs, outputs, side effects)
|
|
78
|
+
3. Note all callers and dependents of the code being refactored
|
|
79
|
+
4. Check for existing tests — these are the safety net
|
|
80
|
+
|
|
81
|
+
If there are **no tests** for the code being refactored → recommend writing characterization tests first, or proceed with extra caution and document risks.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
### Phase 2 — Identify Refactor Targets
|
|
86
|
+
|
|
87
|
+
Common code smells to look for:
|
|
88
|
+
|
|
89
|
+
| Smell | Description |
|
|
90
|
+
|-------|-------------|
|
|
91
|
+
| God Component/Function | Does too many things — split by responsibility |
|
|
92
|
+
| Duplicate Logic | Same pattern repeated — extract to shared utility |
|
|
93
|
+
| Long Parameter Lists | >4 params — use options object |
|
|
94
|
+
| Deep Nesting | >3 levels of if/else — flatten with early returns |
|
|
95
|
+
| Magic Numbers/Strings | Unnamed constants — extract to named constants |
|
|
96
|
+
| Dead Code | Unused variables, functions, imports — remove |
|
|
97
|
+
| Inconsistent Naming | Mixed conventions — standardize |
|
|
98
|
+
| Missing Types | `any`, missing return types — add precise types |
|
|
99
|
+
| Large Files | >300 lines — consider splitting by concern |
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
### Phase 3 — Plan the Refactor
|
|
104
|
+
|
|
105
|
+
Create a step-by-step plan before touching code:
|
|
106
|
+
|
|
107
|
+
1. List each specific change with its justification
|
|
108
|
+
2. Order changes from lowest to highest risk
|
|
109
|
+
3. Identify what tests must pass after each step
|
|
110
|
+
4. Flag any changes that touch shared/exported code
|
|
111
|
+
|
|
112
|
+
Present plan to user if scope is large or changes are risky.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
### Phase 4 — Execute Incrementally
|
|
117
|
+
|
|
118
|
+
Apply changes in small, verifiable steps:
|
|
119
|
+
|
|
120
|
+
**Safe refactor order:**
|
|
121
|
+
1. Rename (lowest risk — IDEs can do this safely)
|
|
122
|
+
2. Extract (pull logic into new functions/hooks without changing callers)
|
|
123
|
+
3. Inline (remove unnecessary abstraction)
|
|
124
|
+
4. Move (relocate to correct file/folder)
|
|
125
|
+
5. Simplify (reduce complexity in logic)
|
|
126
|
+
6. Remove (delete dead code last — confirm nothing breaks)
|
|
127
|
+
|
|
128
|
+
After **each step** → verify tests still pass before moving on.
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
### Phase 5 — Verify Behavior Preserved
|
|
133
|
+
|
|
134
|
+
- [ ] All existing tests pass
|
|
135
|
+
- [ ] Run lint and type-check — clean
|
|
136
|
+
- [ ] Manual smoke test of affected functionality
|
|
137
|
+
- [ ] No new `any` types introduced
|
|
138
|
+
- [ ] No unused imports or dead code left
|
|
139
|
+
- [ ] Public API unchanged (or explicitly approved to change)
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
### Phase 6 — Report
|
|
144
|
+
|
|
145
|
+
Document what changed and why:
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
What changed: [List of changes]
|
|
149
|
+
Why: [Specific smell or issue addressed]
|
|
150
|
+
Risk level: [Low / Medium / High]
|
|
151
|
+
Tests status: [All pass / N new tests added]
|
|
152
|
+
Behavior: [Unchanged — verified]
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Decision Tree
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
Is there existing test coverage?
|
|
161
|
+
├── Yes → Proceed — tests are the safety net
|
|
162
|
+
└── No → Recommend characterization tests first
|
|
163
|
+
├── User agrees → write tests then refactor
|
|
164
|
+
└── User wants to proceed anyway → proceed with caution, document risk
|
|
165
|
+
|
|
166
|
+
Does the refactor change public APIs?
|
|
167
|
+
├── Yes → Stop — confirm with user, this may be a breaking change
|
|
168
|
+
└── No → Proceed
|
|
169
|
+
|
|
170
|
+
Is the scope larger than expected?
|
|
171
|
+
├── Yes → Present updated plan, get approval before continuing
|
|
172
|
+
└── No → Continue
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Output Format
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
🔧 Refactor Summary
|
|
181
|
+
─────────────────────────────────────────────────
|
|
182
|
+
Scope: [What was refactored]
|
|
183
|
+
Changes: [N files modified, N extracted, N removed]
|
|
184
|
+
|
|
185
|
+
Changes applied:
|
|
186
|
+
✅ [Rename: oldName → newName in path/to/file.ts]
|
|
187
|
+
✅ [Extract: logic → useCustomHook in path/to/hook.ts]
|
|
188
|
+
✅ [Remove: dead code in path/to/old.ts]
|
|
189
|
+
✅ [Split: LargeComponent → ComponentA + ComponentB]
|
|
190
|
+
|
|
191
|
+
📊 Quality improvement:
|
|
192
|
+
Before: [brief description of the problem]
|
|
193
|
+
After: [brief description of improvement]
|
|
194
|
+
|
|
195
|
+
✅ Verification:
|
|
196
|
+
Tests: PASS (N tests)
|
|
197
|
+
Lint: Clean
|
|
198
|
+
Types: No new `any`
|
|
199
|
+
Behavior: Unchanged
|
|
200
|
+
|
|
201
|
+
⚠️ Notes:
|
|
202
|
+
[Any assumptions, risks, or follow-up suggestions]
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Validation Checklist
|
|
208
|
+
|
|
209
|
+
- [ ] Behavior is unchanged — verified with tests or manual check
|
|
210
|
+
- [ ] All tests pass
|
|
211
|
+
- [ ] Lint and type-check clean
|
|
212
|
+
- [ ] No dead code, unused imports, or console.logs left
|
|
213
|
+
- [ ] Public APIs unchanged (or explicitly approved)
|
|
214
|
+
- [ ] Changes are documented with justification
|
|
215
|
+
- [ ] No new dependencies introduced
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Examples
|
|
220
|
+
|
|
221
|
+
See `examples/` folder.
|
|
222
|
+
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: qk-state-management
|
|
3
|
+
description: >-
|
|
4
|
+
Xác định và triển khai chiến lược quản lý state phù hợp (Zustand, Redux, React Query, Local State).
|
|
5
|
+
version: 1.0.0
|
|
6
|
+
category: frontend
|
|
7
|
+
tags: [state, redux, zustand, react-query, context, pinia, data-flow]
|
|
8
|
+
platforms: [antigravity, claude-code, kilo-code, cursor, windsurf]
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# State Management
|
|
12
|
+
|
|
13
|
+
> **Language rule:**
|
|
14
|
+
> Use English for: code, identifiers, file names, architecture terms, technical decisions.
|
|
15
|
+
> Use the user's language for: explanations, questions, summaries, and feedback.
|
|
16
|
+
> The user may write in any language — detect and match it automatically.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Trigger
|
|
21
|
+
|
|
22
|
+
Activate this skill when:
|
|
23
|
+
- User asks to "store this data", "share state between components", or "cache API results"
|
|
24
|
+
- Prop drilling becomes excessive (>3 levels deep)
|
|
25
|
+
- Integrating complex UI interactions that need memory (e.g., shopping cart, multi-step wizard)
|
|
26
|
+
- Managing async server data and loading/error states
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Scope
|
|
31
|
+
|
|
32
|
+
- ✅ Decide which state layer to use based on the data's lifecycle and scope
|
|
33
|
+
- ✅ Implement local state (`useState`, `useReducer`, `ref`)
|
|
34
|
+
- ✅ Implement global UI state (Zustand, Pinia, Context, Redux)
|
|
35
|
+
- ✅ Implement server state (React Query, SWR, Apollo)
|
|
36
|
+
- ✅ Ensure state is immutable and updates correctly
|
|
37
|
+
- ✅ Prevent race conditions and stale state bugs
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Non-goals
|
|
42
|
+
|
|
43
|
+
- ❌ Do NOT introduce a new state management library if the project already uses one
|
|
44
|
+
- ❌ Do NOT put server data (API responses) in a global UI store (like Redux) if React Query is available
|
|
45
|
+
- ❌ Do NOT use global state for something that should be local (e.g., a modal's `isOpen` state)
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Workflow
|
|
50
|
+
|
|
51
|
+
### Phase 1 — State Classification
|
|
52
|
+
|
|
53
|
+
Analyze the data the user wants to manage and classify it:
|
|
54
|
+
|
|
55
|
+
1. **Local UI State:** Only needed by one component (e.g., toggle button, input value).
|
|
56
|
+
2. **Shared UI State:** Needed by multiple components, but not saved to DB (e.g., dark mode, cart items, selected filters).
|
|
57
|
+
3. **Server State:** Data fetched from an API. Needs caching, refetching, and loading states.
|
|
58
|
+
4. **URL State:** Data that should be shareable or survive refresh (e.g., search query `?q=shoes`, current page).
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
### Phase 2 — Strategy Selection
|
|
63
|
+
|
|
64
|
+
Based on the classification and project stack (`project-audit`), choose the tool:
|
|
65
|
+
|
|
66
|
+
| State Type | Recommended Tool |
|
|
67
|
+
|------------|------------------|
|
|
68
|
+
| Local UI | `useState`, `useReducer` |
|
|
69
|
+
| Shared UI | Zustand, Pinia, Redux, Context API |
|
|
70
|
+
| Server | React Query, RTK Query, Apollo, SWR |
|
|
71
|
+
| URL | React Router `useSearchParams`, Next.js `useRouter` |
|
|
72
|
+
|
|
73
|
+
**Rule:** Always respect existing project conventions. If they use Redux for everything, use Redux.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
### Phase 3 — Implementation
|
|
78
|
+
|
|
79
|
+
Generate the required code.
|
|
80
|
+
|
|
81
|
+
**Example for Server State (React Query):**
|
|
82
|
+
- Create query key factory
|
|
83
|
+
- Create custom hook (`useUserList`)
|
|
84
|
+
- Handle `isLoading`, `isError`, and `data`
|
|
85
|
+
|
|
86
|
+
**Example for Global UI State (Zustand):**
|
|
87
|
+
- Create store file (`userStore.ts`)
|
|
88
|
+
- Define state interface and initial values
|
|
89
|
+
- Define update actions (mutations)
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### Phase 4 — Validation
|
|
94
|
+
|
|
95
|
+
- [ ] Does it update correctly without mutating state directly?
|
|
96
|
+
- [ ] Are unnecessary re-renders avoided?
|
|
97
|
+
- [ ] Is server state properly cached and invalidated after mutations?
|
|
98
|
+
- [ ] Is it placed in the correct directory (e.g., `src/store/` or `src/hooks/`)?
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Decision Tree
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
Is the data fetched from a backend API?
|
|
106
|
+
├── Yes → Use Server State (React Query / SWR / RTK Query)
|
|
107
|
+
└── No → Is the data only needed in one component and its direct children?
|
|
108
|
+
├── Yes → Use Local State (`useState`)
|
|
109
|
+
└── No → Is the data used across many distinct branches of the app?
|
|
110
|
+
├── Yes → Use Global State (Zustand / Redux)
|
|
111
|
+
└── No → Use Context API or lift state up
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Output Format
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
🧠 State Management Plan
|
|
120
|
+
─────────────────────────────────────────────────
|
|
121
|
+
State Type: [Server / Global UI / Local / URL]
|
|
122
|
+
Tool Used: [React Query / Zustand / useState / etc.]
|
|
123
|
+
|
|
124
|
+
Implementation:
|
|
125
|
+
✅ [File 1] — [Store / Hook definition]
|
|
126
|
+
✅ [File 2] — [Component integration]
|
|
127
|
+
|
|
128
|
+
⚠️ Considerations:
|
|
129
|
+
• [Note on caching, stale time, or performance]
|
|
130
|
+
|
|
131
|
+
🔗 Next Steps:
|
|
132
|
+
State is ready. Use the hook in your component.
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Examples
|
|
138
|
+
|
|
139
|
+
See `examples/` folder.
|
|
140
|
+
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: qk-table-crud-generator
|
|
3
|
+
description: >-
|
|
4
|
+
Tạo các bảng dữ liệu admin với đầy đủ tính năng phân trang, sắp xếp, lọc và thao tác thêm/sửa/xóa (CRUD).
|
|
5
|
+
version: 1.0.0
|
|
6
|
+
category: frontend
|
|
7
|
+
tags: [table, data-grid, crud, admin, pagination, sorting]
|
|
8
|
+
platforms: [antigravity, claude-code, kilo-code, cursor, windsurf]
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Table & CRUD Generator
|
|
12
|
+
|
|
13
|
+
> **Language rule:**
|
|
14
|
+
> Use English for: code, identifiers, file names, architecture terms, technical decisions.
|
|
15
|
+
> Use the user's language for: explanations, questions, summaries, and feedback.
|
|
16
|
+
> The user may write in any language — detect and match it automatically.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Trigger
|
|
21
|
+
|
|
22
|
+
Activate this skill when:
|
|
23
|
+
- User says "create an admin table", "build a user list", "add data grid"
|
|
24
|
+
- User needs a view to manage a list of entities with CRUD capabilities
|
|
25
|
+
- A feature requires complex data presentation (sorting, filtering, pagination)
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Scope
|
|
30
|
+
|
|
31
|
+
- ✅ Generate a data table using design system components or libraries (e.g., TanStack Table)
|
|
32
|
+
- ✅ Implement client-side or server-side pagination, sorting, and filtering
|
|
33
|
+
- ✅ Add UI actions for Create, Edit, and Delete (modals or routing)
|
|
34
|
+
- ✅ Integrate with `api-integration` hooks for data fetching and mutations
|
|
35
|
+
- ✅ Handle loading, error, and empty states gracefully
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Non-goals
|
|
40
|
+
|
|
41
|
+
- ❌ Do NOT build the backend API for the CRUD operations (assume they exist or delegate)
|
|
42
|
+
- ❌ Do NOT use raw `<table>` tags if a powerful data-grid library is already installed
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Workflow
|
|
47
|
+
|
|
48
|
+
### Phase 1 — Data Model & Requirements
|
|
49
|
+
|
|
50
|
+
1. Understand the entity (e.g., `User`, `Product`).
|
|
51
|
+
2. Identify columns to display.
|
|
52
|
+
3. Determine operations needed (e.g., just Read/Delete, or full CRUD).
|
|
53
|
+
4. Decide on Pagination strategy: Server-side (URL params) or Client-side (in-memory).
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
### Phase 2 — Table Component Setup
|
|
58
|
+
|
|
59
|
+
1. Check for table libraries (e.g., `@tanstack/react-table`, MUI DataGrid, AntD Table).
|
|
60
|
+
2. Define column definitions (headers, accessor keys, cell formatters).
|
|
61
|
+
3. Set up the table UI wrapper.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
### Phase 3 — Data Integration
|
|
66
|
+
|
|
67
|
+
Connect to the state/API layer (e.g., React Query).
|
|
68
|
+
- `useQuery` for fetching the list. Pass pagination/sorting state.
|
|
69
|
+
- Handle `isLoading` → show skeleton or spinner.
|
|
70
|
+
- Handle empty data → show empty state component.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
### Phase 4 — CRUD Actions
|
|
75
|
+
|
|
76
|
+
Implement actions (usually in an "Actions" column or toolbar):
|
|
77
|
+
- **Create:** Button opening a Modal (delegate to `form-builder`) or routing to `/new`.
|
|
78
|
+
- **Edit:** Button opening an Edit Modal or routing to `/edit/:id`.
|
|
79
|
+
- **Delete:** Button opening a confirmation dialog, calling delete mutation on confirm.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Decision Tree
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
Is the dataset large (requires backend pagination)?
|
|
87
|
+
├── Yes → Implement Server-side pagination (sync state with URL search params)
|
|
88
|
+
└── No → Implement Client-side pagination (fetch all once, slice in UI)
|
|
89
|
+
|
|
90
|
+
Does the project use TanStack Table (React Table)?
|
|
91
|
+
├── Yes → Use `useReactTable` to manage table state and column definitions
|
|
92
|
+
└── No → Use the project's specific UI library table component
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Output Format
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
📊 Table & CRUD Generated
|
|
101
|
+
─────────────────────────────────────────────────
|
|
102
|
+
Entity: [Entity Name]
|
|
103
|
+
Features: [Pagination (Server), Sorting, CRUD actions]
|
|
104
|
+
|
|
105
|
+
Components Created:
|
|
106
|
+
✅ [Entity]Table.tsx
|
|
107
|
+
✅ [Entity]Columns.tsx
|
|
108
|
+
✅ DeleteConfirmModal.tsx
|
|
109
|
+
|
|
110
|
+
Integration:
|
|
111
|
+
- Fetching: Linked to `use[Entity]List` hook
|
|
112
|
+
- Mutations: Linked to Create/Update/Delete hooks
|
|
113
|
+
|
|
114
|
+
🔗 Next Steps:
|
|
115
|
+
If Create/Edit forms are needed, delegate to `form-builder`.
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Validation Checklist
|
|
121
|
+
|
|
122
|
+
- [ ] Columns are defined correctly
|
|
123
|
+
- [ ] Loading and empty states are handled
|
|
124
|
+
- [ ] Pagination/sorting state is managed properly
|
|
125
|
+
- [ ] CRUD actions trigger the correct mutations or navigations
|
|
126
|
+
- [ ] Delete actions have a confirmation step
|
|
127
|
+
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: qk-ui-builder
|
|
3
|
+
description: >-
|
|
4
|
+
Xây dựng các màn hình và layout phức tạp từ yêu cầu, tái sử dụng component và đảm bảo responsive.
|
|
5
|
+
version: 1.0.0
|
|
6
|
+
category: frontend
|
|
7
|
+
tags: [ui, layout, screens, pages, styling, responsive]
|
|
8
|
+
platforms: [antigravity, claude-code, kilo-code, cursor, windsurf]
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# UI Builder
|
|
12
|
+
|
|
13
|
+
> **Language rule:**
|
|
14
|
+
> Use English for: code, identifiers, file names, architecture terms, technical decisions.
|
|
15
|
+
> Use the user's language for: explanations, questions, summaries, and feedback.
|
|
16
|
+
> The user may write in any language — detect and match it automatically.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Trigger
|
|
21
|
+
|
|
22
|
+
Activate this skill when:
|
|
23
|
+
- User wants to create a new page, screen, or view
|
|
24
|
+
- User provides a mockup, wireframe, or visual description
|
|
25
|
+
- User asks to "build a layout", "create a dashboard", "make the profile page"
|
|
26
|
+
- Refactoring a large, messy view into a structured layout
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Scope
|
|
31
|
+
|
|
32
|
+
- ✅ Translate requirements into a component hierarchy
|
|
33
|
+
- ✅ Build layouts using Grid, Flexbox, and project styling conventions
|
|
34
|
+
- ✅ Ensure responsive design (mobile-first or desktop-first based on project)
|
|
35
|
+
- ✅ Integrate existing shared components (Buttons, Cards, Inputs) via `design-system` rules
|
|
36
|
+
- ✅ Define placeholders for data and logic (to be filled by `api-integration` or `state-management`)
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Non-goals
|
|
41
|
+
|
|
42
|
+
- ❌ Do NOT build backend APIs
|
|
43
|
+
- ❌ Do NOT implement complex global state (delegate to `state-management`)
|
|
44
|
+
- ❌ Do NOT invent new core UI components if they already exist in the design system
|
|
45
|
+
- ❌ Do NOT write raw HTML (`<button>`) if a shared component (`<Button>`) exists
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Workflow
|
|
50
|
+
|
|
51
|
+
### Phase 1 — Requirement Analysis
|
|
52
|
+
|
|
53
|
+
1. Understand the goal: What screen are we building?
|
|
54
|
+
2. Identify major sections: Header, Sidebar, Main Content, Footer, Modals.
|
|
55
|
+
3. Identify data requirements: What data will populate this view? (Use mock data initially).
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
### Phase 2 — Component Hierarchy Planning
|
|
60
|
+
|
|
61
|
+
Break the screen down into smaller components.
|
|
62
|
+
**Rule of thumb:** If a section has complex logic or is reusable, it should be a separate component.
|
|
63
|
+
|
|
64
|
+
*Example:*
|
|
65
|
+
```text
|
|
66
|
+
UserProfilePage
|
|
67
|
+
├── ProfileHeader
|
|
68
|
+
│ ├── Avatar
|
|
69
|
+
│ └── UserStats
|
|
70
|
+
├── UserSettingsForm (delegate to form-builder)
|
|
71
|
+
└── UserActivityList
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
### Phase 3 — Design System Integration
|
|
77
|
+
|
|
78
|
+
*(Relies on output from `design-system` skill)*
|
|
79
|
+
Identify which existing components will be used for each part of the hierarchy.
|
|
80
|
+
|
|
81
|
+
- Buttons → `<Button>`
|
|
82
|
+
- Layouts → `<Container>`, `<Grid>`
|
|
83
|
+
- Typography → `<Typography variant="h2">` or Tailwind text classes
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
### Phase 4 — Implementation
|
|
88
|
+
|
|
89
|
+
Write the code.
|
|
90
|
+
1. Build the layout skeleton first (Flexbox/Grid).
|
|
91
|
+
2. Add static/mock data to visualize the structure.
|
|
92
|
+
3. Apply styling for layout, spacing, and typography.
|
|
93
|
+
4. Ensure responsive behavior (e.g., stack columns on mobile).
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
### Phase 5 — Validation
|
|
98
|
+
|
|
99
|
+
- [ ] Does it match the requirements?
|
|
100
|
+
- [ ] Is it responsive?
|
|
101
|
+
- [ ] Does it strictly use the design system?
|
|
102
|
+
- [ ] Is the code clean and well-structured (not one giant file)?
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Decision Tree
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
Is a section of the UI highly complex or forms a distinct logical unit?
|
|
110
|
+
├── Yes → Extract it into its own component file (e.g., `ProfileHeader.tsx`)
|
|
111
|
+
└── No → Keep it inline in the main layout file for now
|
|
112
|
+
|
|
113
|
+
Does a required base component (e.g., DatePicker) exist in the project?
|
|
114
|
+
├── Yes → Import and use it
|
|
115
|
+
└── No → Use a standard HTML fallback or instruct `component-generator` to build it later
|
|
116
|
+
|
|
117
|
+
Is the UI data-heavy (like a complex form or table)?
|
|
118
|
+
├── Yes → Delegate specific sections to `form-builder` or `table-crud-generator`
|
|
119
|
+
└── No → Build it fully within `ui-builder`
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Output Format
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
🎨 UI Builder Summary
|
|
128
|
+
─────────────────────────────────────────────────
|
|
129
|
+
Screen: [Name of the screen/view built]
|
|
130
|
+
|
|
131
|
+
Component Hierarchy:
|
|
132
|
+
[Tree showing parent and child components]
|
|
133
|
+
|
|
134
|
+
📁 Files Created/Modified:
|
|
135
|
+
✅ [path/to/Page.tsx]
|
|
136
|
+
✅ [path/to/SubComponent.tsx]
|
|
137
|
+
|
|
138
|
+
🛠️ Implementation Details:
|
|
139
|
+
- Responsive: [Yes - describe breakpoints used]
|
|
140
|
+
- Mock Data: [Added placeholders for API integration]
|
|
141
|
+
|
|
142
|
+
🔗 Next Steps:
|
|
143
|
+
→ Need to wire up API? Route to `api-integration`.
|
|
144
|
+
→ Need complex state? Route to `state-management`.
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Examples
|
|
150
|
+
|
|
151
|
+
See `examples/` folder.
|
|
152
|
+
|