cp-toolkit 2.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/README.md +130 -0
- package/bin/cp-kit.js +72 -0
- package/package.json +46 -0
- package/src/commands/add.js +212 -0
- package/src/commands/doctor.js +149 -0
- package/src/commands/init.js +662 -0
- package/src/commands/list.js +128 -0
- package/src/index.js +13 -0
- package/templates/agents/backend-specialist.md +263 -0
- package/templates/agents/code-archaeologist.md +106 -0
- package/templates/agents/database-architect.md +226 -0
- package/templates/agents/debugger.md +225 -0
- package/templates/agents/devops-engineer.md +242 -0
- package/templates/agents/documentation-writer.md +104 -0
- package/templates/agents/explorer-agent.md +73 -0
- package/templates/agents/frontend-specialist.md +556 -0
- package/templates/agents/game-developer.md +162 -0
- package/templates/agents/mobile-developer.md +377 -0
- package/templates/agents/orchestrator.md +416 -0
- package/templates/agents/penetration-tester.md +188 -0
- package/templates/agents/performance-optimizer.md +187 -0
- package/templates/agents/product-manager.md +112 -0
- package/templates/agents/product-owner.md +95 -0
- package/templates/agents/project-planner.md +406 -0
- package/templates/agents/qa-automation-engineer.md +103 -0
- package/templates/agents/security-auditor.md +170 -0
- package/templates/agents/seo-specialist.md +111 -0
- package/templates/agents/test-engineer.md +158 -0
- package/templates/github/agents/backend-specialist.md +67 -0
- package/templates/github/agents/code-archaeologist.md +61 -0
- package/templates/github/agents/database-architect.md +73 -0
- package/templates/github/agents/debugger.md +71 -0
- package/templates/github/agents/devops-engineer.md +85 -0
- package/templates/github/agents/documentation-writer.md +107 -0
- package/templates/github/agents/explorer-agent.md +87 -0
- package/templates/github/agents/frontend-specialist.md +54 -0
- package/templates/github/agents/game-developer.md +94 -0
- package/templates/github/agents/mobile-developer.md +75 -0
- package/templates/github/agents/orchestrator.md +48 -0
- package/templates/github/agents/penetration-tester.md +87 -0
- package/templates/github/agents/performance-optimizer.md +70 -0
- package/templates/github/agents/product-manager.md +85 -0
- package/templates/github/agents/product-owner.md +77 -0
- package/templates/github/agents/project-planner.md +83 -0
- package/templates/github/agents/qa-automation-engineer.md +95 -0
- package/templates/github/agents/security-auditor.md +72 -0
- package/templates/github/agents/seo-specialist.md +78 -0
- package/templates/github/agents/test-engineer.md +79 -0
- package/templates/github/instructions/database.instructions.md +74 -0
- package/templates/github/instructions/python.instructions.md +76 -0
- package/templates/github/instructions/security.instructions.md +73 -0
- package/templates/github/instructions/typescript.instructions.md +50 -0
- package/templates/rules/GEMINI.md +273 -0
- package/templates/scripts/mcp-server.js +704 -0
- package/templates/skills/core/behavioral-modes/SKILL.md +242 -0
- package/templates/skills/core/brainstorming/SKILL.md +163 -0
- package/templates/skills/core/brainstorming/dynamic-questioning.md +350 -0
- package/templates/skills/core/clean-code/SKILL.md +201 -0
- package/templates/skills/core/intelligent-routing/SKILL.md +335 -0
- package/templates/skills/core/mcp-builder/SKILL.md +176 -0
- package/templates/skills/core/parallel-agents/SKILL.md +175 -0
- package/templates/skills/core/plan-writing/SKILL.md +152 -0
- package/templates/skills/optional/api-patterns/SKILL.md +81 -0
- package/templates/skills/optional/api-patterns/api-style.md +42 -0
- package/templates/skills/optional/api-patterns/auth.md +24 -0
- package/templates/skills/optional/api-patterns/documentation.md +26 -0
- package/templates/skills/optional/api-patterns/graphql.md +41 -0
- package/templates/skills/optional/api-patterns/rate-limiting.md +31 -0
- package/templates/skills/optional/api-patterns/response.md +37 -0
- package/templates/skills/optional/api-patterns/rest.md +40 -0
- package/templates/skills/optional/api-patterns/scripts/api_validator.py +211 -0
- package/templates/skills/optional/api-patterns/security-testing.md +122 -0
- package/templates/skills/optional/api-patterns/trpc.md +41 -0
- package/templates/skills/optional/api-patterns/versioning.md +22 -0
- package/templates/skills/optional/app-builder/SKILL.md +75 -0
- package/templates/skills/optional/app-builder/agent-coordination.md +71 -0
- package/templates/skills/optional/app-builder/feature-building.md +53 -0
- package/templates/skills/optional/app-builder/project-detection.md +34 -0
- package/templates/skills/optional/app-builder/scaffolding.md +118 -0
- package/templates/skills/optional/app-builder/tech-stack.md +40 -0
- package/templates/skills/optional/app-builder/templates/SKILL.md +39 -0
- package/templates/skills/optional/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/templates/skills/optional/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/templates/skills/optional/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/templates/skills/optional/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/templates/skills/optional/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/templates/skills/optional/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/templates/skills/optional/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/templates/skills/optional/app-builder/templates/nextjs-fullstack/TEMPLATE.md +82 -0
- package/templates/skills/optional/app-builder/templates/nextjs-saas/TEMPLATE.md +100 -0
- package/templates/skills/optional/app-builder/templates/nextjs-static/TEMPLATE.md +106 -0
- package/templates/skills/optional/app-builder/templates/nuxt-app/TEMPLATE.md +101 -0
- package/templates/skills/optional/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/templates/skills/optional/app-builder/templates/react-native-app/TEMPLATE.md +93 -0
- package/templates/skills/optional/architecture/SKILL.md +55 -0
- package/templates/skills/optional/architecture/context-discovery.md +43 -0
- package/templates/skills/optional/architecture/examples.md +94 -0
- package/templates/skills/optional/architecture/pattern-selection.md +68 -0
- package/templates/skills/optional/architecture/patterns-reference.md +50 -0
- package/templates/skills/optional/architecture/trade-off-analysis.md +77 -0
- package/templates/skills/optional/bash-linux/SKILL.md +199 -0
- package/templates/skills/optional/code-review-checklist/SKILL.md +109 -0
- package/templates/skills/optional/database-design/SKILL.md +52 -0
- package/templates/skills/optional/database-design/database-selection.md +43 -0
- package/templates/skills/optional/database-design/indexing.md +39 -0
- package/templates/skills/optional/database-design/migrations.md +48 -0
- package/templates/skills/optional/database-design/optimization.md +36 -0
- package/templates/skills/optional/database-design/orm-selection.md +30 -0
- package/templates/skills/optional/database-design/schema-design.md +56 -0
- package/templates/skills/optional/database-design/scripts/schema_validator.py +172 -0
- package/templates/skills/optional/deployment-procedures/SKILL.md +241 -0
- package/templates/skills/optional/documentation-templates/SKILL.md +194 -0
- package/templates/skills/optional/frontend-design/SKILL.md +418 -0
- package/templates/skills/optional/frontend-design/animation-guide.md +331 -0
- package/templates/skills/optional/frontend-design/color-system.md +311 -0
- package/templates/skills/optional/frontend-design/decision-trees.md +418 -0
- package/templates/skills/optional/frontend-design/motion-graphics.md +306 -0
- package/templates/skills/optional/frontend-design/scripts/accessibility_checker.py +183 -0
- package/templates/skills/optional/frontend-design/scripts/ux_audit.py +722 -0
- package/templates/skills/optional/frontend-design/typography-system.md +345 -0
- package/templates/skills/optional/frontend-design/ux-psychology.md +541 -0
- package/templates/skills/optional/frontend-design/visual-effects.md +383 -0
- package/templates/skills/optional/game-development/2d-games/SKILL.md +119 -0
- package/templates/skills/optional/game-development/3d-games/SKILL.md +135 -0
- package/templates/skills/optional/game-development/SKILL.md +167 -0
- package/templates/skills/optional/game-development/game-art/SKILL.md +185 -0
- package/templates/skills/optional/game-development/game-audio/SKILL.md +190 -0
- package/templates/skills/optional/game-development/game-design/SKILL.md +129 -0
- package/templates/skills/optional/game-development/mobile-games/SKILL.md +108 -0
- package/templates/skills/optional/game-development/multiplayer/SKILL.md +132 -0
- package/templates/skills/optional/game-development/pc-games/SKILL.md +144 -0
- package/templates/skills/optional/game-development/vr-ar/SKILL.md +123 -0
- package/templates/skills/optional/game-development/web-games/SKILL.md +150 -0
- package/templates/skills/optional/geo-fundamentals/SKILL.md +156 -0
- package/templates/skills/optional/geo-fundamentals/scripts/geo_checker.py +289 -0
- package/templates/skills/optional/i18n-localization/SKILL.md +154 -0
- package/templates/skills/optional/i18n-localization/scripts/i18n_checker.py +241 -0
- package/templates/skills/optional/lint-and-validate/SKILL.md +45 -0
- package/templates/skills/optional/lint-and-validate/scripts/lint_runner.py +172 -0
- package/templates/skills/optional/lint-and-validate/scripts/type_coverage.py +173 -0
- package/templates/skills/optional/mobile-design/SKILL.md +394 -0
- package/templates/skills/optional/mobile-design/decision-trees.md +516 -0
- package/templates/skills/optional/mobile-design/mobile-backend.md +491 -0
- package/templates/skills/optional/mobile-design/mobile-color-system.md +420 -0
- package/templates/skills/optional/mobile-design/mobile-debugging.md +122 -0
- package/templates/skills/optional/mobile-design/mobile-design-thinking.md +357 -0
- package/templates/skills/optional/mobile-design/mobile-navigation.md +458 -0
- package/templates/skills/optional/mobile-design/mobile-performance.md +767 -0
- package/templates/skills/optional/mobile-design/mobile-testing.md +356 -0
- package/templates/skills/optional/mobile-design/mobile-typography.md +433 -0
- package/templates/skills/optional/mobile-design/platform-android.md +666 -0
- package/templates/skills/optional/mobile-design/platform-ios.md +561 -0
- package/templates/skills/optional/mobile-design/scripts/mobile_audit.py +670 -0
- package/templates/skills/optional/mobile-design/touch-psychology.md +537 -0
- package/templates/skills/optional/nextjs-react-expert/1-async-eliminating-waterfalls.md +312 -0
- package/templates/skills/optional/nextjs-react-expert/2-bundle-bundle-size-optimization.md +240 -0
- package/templates/skills/optional/nextjs-react-expert/3-server-server-side-performance.md +490 -0
- package/templates/skills/optional/nextjs-react-expert/4-client-client-side-data-fetching.md +264 -0
- package/templates/skills/optional/nextjs-react-expert/5-rerender-re-render-optimization.md +581 -0
- package/templates/skills/optional/nextjs-react-expert/6-rendering-rendering-performance.md +432 -0
- package/templates/skills/optional/nextjs-react-expert/7-js-javascript-performance.md +684 -0
- package/templates/skills/optional/nextjs-react-expert/8-advanced-advanced-patterns.md +150 -0
- package/templates/skills/optional/nextjs-react-expert/SKILL.md +267 -0
- package/templates/skills/optional/nextjs-react-expert/scripts/convert_rules.py +222 -0
- package/templates/skills/optional/nextjs-react-expert/scripts/react_performance_checker.py +252 -0
- package/templates/skills/optional/nodejs-best-practices/SKILL.md +333 -0
- package/templates/skills/optional/performance-profiling/SKILL.md +143 -0
- package/templates/skills/optional/performance-profiling/scripts/lighthouse_audit.py +76 -0
- package/templates/skills/optional/powershell-windows/SKILL.md +167 -0
- package/templates/skills/optional/python-patterns/SKILL.md +441 -0
- package/templates/skills/optional/red-team-tactics/SKILL.md +199 -0
- package/templates/skills/optional/seo-fundamentals/SKILL.md +129 -0
- package/templates/skills/optional/seo-fundamentals/scripts/seo_checker.py +219 -0
- package/templates/skills/optional/server-management/SKILL.md +161 -0
- package/templates/skills/optional/systematic-debugging/SKILL.md +109 -0
- package/templates/skills/optional/tailwind-patterns/SKILL.md +269 -0
- package/templates/skills/optional/tdd-workflow/SKILL.md +149 -0
- package/templates/skills/optional/testing-patterns/SKILL.md +178 -0
- package/templates/skills/optional/testing-patterns/scripts/test_runner.py +219 -0
- package/templates/skills/optional/vulnerability-scanner/SKILL.md +276 -0
- package/templates/skills/optional/vulnerability-scanner/checklists.md +121 -0
- package/templates/skills/optional/vulnerability-scanner/scripts/security_scan.py +458 -0
- package/templates/skills/optional/web-design-guidelines/SKILL.md +57 -0
- package/templates/skills/optional/webapp-testing/SKILL.md +187 -0
- package/templates/skills/optional/webapp-testing/scripts/playwright_runner.py +173 -0
- package/templates/workflows/brainstorm.md +113 -0
- package/templates/workflows/create.md +59 -0
- package/templates/workflows/debug.md +103 -0
- package/templates/workflows/deploy.md +176 -0
- package/templates/workflows/enhance.md +63 -0
- package/templates/workflows/orchestrate.md +237 -0
- package/templates/workflows/plan.md +89 -0
- package/templates/workflows/preview.md +81 -0
- package/templates/workflows/status.md +86 -0
- package/templates/workflows/test.md +144 -0
- package/templates/workflows/ui-ux-pro-max.md +296 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tailwind-patterns
|
|
3
|
+
description: Tailwind CSS v4 principles. CSS-first configuration, container queries, modern patterns, design token architecture.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Glob, Grep
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Tailwind CSS Patterns (v4 - 2025)
|
|
8
|
+
|
|
9
|
+
> Modern utility-first CSS with CSS-native configuration.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 1. Tailwind v4 Architecture
|
|
14
|
+
|
|
15
|
+
### What Changed from v3
|
|
16
|
+
|
|
17
|
+
| v3 (Legacy) | v4 (Current) |
|
|
18
|
+
|-------------|--------------|
|
|
19
|
+
| `tailwind.config.js` | CSS-based `@theme` directive |
|
|
20
|
+
| PostCSS plugin | Oxide engine (10x faster) |
|
|
21
|
+
| JIT mode | Native, always-on |
|
|
22
|
+
| Plugin system | CSS-native features |
|
|
23
|
+
| `@apply` directive | Still works, discouraged |
|
|
24
|
+
|
|
25
|
+
### v4 Core Concepts
|
|
26
|
+
|
|
27
|
+
| Concept | Description |
|
|
28
|
+
|---------|-------------|
|
|
29
|
+
| **CSS-first** | Configuration in CSS, not JavaScript |
|
|
30
|
+
| **Oxide Engine** | Rust-based compiler, much faster |
|
|
31
|
+
| **Native Nesting** | CSS nesting without PostCSS |
|
|
32
|
+
| **CSS Variables** | All tokens exposed as `--*` vars |
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 2. CSS-Based Configuration
|
|
37
|
+
|
|
38
|
+
### Theme Definition
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
@theme {
|
|
42
|
+
/* Colors - use semantic names */
|
|
43
|
+
--color-primary: oklch(0.7 0.15 250);
|
|
44
|
+
--color-surface: oklch(0.98 0 0);
|
|
45
|
+
--color-surface-dark: oklch(0.15 0 0);
|
|
46
|
+
|
|
47
|
+
/* Spacing scale */
|
|
48
|
+
--spacing-xs: 0.25rem;
|
|
49
|
+
--spacing-sm: 0.5rem;
|
|
50
|
+
--spacing-md: 1rem;
|
|
51
|
+
--spacing-lg: 2rem;
|
|
52
|
+
|
|
53
|
+
/* Typography */
|
|
54
|
+
--font-sans: 'Inter', system-ui, sans-serif;
|
|
55
|
+
--font-mono: 'JetBrains Mono', monospace;
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### When to Extend vs Override
|
|
60
|
+
|
|
61
|
+
| Action | Use When |
|
|
62
|
+
|--------|----------|
|
|
63
|
+
| **Extend** | Adding new values alongside defaults |
|
|
64
|
+
| **Override** | Replacing default scale entirely |
|
|
65
|
+
| **Semantic tokens** | Project-specific naming (primary, surface) |
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## 3. Container Queries (v4 Native)
|
|
70
|
+
|
|
71
|
+
### Breakpoint vs Container
|
|
72
|
+
|
|
73
|
+
| Type | Responds To |
|
|
74
|
+
|------|-------------|
|
|
75
|
+
| **Breakpoint** (`md:`) | Viewport width |
|
|
76
|
+
| **Container** (`@container`) | Parent element width |
|
|
77
|
+
|
|
78
|
+
### Container Query Usage
|
|
79
|
+
|
|
80
|
+
| Pattern | Classes |
|
|
81
|
+
|---------|---------|
|
|
82
|
+
| Define container | `@container` on parent |
|
|
83
|
+
| Container breakpoint | `@sm:`, `@md:`, `@lg:` on children |
|
|
84
|
+
| Named containers | `@container/card` for specificity |
|
|
85
|
+
|
|
86
|
+
### When to Use
|
|
87
|
+
|
|
88
|
+
| Scenario | Use |
|
|
89
|
+
|----------|-----|
|
|
90
|
+
| Page-level layouts | Viewport breakpoints |
|
|
91
|
+
| Component-level responsive | Container queries |
|
|
92
|
+
| Reusable components | Container queries (context-independent) |
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## 4. Responsive Design
|
|
97
|
+
|
|
98
|
+
### Breakpoint System
|
|
99
|
+
|
|
100
|
+
| Prefix | Min Width | Target |
|
|
101
|
+
|--------|-----------|--------|
|
|
102
|
+
| (none) | 0px | Mobile-first base |
|
|
103
|
+
| `sm:` | 640px | Large phone / small tablet |
|
|
104
|
+
| `md:` | 768px | Tablet |
|
|
105
|
+
| `lg:` | 1024px | Laptop |
|
|
106
|
+
| `xl:` | 1280px | Desktop |
|
|
107
|
+
| `2xl:` | 1536px | Large desktop |
|
|
108
|
+
|
|
109
|
+
### Mobile-First Principle
|
|
110
|
+
|
|
111
|
+
1. Write mobile styles first (no prefix)
|
|
112
|
+
2. Add larger screen overrides with prefixes
|
|
113
|
+
3. Example: `w-full md:w-1/2 lg:w-1/3`
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## 5. Dark Mode
|
|
118
|
+
|
|
119
|
+
### Configuration Strategies
|
|
120
|
+
|
|
121
|
+
| Method | Behavior | Use When |
|
|
122
|
+
|--------|----------|----------|
|
|
123
|
+
| `class` | `.dark` class toggles | Manual theme switcher |
|
|
124
|
+
| `media` | Follows system preference | No user control |
|
|
125
|
+
| `selector` | Custom selector (v4) | Complex theming |
|
|
126
|
+
|
|
127
|
+
### Dark Mode Pattern
|
|
128
|
+
|
|
129
|
+
| Element | Light | Dark |
|
|
130
|
+
|---------|-------|------|
|
|
131
|
+
| Background | `bg-white` | `dark:bg-zinc-900` |
|
|
132
|
+
| Text | `text-zinc-900` | `dark:text-zinc-100` |
|
|
133
|
+
| Borders | `border-zinc-200` | `dark:border-zinc-700` |
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## 6. Modern Layout Patterns
|
|
138
|
+
|
|
139
|
+
### Flexbox Patterns
|
|
140
|
+
|
|
141
|
+
| Pattern | Classes |
|
|
142
|
+
|---------|---------|
|
|
143
|
+
| Center (both axes) | `flex items-center justify-center` |
|
|
144
|
+
| Vertical stack | `flex flex-col gap-4` |
|
|
145
|
+
| Horizontal row | `flex gap-4` |
|
|
146
|
+
| Space between | `flex justify-between items-center` |
|
|
147
|
+
| Wrap grid | `flex flex-wrap gap-4` |
|
|
148
|
+
|
|
149
|
+
### Grid Patterns
|
|
150
|
+
|
|
151
|
+
| Pattern | Classes |
|
|
152
|
+
|---------|---------|
|
|
153
|
+
| Auto-fit responsive | `grid grid-cols-[repeat(auto-fit,minmax(250px,1fr))]` |
|
|
154
|
+
| Asymmetric (Bento) | `grid grid-cols-3 grid-rows-2` with spans |
|
|
155
|
+
| Sidebar layout | `grid grid-cols-[auto_1fr]` |
|
|
156
|
+
|
|
157
|
+
> **Note:** Prefer asymmetric/Bento layouts over symmetric 3-column grids.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## 7. Modern Color System
|
|
162
|
+
|
|
163
|
+
### OKLCH vs RGB/HSL
|
|
164
|
+
|
|
165
|
+
| Format | Advantage |
|
|
166
|
+
|--------|-----------|
|
|
167
|
+
| **OKLCH** | Perceptually uniform, better for design |
|
|
168
|
+
| **HSL** | Intuitive hue/saturation |
|
|
169
|
+
| **RGB** | Legacy compatibility |
|
|
170
|
+
|
|
171
|
+
### Color Token Architecture
|
|
172
|
+
|
|
173
|
+
| Layer | Example | Purpose |
|
|
174
|
+
|-------|---------|---------|
|
|
175
|
+
| **Primitive** | `--blue-500` | Raw color values |
|
|
176
|
+
| **Semantic** | `--color-primary` | Purpose-based naming |
|
|
177
|
+
| **Component** | `--button-bg` | Component-specific |
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## 8. Typography System
|
|
182
|
+
|
|
183
|
+
### Font Stack Pattern
|
|
184
|
+
|
|
185
|
+
| Type | Recommended |
|
|
186
|
+
|------|-------------|
|
|
187
|
+
| Sans | `'Inter', 'SF Pro', system-ui, sans-serif` |
|
|
188
|
+
| Mono | `'JetBrains Mono', 'Fira Code', monospace` |
|
|
189
|
+
| Display | `'Outfit', 'Poppins', sans-serif` |
|
|
190
|
+
|
|
191
|
+
### Type Scale
|
|
192
|
+
|
|
193
|
+
| Class | Size | Use |
|
|
194
|
+
|-------|------|-----|
|
|
195
|
+
| `text-xs` | 0.75rem | Labels, captions |
|
|
196
|
+
| `text-sm` | 0.875rem | Secondary text |
|
|
197
|
+
| `text-base` | 1rem | Body text |
|
|
198
|
+
| `text-lg` | 1.125rem | Lead text |
|
|
199
|
+
| `text-xl`+ | 1.25rem+ | Headings |
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## 9. Animation & Transitions
|
|
204
|
+
|
|
205
|
+
### Built-in Animations
|
|
206
|
+
|
|
207
|
+
| Class | Effect |
|
|
208
|
+
|-------|--------|
|
|
209
|
+
| `animate-spin` | Continuous rotation |
|
|
210
|
+
| `animate-ping` | Attention pulse |
|
|
211
|
+
| `animate-pulse` | Subtle opacity pulse |
|
|
212
|
+
| `animate-bounce` | Bouncing effect |
|
|
213
|
+
|
|
214
|
+
### Transition Patterns
|
|
215
|
+
|
|
216
|
+
| Pattern | Classes |
|
|
217
|
+
|---------|---------|
|
|
218
|
+
| All properties | `transition-all duration-200` |
|
|
219
|
+
| Specific | `transition-colors duration-150` |
|
|
220
|
+
| With easing | `ease-out` or `ease-in-out` |
|
|
221
|
+
| Hover effect | `hover:scale-105 transition-transform` |
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## 10. Component Extraction
|
|
226
|
+
|
|
227
|
+
### When to Extract
|
|
228
|
+
|
|
229
|
+
| Signal | Action |
|
|
230
|
+
|--------|--------|
|
|
231
|
+
| Same class combo 3+ times | Extract component |
|
|
232
|
+
| Complex state variants | Extract component |
|
|
233
|
+
| Design system element | Extract + document |
|
|
234
|
+
|
|
235
|
+
### Extraction Methods
|
|
236
|
+
|
|
237
|
+
| Method | Use When |
|
|
238
|
+
|--------|----------|
|
|
239
|
+
| **React/Vue component** | Dynamic, JS needed |
|
|
240
|
+
| **@apply in CSS** | Static, no JS needed |
|
|
241
|
+
| **Design tokens** | Reusable values |
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## 11. Anti-Patterns
|
|
246
|
+
|
|
247
|
+
| Don't | Do |
|
|
248
|
+
|-------|-----|
|
|
249
|
+
| Arbitrary values everywhere | Use design system scale |
|
|
250
|
+
| `!important` | Fix specificity properly |
|
|
251
|
+
| Inline `style=` | Use utilities |
|
|
252
|
+
| Duplicate long class lists | Extract component |
|
|
253
|
+
| Mix v3 config with v4 | Migrate fully to CSS-first |
|
|
254
|
+
| Use `@apply` heavily | Prefer components |
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## 12. Performance Principles
|
|
259
|
+
|
|
260
|
+
| Principle | Implementation |
|
|
261
|
+
|-----------|----------------|
|
|
262
|
+
| **Purge unused** | Automatic in v4 |
|
|
263
|
+
| **Avoid dynamism** | No template string classes |
|
|
264
|
+
| **Use Oxide** | Default in v4, 10x faster |
|
|
265
|
+
| **Cache builds** | CI/CD caching |
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
> **Remember:** Tailwind v4 is CSS-first. Embrace CSS variables, container queries, and native features. The config file is now optional.
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tdd-workflow
|
|
3
|
+
description: Test-Driven Development workflow principles. RED-GREEN-REFACTOR cycle.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Glob, Grep, Bash
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# TDD Workflow
|
|
8
|
+
|
|
9
|
+
> Write tests first, code second.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 1. The TDD Cycle
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
🔴 RED → Write failing test
|
|
17
|
+
↓
|
|
18
|
+
🟢 GREEN → Write minimal code to pass
|
|
19
|
+
↓
|
|
20
|
+
🔵 REFACTOR → Improve code quality
|
|
21
|
+
↓
|
|
22
|
+
Repeat...
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 2. The Three Laws of TDD
|
|
28
|
+
|
|
29
|
+
1. Write production code only to make a failing test pass
|
|
30
|
+
2. Write only enough test to demonstrate failure
|
|
31
|
+
3. Write only enough code to make the test pass
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 3. RED Phase Principles
|
|
36
|
+
|
|
37
|
+
### What to Write
|
|
38
|
+
|
|
39
|
+
| Focus | Example |
|
|
40
|
+
|-------|---------|
|
|
41
|
+
| Behavior | "should add two numbers" |
|
|
42
|
+
| Edge cases | "should handle empty input" |
|
|
43
|
+
| Error states | "should throw for invalid data" |
|
|
44
|
+
|
|
45
|
+
### RED Phase Rules
|
|
46
|
+
|
|
47
|
+
- Test must fail first
|
|
48
|
+
- Test name describes expected behavior
|
|
49
|
+
- One assertion per test (ideally)
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 4. GREEN Phase Principles
|
|
54
|
+
|
|
55
|
+
### Minimum Code
|
|
56
|
+
|
|
57
|
+
| Principle | Meaning |
|
|
58
|
+
|-----------|---------|
|
|
59
|
+
| **YAGNI** | You Aren't Gonna Need It |
|
|
60
|
+
| **Simplest thing** | Write the minimum to pass |
|
|
61
|
+
| **No optimization** | Just make it work |
|
|
62
|
+
|
|
63
|
+
### GREEN Phase Rules
|
|
64
|
+
|
|
65
|
+
- Don't write unneeded code
|
|
66
|
+
- Don't optimize yet
|
|
67
|
+
- Pass the test, nothing more
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 5. REFACTOR Phase Principles
|
|
72
|
+
|
|
73
|
+
### What to Improve
|
|
74
|
+
|
|
75
|
+
| Area | Action |
|
|
76
|
+
|------|--------|
|
|
77
|
+
| Duplication | Extract common code |
|
|
78
|
+
| Naming | Make intent clear |
|
|
79
|
+
| Structure | Improve organization |
|
|
80
|
+
| Complexity | Simplify logic |
|
|
81
|
+
|
|
82
|
+
### REFACTOR Rules
|
|
83
|
+
|
|
84
|
+
- All tests must stay green
|
|
85
|
+
- Small incremental changes
|
|
86
|
+
- Commit after each refactor
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## 6. AAA Pattern
|
|
91
|
+
|
|
92
|
+
Every test follows:
|
|
93
|
+
|
|
94
|
+
| Step | Purpose |
|
|
95
|
+
|------|---------|
|
|
96
|
+
| **Arrange** | Set up test data |
|
|
97
|
+
| **Act** | Execute code under test |
|
|
98
|
+
| **Assert** | Verify expected outcome |
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## 7. When to Use TDD
|
|
103
|
+
|
|
104
|
+
| Scenario | TDD Value |
|
|
105
|
+
|----------|-----------|
|
|
106
|
+
| New feature | High |
|
|
107
|
+
| Bug fix | High (write test first) |
|
|
108
|
+
| Complex logic | High |
|
|
109
|
+
| Exploratory | Low (spike, then TDD) |
|
|
110
|
+
| UI layout | Low |
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## 8. Test Prioritization
|
|
115
|
+
|
|
116
|
+
| Priority | Test Type |
|
|
117
|
+
|----------|-----------|
|
|
118
|
+
| 1 | Happy path |
|
|
119
|
+
| 2 | Error cases |
|
|
120
|
+
| 3 | Edge cases |
|
|
121
|
+
| 4 | Performance |
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## 9. Anti-Patterns
|
|
126
|
+
|
|
127
|
+
| ❌ Don't | ✅ Do |
|
|
128
|
+
|----------|-------|
|
|
129
|
+
| Skip the RED phase | Watch test fail first |
|
|
130
|
+
| Write tests after | Write tests before |
|
|
131
|
+
| Over-engineer initial | Keep it simple |
|
|
132
|
+
| Multiple asserts | One behavior per test |
|
|
133
|
+
| Test implementation | Test behavior |
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## 10. AI-Augmented TDD
|
|
138
|
+
|
|
139
|
+
### Multi-Agent Pattern
|
|
140
|
+
|
|
141
|
+
| Agent | Role |
|
|
142
|
+
|-------|------|
|
|
143
|
+
| Agent A | Write failing tests (RED) |
|
|
144
|
+
| Agent B | Implement to pass (GREEN) |
|
|
145
|
+
| Agent C | Optimize (REFACTOR) |
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
> **Remember:** The test is the specification. If you can't write a test, you don't understand the requirement.
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: testing-patterns
|
|
3
|
+
description: Testing patterns and principles. Unit, integration, mocking strategies.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Glob, Grep, Bash
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Testing Patterns
|
|
8
|
+
|
|
9
|
+
> Principles for reliable test suites.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 1. Testing Pyramid
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
/\ E2E (Few)
|
|
17
|
+
/ \ Critical flows
|
|
18
|
+
/----\
|
|
19
|
+
/ \ Integration (Some)
|
|
20
|
+
/--------\ API, DB queries
|
|
21
|
+
/ \
|
|
22
|
+
/------------\ Unit (Many)
|
|
23
|
+
Functions, classes
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 2. AAA Pattern
|
|
29
|
+
|
|
30
|
+
| Step | Purpose |
|
|
31
|
+
|------|---------|
|
|
32
|
+
| **Arrange** | Set up test data |
|
|
33
|
+
| **Act** | Execute code under test |
|
|
34
|
+
| **Assert** | Verify outcome |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 3. Test Type Selection
|
|
39
|
+
|
|
40
|
+
### When to Use Each
|
|
41
|
+
|
|
42
|
+
| Type | Best For | Speed |
|
|
43
|
+
|------|----------|-------|
|
|
44
|
+
| **Unit** | Pure functions, logic | Fast (<50ms) |
|
|
45
|
+
| **Integration** | API, DB, services | Medium |
|
|
46
|
+
| **E2E** | Critical user flows | Slow |
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 4. Unit Test Principles
|
|
51
|
+
|
|
52
|
+
### Good Unit Tests
|
|
53
|
+
|
|
54
|
+
| Principle | Meaning |
|
|
55
|
+
|-----------|---------|
|
|
56
|
+
| Fast | < 100ms each |
|
|
57
|
+
| Isolated | No external deps |
|
|
58
|
+
| Repeatable | Same result always |
|
|
59
|
+
| Self-checking | No manual verification |
|
|
60
|
+
| Timely | Written with code |
|
|
61
|
+
|
|
62
|
+
### What to Unit Test
|
|
63
|
+
|
|
64
|
+
| Test | Don't Test |
|
|
65
|
+
|------|------------|
|
|
66
|
+
| Business logic | Framework code |
|
|
67
|
+
| Edge cases | Third-party libs |
|
|
68
|
+
| Error handling | Simple getters |
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 5. Integration Test Principles
|
|
73
|
+
|
|
74
|
+
### What to Test
|
|
75
|
+
|
|
76
|
+
| Area | Focus |
|
|
77
|
+
|------|-------|
|
|
78
|
+
| API endpoints | Request/response |
|
|
79
|
+
| Database | Queries, transactions |
|
|
80
|
+
| External services | Contracts |
|
|
81
|
+
|
|
82
|
+
### Setup/Teardown
|
|
83
|
+
|
|
84
|
+
| Phase | Action |
|
|
85
|
+
|-------|--------|
|
|
86
|
+
| Before All | Connect resources |
|
|
87
|
+
| Before Each | Reset state |
|
|
88
|
+
| After Each | Clean up |
|
|
89
|
+
| After All | Disconnect |
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 6. Mocking Principles
|
|
94
|
+
|
|
95
|
+
### When to Mock
|
|
96
|
+
|
|
97
|
+
| Mock | Don't Mock |
|
|
98
|
+
|------|------------|
|
|
99
|
+
| External APIs | The code under test |
|
|
100
|
+
| Database (unit) | Simple dependencies |
|
|
101
|
+
| Time/random | Pure functions |
|
|
102
|
+
| Network | In-memory stores |
|
|
103
|
+
|
|
104
|
+
### Mock Types
|
|
105
|
+
|
|
106
|
+
| Type | Use |
|
|
107
|
+
|------|-----|
|
|
108
|
+
| Stub | Return fixed values |
|
|
109
|
+
| Spy | Track calls |
|
|
110
|
+
| Mock | Set expectations |
|
|
111
|
+
| Fake | Simplified implementation |
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## 7. Test Organization
|
|
116
|
+
|
|
117
|
+
### Naming
|
|
118
|
+
|
|
119
|
+
| Pattern | Example |
|
|
120
|
+
|---------|---------|
|
|
121
|
+
| Should behavior | "should return error when..." |
|
|
122
|
+
| When condition | "when user not found..." |
|
|
123
|
+
| Given-when-then | "given X, when Y, then Z" |
|
|
124
|
+
|
|
125
|
+
### Grouping
|
|
126
|
+
|
|
127
|
+
| Level | Use |
|
|
128
|
+
|-------|-----|
|
|
129
|
+
| describe | Group related tests |
|
|
130
|
+
| it/test | Individual case |
|
|
131
|
+
| beforeEach | Common setup |
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 8. Test Data
|
|
136
|
+
|
|
137
|
+
### Strategies
|
|
138
|
+
|
|
139
|
+
| Approach | Use |
|
|
140
|
+
|----------|-----|
|
|
141
|
+
| Factories | Generate test data |
|
|
142
|
+
| Fixtures | Predefined datasets |
|
|
143
|
+
| Builders | Fluent object creation |
|
|
144
|
+
|
|
145
|
+
### Principles
|
|
146
|
+
|
|
147
|
+
- Use realistic data
|
|
148
|
+
- Randomize non-essential values (faker)
|
|
149
|
+
- Share common fixtures
|
|
150
|
+
- Keep data minimal
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## 9. Best Practices
|
|
155
|
+
|
|
156
|
+
| Practice | Why |
|
|
157
|
+
|----------|-----|
|
|
158
|
+
| One assert per test | Clear failure reason |
|
|
159
|
+
| Independent tests | No order dependency |
|
|
160
|
+
| Fast tests | Run frequently |
|
|
161
|
+
| Descriptive names | Self-documenting |
|
|
162
|
+
| Clean up | Avoid side effects |
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 10. Anti-Patterns
|
|
167
|
+
|
|
168
|
+
| ❌ Don't | ✅ Do |
|
|
169
|
+
|----------|-------|
|
|
170
|
+
| Test implementation | Test behavior |
|
|
171
|
+
| Duplicate test code | Use factories |
|
|
172
|
+
| Complex test setup | Simplify or split |
|
|
173
|
+
| Ignore flaky tests | Fix root cause |
|
|
174
|
+
| Skip cleanup | Reset state |
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
> **Remember:** Tests are documentation. If someone can't understand what the code does from the tests, rewrite them.
|