ai-developer-skill-os 1.0.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/CHANGELOG.md +31 -0
- package/LICENSE +21 -0
- package/README.md +142 -0
- package/_template/SKILL.md +154 -0
- package/_template/examples/example-en.md +49 -0
- package/_template/examples/example-vi.md +49 -0
- package/bin/install.js +56 -0
- package/docs/CHI_TIET_SKILLS.md +117 -0
- package/docs/HUONG_DAN_SU_DUNG.md +102 -0
- package/package.json +34 -0
- package/skills/backend/auth-security/SKILL.md +94 -0
- package/skills/backend/backend-architecture/SKILL.md +123 -0
- package/skills/backend/database-engineer/SKILL.md +102 -0
- package/skills/backend/deployment/SKILL.md +94 -0
- package/skills/engineering/agent-orchestrator/SKILL.md +177 -0
- package/skills/engineering/api-integration/SKILL.md +378 -0
- package/skills/engineering/bug-fix/SKILL.md +211 -0
- package/skills/engineering/context-manager/SKILL.md +174 -0
- package/skills/engineering/git-engineer/SKILL.md +302 -0
- package/skills/engineering/migration/SKILL.md +282 -0
- package/skills/engineering/project-audit/SKILL.md +278 -0
- package/skills/engineering/refactor/SKILL.md +220 -0
- package/skills/frontend/accessibility-audit/SKILL.md +119 -0
- package/skills/frontend/component-generator/SKILL.md +134 -0
- package/skills/frontend/design-system/SKILL.md +135 -0
- package/skills/frontend/form-builder/SKILL.md +138 -0
- package/skills/frontend/frontend-architecture/SKILL.md +153 -0
- package/skills/frontend/frontend-debug/SKILL.md +131 -0
- package/skills/frontend/frontend-performance/SKILL.md +127 -0
- package/skills/frontend/frontend-testing/SKILL.md +144 -0
- package/skills/frontend/state-management/SKILL.md +138 -0
- package/skills/frontend/table-crud-generator/SKILL.md +125 -0
- package/skills/frontend/ui-builder/SKILL.md +150 -0
- package/skills.json +667 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: 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, pattern names, file paths, technical terms.
|
|
15
|
+
> Use **the user's language** for: explanations, questions, and summaries.
|
|
16
|
+
|
|
17
|
+
> ⚠️ **Core constraint: Refactoring must NOT change observable behavior.**
|
|
18
|
+
> If behavior changes are needed → that is a feature, not a refactor.
|
|
19
|
+
> Stop and clarify with the user before proceeding.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Trigger
|
|
24
|
+
|
|
25
|
+
Activate this skill when:
|
|
26
|
+
- User says "clean up", "refactor", "it's too messy", "hard to maintain"
|
|
27
|
+
- Code has grown beyond its original design (God component, fat service, spaghetti logic)
|
|
28
|
+
- Duplicate patterns exist across multiple files
|
|
29
|
+
- `project-audit` identified architecture issues (P2/P3) ready to be addressed
|
|
30
|
+
- User asks to "improve code quality" without changing functionality
|
|
31
|
+
|
|
32
|
+
**Not this skill** → Use `bug-fix` if behavior is wrong. Use `migration` if upgrading dependencies.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Scope
|
|
37
|
+
|
|
38
|
+
- ✅ Rename for clarity (variables, functions, files, components)
|
|
39
|
+
- ✅ Extract reusable logic into functions, hooks, services, or utilities
|
|
40
|
+
- ✅ Remove dead code, unused imports, and orphaned files
|
|
41
|
+
- ✅ Split large components / functions into focused units
|
|
42
|
+
- ✅ Apply consistent patterns across the codebase
|
|
43
|
+
- ✅ Improve type coverage (replace `any`, add missing types)
|
|
44
|
+
- ✅ Reduce complexity (flatten nested conditions, simplify logic)
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Non-goals
|
|
49
|
+
|
|
50
|
+
- ❌ Do NOT change behavior — if you must, stop and discuss first
|
|
51
|
+
- ❌ Do NOT change public APIs or exported interfaces without explicit approval
|
|
52
|
+
- ❌ Do NOT rewrite everything — prefer incremental, targeted changes
|
|
53
|
+
- ❌ Do NOT apply opinionated style changes (formatting belongs to linter/prettier)
|
|
54
|
+
- ❌ Do NOT introduce new dependencies
|
|
55
|
+
- ❌ Do NOT refactor code unrelated to the stated scope
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Severity Levels (for issues found during analysis)
|
|
60
|
+
|
|
61
|
+
| Level | Meaning |
|
|
62
|
+
|-------|---------|
|
|
63
|
+
| P0 | Refactor introduces breaking change — stop immediately |
|
|
64
|
+
| P1 | High coupling or duplication blocking feature work |
|
|
65
|
+
| P2 | Code smell reducing maintainability |
|
|
66
|
+
| P3 | Minor naming or style inconsistency |
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Workflow
|
|
71
|
+
|
|
72
|
+
### Phase 1 — Understand Current State
|
|
73
|
+
|
|
74
|
+
Before changing anything:
|
|
75
|
+
1. Read the target code thoroughly
|
|
76
|
+
2. Identify what it does (behavior, inputs, outputs, side effects)
|
|
77
|
+
3. Note all callers and dependents of the code being refactored
|
|
78
|
+
4. Check for existing tests — these are the safety net
|
|
79
|
+
|
|
80
|
+
If there are **no tests** for the code being refactored → recommend writing characterization tests first, or proceed with extra caution and document risks.
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
### Phase 2 — Identify Refactor Targets
|
|
85
|
+
|
|
86
|
+
Common code smells to look for:
|
|
87
|
+
|
|
88
|
+
| Smell | Description |
|
|
89
|
+
|-------|-------------|
|
|
90
|
+
| God Component/Function | Does too many things — split by responsibility |
|
|
91
|
+
| Duplicate Logic | Same pattern repeated — extract to shared utility |
|
|
92
|
+
| Long Parameter Lists | >4 params — use options object |
|
|
93
|
+
| Deep Nesting | >3 levels of if/else — flatten with early returns |
|
|
94
|
+
| Magic Numbers/Strings | Unnamed constants — extract to named constants |
|
|
95
|
+
| Dead Code | Unused variables, functions, imports — remove |
|
|
96
|
+
| Inconsistent Naming | Mixed conventions — standardize |
|
|
97
|
+
| Missing Types | `any`, missing return types — add precise types |
|
|
98
|
+
| Large Files | >300 lines — consider splitting by concern |
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
### Phase 3 — Plan the Refactor
|
|
103
|
+
|
|
104
|
+
Create a step-by-step plan before touching code:
|
|
105
|
+
|
|
106
|
+
1. List each specific change with its justification
|
|
107
|
+
2. Order changes from lowest to highest risk
|
|
108
|
+
3. Identify what tests must pass after each step
|
|
109
|
+
4. Flag any changes that touch shared/exported code
|
|
110
|
+
|
|
111
|
+
Present plan to user if scope is large or changes are risky.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
### Phase 4 — Execute Incrementally
|
|
116
|
+
|
|
117
|
+
Apply changes in small, verifiable steps:
|
|
118
|
+
|
|
119
|
+
**Safe refactor order:**
|
|
120
|
+
1. Rename (lowest risk — IDEs can do this safely)
|
|
121
|
+
2. Extract (pull logic into new functions/hooks without changing callers)
|
|
122
|
+
3. Inline (remove unnecessary abstraction)
|
|
123
|
+
4. Move (relocate to correct file/folder)
|
|
124
|
+
5. Simplify (reduce complexity in logic)
|
|
125
|
+
6. Remove (delete dead code last — confirm nothing breaks)
|
|
126
|
+
|
|
127
|
+
After **each step** → verify tests still pass before moving on.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
### Phase 5 — Verify Behavior Preserved
|
|
132
|
+
|
|
133
|
+
- [ ] All existing tests pass
|
|
134
|
+
- [ ] Run lint and type-check — clean
|
|
135
|
+
- [ ] Manual smoke test of affected functionality
|
|
136
|
+
- [ ] No new `any` types introduced
|
|
137
|
+
- [ ] No unused imports or dead code left
|
|
138
|
+
- [ ] Public API unchanged (or explicitly approved to change)
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
### Phase 6 — Report
|
|
143
|
+
|
|
144
|
+
Document what changed and why:
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
What changed: [List of changes]
|
|
148
|
+
Why: [Specific smell or issue addressed]
|
|
149
|
+
Risk level: [Low / Medium / High]
|
|
150
|
+
Tests status: [All pass / N new tests added]
|
|
151
|
+
Behavior: [Unchanged — verified]
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Decision Tree
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
Is there existing test coverage?
|
|
160
|
+
├── Yes → Proceed — tests are the safety net
|
|
161
|
+
└── No → Recommend characterization tests first
|
|
162
|
+
├── User agrees → write tests then refactor
|
|
163
|
+
└── User wants to proceed anyway → proceed with caution, document risk
|
|
164
|
+
|
|
165
|
+
Does the refactor change public APIs?
|
|
166
|
+
├── Yes → Stop — confirm with user, this may be a breaking change
|
|
167
|
+
└── No → Proceed
|
|
168
|
+
|
|
169
|
+
Is the scope larger than expected?
|
|
170
|
+
├── Yes → Present updated plan, get approval before continuing
|
|
171
|
+
└── No → Continue
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Output Format
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
🔧 Refactor Summary
|
|
180
|
+
─────────────────────────────────────────────────
|
|
181
|
+
Scope: [What was refactored]
|
|
182
|
+
Changes: [N files modified, N extracted, N removed]
|
|
183
|
+
|
|
184
|
+
Changes applied:
|
|
185
|
+
✅ [Rename: oldName → newName in path/to/file.ts]
|
|
186
|
+
✅ [Extract: logic → useCustomHook in path/to/hook.ts]
|
|
187
|
+
✅ [Remove: dead code in path/to/old.ts]
|
|
188
|
+
✅ [Split: LargeComponent → ComponentA + ComponentB]
|
|
189
|
+
|
|
190
|
+
📊 Quality improvement:
|
|
191
|
+
Before: [brief description of the problem]
|
|
192
|
+
After: [brief description of improvement]
|
|
193
|
+
|
|
194
|
+
✅ Verification:
|
|
195
|
+
Tests: PASS (N tests)
|
|
196
|
+
Lint: Clean
|
|
197
|
+
Types: No new `any`
|
|
198
|
+
Behavior: Unchanged
|
|
199
|
+
|
|
200
|
+
⚠️ Notes:
|
|
201
|
+
[Any assumptions, risks, or follow-up suggestions]
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Validation Checklist
|
|
207
|
+
|
|
208
|
+
- [ ] Behavior is unchanged — verified with tests or manual check
|
|
209
|
+
- [ ] All tests pass
|
|
210
|
+
- [ ] Lint and type-check clean
|
|
211
|
+
- [ ] No dead code, unused imports, or console.logs left
|
|
212
|
+
- [ ] Public APIs unchanged (or explicitly approved)
|
|
213
|
+
- [ ] Changes are documented with justification
|
|
214
|
+
- [ ] No new dependencies introduced
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## Examples
|
|
219
|
+
|
|
220
|
+
See `examples/` folder.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: accessibility-audit
|
|
3
|
+
description: >-
|
|
4
|
+
Kiểm tra và sửa lỗi khả năng tiếp cận (a11y/WCAG). Đảm bảo hỗ trợ phím, screen reader và semantic HTML.
|
|
5
|
+
version: 1.0.0
|
|
6
|
+
category: frontend
|
|
7
|
+
tags: [accessibility, a11y, aria, wcag, screen-reader, keyboard]
|
|
8
|
+
platforms: [antigravity, claude-code, kilo-code, cursor, windsurf]
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Accessibility (A11y) Audit
|
|
12
|
+
|
|
13
|
+
> **Language rule:**
|
|
14
|
+
> Use **English** for: ARIA attributes, HTML tags, WCAG guidelines, technical terms.
|
|
15
|
+
> Use **the user's language** for: explanations, summaries, and questions.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Trigger
|
|
20
|
+
|
|
21
|
+
Activate this skill when:
|
|
22
|
+
- User asks to "make this accessible", "fix a11y", or "audit accessibility"
|
|
23
|
+
- Building complex interactive components (modals, dropdowns, tabs, sliders)
|
|
24
|
+
- Preparing an app for production or public release
|
|
25
|
+
- Project audit flags missing semantic HTML or ARIA issues
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Scope
|
|
30
|
+
|
|
31
|
+
- ✅ **Keyboard Navigation:** Ensure all interactive elements are reachable via `Tab`, and operable via `Enter`/`Space`/Arrows. Focus management (trapping focus in modals).
|
|
32
|
+
- ✅ **Screen Reader Support:** Add proper `aria-` attributes, `alt` text, and visually hidden text (`sr-only`).
|
|
33
|
+
- ✅ **Semantic HTML:** Replace `div` soups with `<nav>`, `<main>`, `<article>`, `<button>`, etc.
|
|
34
|
+
- ✅ **Color Contrast:** Verify text vs. background contrast meets WCAG AA (4.5:1 for normal text).
|
|
35
|
+
- ✅ **Form Labels:** Ensure all inputs have associated `<label>`s or `aria-label`s.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Non-goals
|
|
40
|
+
|
|
41
|
+
- ❌ Do NOT completely redesign the UI visually (unless fixing a severe contrast issue, and even then, ask first).
|
|
42
|
+
- ❌ Do NOT overuse ARIA. The first rule of ARIA is: "No ARIA is better than bad ARIA." Use semantic HTML first.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Workflow
|
|
47
|
+
|
|
48
|
+
### Phase 1 — Semantic HTML Check
|
|
49
|
+
|
|
50
|
+
Scan the component for basic HTML semantics:
|
|
51
|
+
- Are buttons actually `<button>` elements (not `<div onClick>`)?
|
|
52
|
+
- Are links actually `<a>` elements with `href`s?
|
|
53
|
+
- Do images have meaningful `alt` text (or `alt=""` if decorative)?
|
|
54
|
+
- Are headings (`h1`-`h6`) in a logical, unbroken hierarchy?
|
|
55
|
+
|
|
56
|
+
### Phase 2 — Keyboard & Focus Management
|
|
57
|
+
|
|
58
|
+
- Can the user tab through the component logically?
|
|
59
|
+
- Does every interactive element have a visible focus state (`:focus-visible`)?
|
|
60
|
+
- For Modals/Dialogs: Is focus trapped inside when open? Is focus restored when closed?
|
|
61
|
+
- For custom widgets (Tabs/Dropdowns): Implement correct arrow key navigation per WAI-ARIA authoring practices.
|
|
62
|
+
|
|
63
|
+
### Phase 3 — Screen Reader (ARIA) Check
|
|
64
|
+
|
|
65
|
+
- Do custom interactive elements have correct `role`s (e.g., `role="tablist"`)?
|
|
66
|
+
- Is dynamic state communicated? (`aria-expanded`, `aria-selected`, `aria-invalid`, `aria-busy`).
|
|
67
|
+
- Are icon-only buttons properly labeled? (`aria-label` or `<span className="sr-only">Label</span>`).
|
|
68
|
+
- Are dynamic live regions used for important announcements (`aria-live="polite"` or `assertive`)?
|
|
69
|
+
|
|
70
|
+
### Phase 4 — Contrast & Visuals
|
|
71
|
+
|
|
72
|
+
- Check text colors against backgrounds.
|
|
73
|
+
- Ensure form fields have visible borders or indicators.
|
|
74
|
+
- Ensure information is not conveyed *only* by color (e.g., a red border for an error must also have error text).
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Decision Tree
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
Is the component a native HTML element (e.g., standard `<button>`)?
|
|
82
|
+
├── Yes → Ensure it has accessible text/labels. No ARIA roles needed.
|
|
83
|
+
└── No → (e.g., a custom `div` acting as a checkbox)
|
|
84
|
+
├── Can it be refactored to use native HTML?
|
|
85
|
+
│ ├── Yes → Refactor to native HTML `<input type="checkbox">`
|
|
86
|
+
│ └── No → Apply `role="checkbox"`, `tabIndex={0}`, `aria-checked`, and keyboard event handlers.
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Output Format
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
♿ Accessibility Audit Report
|
|
95
|
+
─────────────────────────────────────────────────
|
|
96
|
+
Component: [ComponentName]
|
|
97
|
+
|
|
98
|
+
Issues Found & Fixed:
|
|
99
|
+
✅ Semantic HTML: Replaced `<div onClick>` with `<button>`
|
|
100
|
+
✅ Screen Readers: Added `aria-label` to icon-only close button
|
|
101
|
+
✅ Keyboard: Added focus trap inside the Modal
|
|
102
|
+
✅ Forms: Associated `<label htmlFor="email">` with Input
|
|
103
|
+
|
|
104
|
+
⚠️ Remaining Warnings (Manual Check Required):
|
|
105
|
+
- Please verify color contrast of primary button in light mode (needs 4.5:1 ratio).
|
|
106
|
+
|
|
107
|
+
🔗 Next Steps:
|
|
108
|
+
Code updated. Recommend testing with a screen reader (VoiceOver/NVDA).
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Validation Checklist
|
|
114
|
+
|
|
115
|
+
- [ ] Semantic HTML preferred over ARIA
|
|
116
|
+
- [ ] Keyboard navigation (Tab + Enter/Space) works correctly
|
|
117
|
+
- [ ] Focus is visible on all interactive elements
|
|
118
|
+
- [ ] Forms have proper labels
|
|
119
|
+
- [ ] Icon-only buttons have accessible names
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: component-generator
|
|
3
|
+
description: >-
|
|
4
|
+
Tạo các UI Component độc lập, tái sử dụng được, có type an toàn và tuân thủ chuẩn design system.
|
|
5
|
+
version: 1.0.0
|
|
6
|
+
category: frontend
|
|
7
|
+
tags: [component, react, vue, ui, props, reusable]
|
|
8
|
+
platforms: [antigravity, claude-code, kilo-code, cursor, windsurf]
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Component Generator
|
|
12
|
+
|
|
13
|
+
> **Language rule:**
|
|
14
|
+
> Use **English** for: code, component names, prop types, technical terminology.
|
|
15
|
+
> Use **the user's language** for: explanations, summaries, and questions.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Trigger
|
|
20
|
+
|
|
21
|
+
Activate this skill when:
|
|
22
|
+
- User says "create a Card component", "make a reusable Button", "extract this into a component"
|
|
23
|
+
- A larger skill (`ui-builder`, `form-builder`) requires a new isolated UI piece to be built
|
|
24
|
+
- Refactoring a large component by splitting it into smaller, reusable parts
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Scope
|
|
29
|
+
|
|
30
|
+
- ✅ Generate a single, focused component (e.g., `UserCard`, `StatBadge`, `Dropdown`)
|
|
31
|
+
- ✅ Define strict, explicit types/interfaces for all props
|
|
32
|
+
- ✅ Implement component variants (e.g., `size`, `color`, `variant`) if needed
|
|
33
|
+
- ✅ Follow project styling rules (Tailwind, CSS Modules, Styled Components)
|
|
34
|
+
- ✅ Ensure accessibility (ARIA attributes, semantic HTML) where applicable
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Non-goals
|
|
39
|
+
|
|
40
|
+
- ❌ Do NOT build full pages or complex screens (delegate to `ui-builder`)
|
|
41
|
+
- ❌ Do NOT handle complex business logic or data fetching inside a dumb/presentational component
|
|
42
|
+
- ❌ Do NOT overwrite existing components without explicit instruction
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Workflow
|
|
47
|
+
|
|
48
|
+
### Phase 1 — Component Design
|
|
49
|
+
|
|
50
|
+
Determine:
|
|
51
|
+
1. **Name:** PascalCase (e.g., `ProductCard`).
|
|
52
|
+
2. **Responsibility:** What exactly does this component do? Keep it single-responsibility.
|
|
53
|
+
3. **Props:** What data does it need from its parent? What events does it emit?
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
### Phase 2 — API (Props) Definition
|
|
58
|
+
|
|
59
|
+
Draft the interface first.
|
|
60
|
+
- Make required props explicit.
|
|
61
|
+
- Use optional props (`?`) for variants or non-essential data.
|
|
62
|
+
- Avoid `any`.
|
|
63
|
+
|
|
64
|
+
*Example:*
|
|
65
|
+
```typescript
|
|
66
|
+
interface ProductCardProps {
|
|
67
|
+
id: string;
|
|
68
|
+
title: string;
|
|
69
|
+
price: number;
|
|
70
|
+
imageUrl?: string;
|
|
71
|
+
isAvailable?: boolean;
|
|
72
|
+
onAddToCart: (id: string) => void;
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
### Phase 3 — Implementation
|
|
79
|
+
|
|
80
|
+
Write the component code.
|
|
81
|
+
1. Use destructuring for props.
|
|
82
|
+
2. Apply styling based on `design-system` rules.
|
|
83
|
+
3. Handle empty/null states (e.g., if `imageUrl` is missing, show a placeholder).
|
|
84
|
+
4. Add basic interactivity (e.g., calling `onAddToCart` when clicked).
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
### Phase 4 — Validation
|
|
89
|
+
|
|
90
|
+
- [ ] Are all props typed correctly?
|
|
91
|
+
- [ ] Is it truly reusable (no hardcoded data)?
|
|
92
|
+
- [ ] Does it use project design tokens?
|
|
93
|
+
- [ ] Is it exported correctly according to project conventions (default vs. named export)?
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Decision Tree
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
Does the component need to manage its own state (e.g., an accordion opening/closing)?
|
|
101
|
+
├── Yes → Add local state (`useState`). Keep it minimal.
|
|
102
|
+
└── No → Make it a pure "dumb" component receiving props.
|
|
103
|
+
|
|
104
|
+
Are there multiple visual styles requested (e.g., primary, secondary, outline)?
|
|
105
|
+
├── Yes → Add a `variant` prop and map it to style classes.
|
|
106
|
+
└── No → Implement the single required style.
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Output Format
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
🧩 Component Generated
|
|
115
|
+
─────────────────────────────────────────────────
|
|
116
|
+
Name: [ComponentName]
|
|
117
|
+
Path: [path/to/Component.tsx]
|
|
118
|
+
|
|
119
|
+
Props Interface:
|
|
120
|
+
[List key props here briefly]
|
|
121
|
+
|
|
122
|
+
Features:
|
|
123
|
+
• [Feature 1, e.g., "Supports primary/secondary variants"]
|
|
124
|
+
• [Feature 2, e.g., "Fully typed with TypeScript"]
|
|
125
|
+
|
|
126
|
+
🔗 Next Steps:
|
|
127
|
+
Component is ready to be imported into your layout.
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Examples
|
|
133
|
+
|
|
134
|
+
See `examples/` folder.
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: design-system
|
|
3
|
+
description: >-
|
|
4
|
+
Ép buộc sử dụng design system, component library và token hiện có, ngăn chặn việc viết HTML/CSS rác.
|
|
5
|
+
version: 1.0.0
|
|
6
|
+
category: frontend
|
|
7
|
+
tags: [design-system, ui-components, styling, tailwind, material-ui, shadcn]
|
|
8
|
+
platforms: [antigravity, claude-code, kilo-code, cursor, windsurf]
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Design System Enforcer
|
|
12
|
+
|
|
13
|
+
> **Language rule:**
|
|
14
|
+
> Use **English** for: component names, CSS classes, design tokens, technical terms.
|
|
15
|
+
> Use **the user's language** for: explanations, summaries, and questions.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Trigger
|
|
20
|
+
|
|
21
|
+
Activate this skill when:
|
|
22
|
+
- About to build UI screens or components
|
|
23
|
+
- Styling or layout work is required
|
|
24
|
+
- User asks to "make it look good" or "match the design"
|
|
25
|
+
- Integrating a third-party UI library (Tailwind, MUI, AntD, Shadcn)
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Scope
|
|
30
|
+
|
|
31
|
+
- ✅ Identify the UI library or design system in use
|
|
32
|
+
- ✅ Map standard HTML elements to project-specific components (e.g., `<button>` → `<Button>`)
|
|
33
|
+
- ✅ Enforce usage of design tokens (colors, spacing, typography) instead of hardcoded values
|
|
34
|
+
- ✅ Provide available component variants and props to downstream skills (`ui-builder`)
|
|
35
|
+
- ✅ Prevent generation of raw CSS/inline styles if utility classes or styled-components are standard
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Non-goals
|
|
40
|
+
|
|
41
|
+
- ❌ Do NOT create new base components if an equivalent already exists
|
|
42
|
+
- ❌ Do NOT introduce a new styling method (e.g., don't add Tailwind if project uses CSS Modules)
|
|
43
|
+
- ❌ Do NOT design full pages (delegate to `ui-builder`)
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Workflow
|
|
48
|
+
|
|
49
|
+
### Phase 1 — Detect Design System
|
|
50
|
+
|
|
51
|
+
Analyze dependencies and project files to identify:
|
|
52
|
+
1. **Component Library:** Shadcn UI, MUI, Ant Design, Chakra, Bootstrap, custom internal library?
|
|
53
|
+
2. **Styling Method:** Tailwind CSS, CSS Modules, Styled Components, Emotion, SCSS, Vanilla CSS?
|
|
54
|
+
3. **Location of Shared Components:** Usually `src/components/ui/`, `src/shared/components/`, or from an npm package.
|
|
55
|
+
4. **Design Tokens:** `tailwind.config.js`, `theme.ts`, `variables.scss`.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
### Phase 2 — Component Mapping
|
|
60
|
+
|
|
61
|
+
Before `ui-builder` generates code, create a mapping table for required elements:
|
|
62
|
+
|
|
63
|
+
| Standard Element | Project Component | Source / Import Path |
|
|
64
|
+
|------------------|-------------------|----------------------|
|
|
65
|
+
| `<button>` | `<Button>` | `@/components/ui/button` |
|
|
66
|
+
| `<input type="text">` | `<Input>` | `@/components/ui/input` |
|
|
67
|
+
| `<div>` (Card) | `<Card>` | `@/components/ui/card` |
|
|
68
|
+
| `<h1>` | `<Typography variant="h1">` | `@mui/material` |
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
### Phase 3 — Token Extraction
|
|
73
|
+
|
|
74
|
+
Identify available tokens for spacing, colors, and typography to avoid hardcoding:
|
|
75
|
+
- *Instead of:* `margin-top: 16px; color: #3b82f6;`
|
|
76
|
+
- *Use:* `mt-4 text-blue-500` (Tailwind) or `theme.spacing(2)` (MUI) or `var(--primary-color)`.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
### Phase 4 — Rule Enforcement
|
|
81
|
+
|
|
82
|
+
Pass strict instructions to `ui-builder` or `component-generator`:
|
|
83
|
+
- "You MUST use `<Button>` instead of `<button>`."
|
|
84
|
+
- "You MUST use Tailwind classes for all styling. No inline `style={{}}` allowed."
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Decision Tree
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
Does the project use a component library (e.g., Shadcn, MUI)?
|
|
92
|
+
├── Yes → Is the required component available?
|
|
93
|
+
│ ├── Yes → Require its use
|
|
94
|
+
│ └── No → Instruct `component-generator` to create it following library style
|
|
95
|
+
└── No → Check if custom shared components exist
|
|
96
|
+
├── Yes → Map to custom shared components
|
|
97
|
+
└── No → Use raw HTML but enforce project's styling method (e.g., Tailwind)
|
|
98
|
+
|
|
99
|
+
Does the project use utility classes (Tailwind)?
|
|
100
|
+
├── Yes → Forbid inline styles or custom CSS files
|
|
101
|
+
└── No → Enforce existing CSS Modules / Styled Components patterns
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Output Format
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
🎨 Design System Rules
|
|
110
|
+
─────────────────────────────────────────────────
|
|
111
|
+
Library: [Shadcn / MUI / Tailwind / Custom / etc.]
|
|
112
|
+
Styling Method: [Tailwind / CSS Modules / Styled Components]
|
|
113
|
+
|
|
114
|
+
Component Mapping for this task:
|
|
115
|
+
✅ Button → `<Button>` from `@/components/ui/button`
|
|
116
|
+
✅ Input → `<Input>` from `@/components/ui/input`
|
|
117
|
+
✅ Layout → Flexbox with Tailwind (`flex flex-col gap-4`)
|
|
118
|
+
|
|
119
|
+
Styling Rules Enforced:
|
|
120
|
+
• No raw HTML `<button>` allowed
|
|
121
|
+
• No inline styles allowed
|
|
122
|
+
• Use primary color token for CTAs
|
|
123
|
+
|
|
124
|
+
🔗 Next Steps:
|
|
125
|
+
Passing these rules to `ui-builder` to generate the UI.
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Validation Checklist
|
|
131
|
+
|
|
132
|
+
- [ ] Design system and styling method correctly identified
|
|
133
|
+
- [ ] Mappings created for all necessary UI elements
|
|
134
|
+
- [ ] Design tokens (spacing/colors) prioritized over hardcoded values
|
|
135
|
+
- [ ] Strict enforcement rules passed to next skill
|