tribunal-kit 2.4.6 → 3.1.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/.agent/ARCHITECTURE.md +99 -99
- package/.agent/GEMINI.md +52 -52
- package/.agent/agents/accessibility-reviewer.md +139 -86
- package/.agent/agents/ai-code-reviewer.md +160 -90
- package/.agent/agents/backend-specialist.md +164 -127
- package/.agent/agents/code-archaeologist.md +115 -73
- package/.agent/agents/database-architect.md +130 -110
- package/.agent/agents/debugger.md +137 -97
- package/.agent/agents/dependency-reviewer.md +78 -30
- package/.agent/agents/devops-engineer.md +161 -118
- package/.agent/agents/documentation-writer.md +151 -87
- package/.agent/agents/explorer-agent.md +117 -99
- package/.agent/agents/frontend-reviewer.md +127 -47
- package/.agent/agents/frontend-specialist.md +169 -109
- package/.agent/agents/game-developer.md +28 -164
- package/.agent/agents/logic-reviewer.md +87 -49
- package/.agent/agents/mobile-developer.md +151 -103
- package/.agent/agents/mobile-reviewer.md +133 -50
- package/.agent/agents/orchestrator.md +121 -110
- package/.agent/agents/penetration-tester.md +103 -77
- package/.agent/agents/performance-optimizer.md +136 -92
- package/.agent/agents/performance-reviewer.md +139 -69
- package/.agent/agents/product-manager.md +104 -70
- package/.agent/agents/product-owner.md +6 -25
- package/.agent/agents/project-planner.md +95 -95
- package/.agent/agents/qa-automation-engineer.md +174 -87
- package/.agent/agents/security-auditor.md +133 -129
- package/.agent/agents/seo-specialist.md +160 -99
- package/.agent/agents/sql-reviewer.md +132 -44
- package/.agent/agents/supervisor-agent.md +137 -109
- package/.agent/agents/swarm-worker-contracts.md +17 -17
- package/.agent/agents/swarm-worker-registry.md +46 -46
- package/.agent/agents/test-coverage-reviewer.md +132 -53
- package/.agent/agents/test-engineer.md +0 -21
- package/.agent/agents/type-safety-reviewer.md +143 -33
- package/.agent/patterns/generator.md +9 -9
- package/.agent/patterns/inversion.md +12 -12
- package/.agent/patterns/pipeline.md +9 -9
- package/.agent/patterns/reviewer.md +13 -13
- package/.agent/patterns/tool-wrapper.md +9 -9
- package/.agent/rules/GEMINI.md +63 -63
- package/.agent/scripts/__pycache__/auto_preview.cpython-311.pyc +0 -0
- package/.agent/scripts/__pycache__/bundle_analyzer.cpython-311.pyc +0 -0
- package/.agent/scripts/__pycache__/checklist.cpython-311.pyc +0 -0
- package/.agent/scripts/__pycache__/dependency_analyzer.cpython-311.pyc +0 -0
- package/.agent/scripts/__pycache__/security_scan.cpython-311.pyc +0 -0
- package/.agent/scripts/__pycache__/session_manager.cpython-311.pyc +0 -0
- package/.agent/scripts/__pycache__/skill_integrator.cpython-311.pyc +0 -0
- package/.agent/scripts/__pycache__/swarm_dispatcher.cpython-311.pyc +0 -0
- package/.agent/scripts/__pycache__/test_runner.cpython-311.pyc +0 -0
- package/.agent/scripts/__pycache__/verify_all.cpython-311.pyc +0 -0
- package/.agent/scripts/compress_skills.py +167 -0
- package/.agent/scripts/consolidate_skills.py +173 -0
- package/.agent/scripts/deep_compress.py +202 -0
- package/.agent/scripts/minify_context.py +80 -0
- package/.agent/scripts/security_scan.py +1 -1
- package/.agent/scripts/strip_tribunal.py +41 -0
- package/.agent/skills/agent-organizer/SKILL.md +60 -100
- package/.agent/skills/agentic-patterns/SKILL.md +0 -70
- package/.agent/skills/ai-prompt-injection-defense/SKILL.md +108 -53
- package/.agent/skills/api-patterns/SKILL.md +197 -257
- package/.agent/skills/api-security-auditor/SKILL.md +125 -57
- package/.agent/skills/app-builder/SKILL.md +326 -50
- package/.agent/skills/app-builder/templates/SKILL.md +13 -15
- package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +16 -16
- package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +22 -22
- package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +18 -18
- package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +20 -20
- package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +17 -17
- package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +18 -18
- package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +21 -21
- package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +19 -19
- package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +26 -26
- package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +26 -26
- package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +19 -19
- package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +18 -18
- package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +20 -20
- package/.agent/skills/appflow-wireframe/SKILL.md +71 -98
- package/.agent/skills/architecture/SKILL.md +161 -200
- package/.agent/skills/authentication-best-practices/SKILL.md +121 -54
- package/.agent/skills/bash-linux/SKILL.md +71 -166
- package/.agent/skills/behavioral-modes/SKILL.md +8 -69
- package/.agent/skills/brainstorming/SKILL.md +345 -127
- package/.agent/skills/building-native-ui/SKILL.md +125 -57
- package/.agent/skills/clean-code/SKILL.md +266 -149
- package/.agent/skills/code-review-checklist/SKILL.md +0 -62
- package/.agent/skills/config-validator/SKILL.md +73 -131
- package/.agent/skills/csharp-developer/SKILL.md +434 -73
- package/.agent/skills/database-design/SKILL.md +190 -275
- package/.agent/skills/deployment-procedures/SKILL.md +81 -158
- package/.agent/skills/devops-engineer/SKILL.md +255 -94
- package/.agent/skills/devops-incident-responder/SKILL.md +50 -69
- package/.agent/skills/doc.md +5 -5
- package/.agent/skills/documentation-templates/SKILL.md +19 -63
- package/.agent/skills/edge-computing/SKILL.md +75 -165
- package/.agent/skills/extract-design-system/SKILL.md +84 -58
- package/.agent/skills/framer-motion-expert/SKILL.md +195 -0
- package/.agent/skills/frontend-design/SKILL.md +151 -499
- package/.agent/skills/game-design-expert/SKILL.md +71 -0
- package/.agent/skills/game-engineering-expert/SKILL.md +88 -0
- package/.agent/skills/geo-fundamentals/SKILL.md +52 -178
- package/.agent/skills/github-operations/SKILL.md +197 -272
- package/.agent/skills/gsap-expert/SKILL.md +194 -0
- package/.agent/skills/i18n-localization/SKILL.md +60 -172
- package/.agent/skills/intelligent-routing/SKILL.md +123 -103
- package/.agent/skills/lint-and-validate/SKILL.md +8 -52
- package/.agent/skills/llm-engineering/SKILL.md +281 -195
- package/.agent/skills/local-first/SKILL.md +76 -159
- package/.agent/skills/mcp-builder/SKILL.md +48 -188
- package/.agent/skills/mobile-design/SKILL.md +213 -219
- package/.agent/skills/motion-engineering/SKILL.md +184 -0
- package/.agent/skills/nextjs-react-expert/SKILL.md +184 -203
- package/.agent/skills/nodejs-best-practices/SKILL.md +403 -185
- package/.agent/skills/observability/SKILL.md +211 -203
- package/.agent/skills/parallel-agents/SKILL.md +53 -146
- package/.agent/skills/performance-profiling/SKILL.md +171 -151
- package/.agent/skills/plan-writing/SKILL.md +49 -153
- package/.agent/skills/platform-engineer/SKILL.md +57 -103
- package/.agent/skills/playwright-best-practices/SKILL.md +110 -63
- package/.agent/skills/powershell-windows/SKILL.md +61 -179
- package/.agent/skills/python-patterns/SKILL.md +7 -35
- package/.agent/skills/python-pro/SKILL.md +273 -114
- package/.agent/skills/react-specialist/SKILL.md +227 -108
- package/.agent/skills/readme-builder/SKILL.md +15 -85
- package/.agent/skills/realtime-patterns/SKILL.md +216 -243
- package/.agent/skills/red-team-tactics/SKILL.md +10 -51
- package/.agent/skills/rust-pro/SKILL.md +525 -142
- package/.agent/skills/seo-fundamentals/SKILL.md +92 -153
- package/.agent/skills/server-management/SKILL.md +110 -166
- package/.agent/skills/shadcn-ui-expert/SKILL.md +154 -55
- package/.agent/skills/skill-creator/SKILL.md +18 -58
- package/.agent/skills/sql-pro/SKILL.md +543 -68
- package/.agent/skills/supabase-postgres-best-practices/SKILL.md +28 -68
- package/.agent/skills/swiftui-expert/SKILL.md +124 -57
- package/.agent/skills/systematic-debugging/SKILL.md +49 -151
- package/.agent/skills/tailwind-patterns/SKILL.md +433 -149
- package/.agent/skills/tdd-workflow/SKILL.md +63 -169
- package/.agent/skills/test-result-analyzer/SKILL.md +33 -73
- package/.agent/skills/testing-patterns/SKILL.md +437 -130
- package/.agent/skills/trend-researcher/SKILL.md +30 -71
- package/.agent/skills/ui-ux-pro-max/SKILL.md +0 -41
- package/.agent/skills/ui-ux-researcher/SKILL.md +51 -91
- package/.agent/skills/vue-expert/SKILL.md +225 -119
- package/.agent/skills/vulnerability-scanner/SKILL.md +264 -226
- package/.agent/skills/web-accessibility-auditor/SKILL.md +141 -58
- package/.agent/skills/web-design-guidelines/SKILL.md +17 -61
- package/.agent/skills/webapp-testing/SKILL.md +71 -196
- package/.agent/skills/whimsy-injector/SKILL.md +58 -132
- package/.agent/skills/workflow-optimizer/SKILL.md +28 -68
- package/.agent/workflows/api-tester.md +96 -224
- package/.agent/workflows/audit.md +81 -122
- package/.agent/workflows/brainstorm.md +69 -105
- package/.agent/workflows/changelog.md +65 -97
- package/.agent/workflows/create.md +73 -88
- package/.agent/workflows/debug.md +80 -111
- package/.agent/workflows/deploy.md +119 -92
- package/.agent/workflows/enhance.md +80 -91
- package/.agent/workflows/fix.md +68 -97
- package/.agent/workflows/generate.md +165 -164
- package/.agent/workflows/migrate.md +106 -109
- package/.agent/workflows/orchestrate.md +103 -86
- package/.agent/workflows/performance-benchmarker.md +77 -268
- package/.agent/workflows/plan.md +120 -98
- package/.agent/workflows/preview.md +39 -96
- package/.agent/workflows/refactor.md +105 -97
- package/.agent/workflows/review-ai.md +63 -102
- package/.agent/workflows/review.md +71 -110
- package/.agent/workflows/session.md +53 -113
- package/.agent/workflows/status.md +42 -88
- package/.agent/workflows/strengthen-skills.md +90 -51
- package/.agent/workflows/swarm.md +114 -129
- package/.agent/workflows/test.md +125 -102
- package/.agent/workflows/tribunal-backend.md +60 -78
- package/.agent/workflows/tribunal-database.md +62 -100
- package/.agent/workflows/tribunal-frontend.md +62 -82
- package/.agent/workflows/tribunal-full.md +56 -100
- package/.agent/workflows/tribunal-mobile.md +65 -94
- package/.agent/workflows/tribunal-performance.md +62 -105
- package/.agent/workflows/ui-ux-pro-max.md +72 -121
- package/README.md +11 -15
- package/package.json +1 -1
- package/.agent/skills/api-patterns/api-style.md +0 -42
- package/.agent/skills/api-patterns/auth.md +0 -24
- package/.agent/skills/api-patterns/documentation.md +0 -26
- package/.agent/skills/api-patterns/graphql.md +0 -41
- package/.agent/skills/api-patterns/rate-limiting.md +0 -31
- package/.agent/skills/api-patterns/response.md +0 -37
- package/.agent/skills/api-patterns/rest.md +0 -40
- package/.agent/skills/api-patterns/security-testing.md +0 -122
- package/.agent/skills/api-patterns/trpc.md +0 -41
- package/.agent/skills/api-patterns/versioning.md +0 -22
- package/.agent/skills/app-builder/agent-coordination.md +0 -71
- package/.agent/skills/app-builder/feature-building.md +0 -53
- package/.agent/skills/app-builder/project-detection.md +0 -34
- package/.agent/skills/app-builder/scaffolding.md +0 -118
- package/.agent/skills/app-builder/tech-stack.md +0 -40
- package/.agent/skills/architecture/context-discovery.md +0 -43
- package/.agent/skills/architecture/examples.md +0 -94
- package/.agent/skills/architecture/pattern-selection.md +0 -68
- package/.agent/skills/architecture/patterns-reference.md +0 -50
- package/.agent/skills/architecture/trade-off-analysis.md +0 -77
- package/.agent/skills/brainstorming/dynamic-questioning.md +0 -360
- package/.agent/skills/database-design/database-selection.md +0 -43
- package/.agent/skills/database-design/indexing.md +0 -39
- package/.agent/skills/database-design/migrations.md +0 -48
- package/.agent/skills/database-design/optimization.md +0 -36
- package/.agent/skills/database-design/orm-selection.md +0 -30
- package/.agent/skills/database-design/schema-design.md +0 -56
- package/.agent/skills/dotnet-core-expert/SKILL.md +0 -103
- package/.agent/skills/framer-motion-animations/SKILL.md +0 -74
- package/.agent/skills/frontend-design/animation-guide.md +0 -331
- package/.agent/skills/frontend-design/color-system.md +0 -329
- package/.agent/skills/frontend-design/decision-trees.md +0 -418
- package/.agent/skills/frontend-design/motion-graphics.md +0 -306
- package/.agent/skills/frontend-design/typography-system.md +0 -363
- package/.agent/skills/frontend-design/ux-psychology.md +0 -1116
- package/.agent/skills/frontend-design/visual-effects.md +0 -383
- package/.agent/skills/game-development/2d-games/SKILL.md +0 -119
- package/.agent/skills/game-development/3d-games/SKILL.md +0 -135
- package/.agent/skills/game-development/SKILL.md +0 -236
- package/.agent/skills/game-development/game-art/SKILL.md +0 -185
- package/.agent/skills/game-development/game-audio/SKILL.md +0 -190
- package/.agent/skills/game-development/game-design/SKILL.md +0 -129
- package/.agent/skills/game-development/mobile-games/SKILL.md +0 -108
- package/.agent/skills/game-development/multiplayer/SKILL.md +0 -132
- package/.agent/skills/game-development/pc-games/SKILL.md +0 -144
- package/.agent/skills/game-development/vr-ar/SKILL.md +0 -123
- package/.agent/skills/game-development/web-games/SKILL.md +0 -150
- package/.agent/skills/intelligent-routing/router-manifest.md +0 -65
- package/.agent/skills/mobile-design/decision-trees.md +0 -516
- package/.agent/skills/mobile-design/mobile-backend.md +0 -491
- package/.agent/skills/mobile-design/mobile-color-system.md +0 -420
- package/.agent/skills/mobile-design/mobile-debugging.md +0 -122
- package/.agent/skills/mobile-design/mobile-design-thinking.md +0 -357
- package/.agent/skills/mobile-design/mobile-navigation.md +0 -458
- package/.agent/skills/mobile-design/mobile-performance.md +0 -767
- package/.agent/skills/mobile-design/mobile-testing.md +0 -356
- package/.agent/skills/mobile-design/mobile-typography.md +0 -433
- package/.agent/skills/mobile-design/platform-android.md +0 -666
- package/.agent/skills/mobile-design/platform-ios.md +0 -561
- package/.agent/skills/mobile-design/touch-psychology.md +0 -537
- package/.agent/skills/nextjs-react-expert/1-async-eliminating-waterfalls.md +0 -312
- package/.agent/skills/nextjs-react-expert/2-bundle-bundle-size-optimization.md +0 -240
- package/.agent/skills/nextjs-react-expert/3-server-server-side-performance.md +0 -490
- package/.agent/skills/nextjs-react-expert/4-client-client-side-data-fetching.md +0 -264
- package/.agent/skills/nextjs-react-expert/5-rerender-re-render-optimization.md +0 -581
- package/.agent/skills/nextjs-react-expert/6-rendering-rendering-performance.md +0 -432
- package/.agent/skills/nextjs-react-expert/7-js-javascript-performance.md +0 -684
- package/.agent/skills/nextjs-react-expert/8-advanced-advanced-patterns.md +0 -150
- package/.agent/skills/vulnerability-scanner/checklists.md +0 -121
|
@@ -1,74 +1,100 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: extract-design-system
|
|
3
|
-
description:
|
|
4
|
-
allowed-tools: Read, Write, Edit, Glob, Grep
|
|
5
|
-
version:
|
|
6
|
-
last-updated: 2026-
|
|
7
|
-
applies-to-model: claude-3-7-sonnet
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# Extract Design System
|
|
11
|
-
|
|
12
|
-
You are a Design System Extraction Engine. Your primary objective is to reverse-engineer given UI representations (screenshots, web page layouts, or raw CSS files) into highly structured, mathematically sound design tokens.
|
|
13
|
-
|
|
14
|
-
## Core Directives
|
|
15
|
-
|
|
16
|
-
1. **Token Primitives First:**
|
|
17
|
-
- Never extract a hardcoded hex color directly into a component. Always abstract it to a root primitive. E.g., `#0f172a` becomes `slate-900` or `--primary-background`.
|
|
18
|
-
- Organize extractions strictly by domain: `Colors`, `Typography` (font-family, line-height, kerning), `Spacing/Sizing` (rem/px scales), `Shadows/Elevation`, and `Border Radii`.
|
|
19
|
-
|
|
20
|
-
2. **Mathematical Scales:**
|
|
21
|
-
- Ensure all spacing and sizing extracted locks onto a geometric grid (typically a 4px or 8px baseline).
|
|
22
|
-
- If an extracted padding is `15px`, aggressively round and normalize it to `16px` (`rem` equivalent: `1rem` / `p-4`) in the system configuration.
|
|
23
|
-
|
|
24
|
-
3. **Output Standardization:**
|
|
25
|
-
- By default, construct configurations that seamlessly graft into standard frameworks (e.g., generating `tailwind.config.ts` themes, or creating CSS variable blocks in `globals.css`).
|
|
26
|
-
- For generic outputs, emit raw JSON arrays defining the design system structure.
|
|
27
|
-
|
|
28
|
-
4. **Component Identification:**
|
|
29
|
-
- Beyond simple tokens, identify repeated UI patterns (Buttons, Input Fields, Cards). Extract their base states alongside `hover`, `active`, `focus`, and `disabled` variants perfectly.
|
|
30
|
-
|
|
31
|
-
## Execution
|
|
32
|
-
When asked to extract a design system from a source, immediately compile a comprehensive `tokens` file dictating exact HSL or Hex values. You must explain *why* certain rounding decisions were made (e.g., snapping to the 4px grid) before generating configurations.
|
|
1
|
+
---
|
|
2
|
+
name: extract-design-system
|
|
3
|
+
description: Design system extraction and tokenization mastery. Identifying repeated HTML/CSS patterns, extracting CSS variables, generating design tokens (colors, spacing, typography), building reusable component schemas, and standardizing ad-hoc styles into cohesive global systems. Use when refactoring messy CSS into a unified design system.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Glob, Grep
|
|
5
|
+
version: 2.0.0
|
|
6
|
+
last-updated: 2026-04-02
|
|
7
|
+
applies-to-model: gemini-2.5-pro, claude-3-7-sonnet
|
|
8
|
+
---
|
|
33
9
|
|
|
10
|
+
# Extract Design System — Tokenization Mastery
|
|
34
11
|
|
|
35
12
|
---
|
|
36
13
|
|
|
37
|
-
##
|
|
14
|
+
## 1. The Token Extraction Protocol
|
|
38
15
|
|
|
39
|
-
|
|
16
|
+
When reviewing a messy, legacy UI file (`<div style="background: #e23e2a; border-radius: 6px; padding: 12px">`), the agent must extract these hardcoded values into Global Tokens.
|
|
40
17
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
3. **Skipping Edge Cases:** Writing the "happy path" and ignoring error handling, timeouts, or data validation.
|
|
44
|
-
4. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
|
|
45
|
-
5. **Silent Degradation:** Catching and suppressing errors without logging or re-raising.
|
|
18
|
+
### Tier 1: Core Design Tokens (The Foundation)
|
|
19
|
+
Tokens should be semantic, not literal. `color-brand` > `color-red`.
|
|
46
20
|
|
|
47
|
-
|
|
21
|
+
```css
|
|
22
|
+
:root {
|
|
23
|
+
/* Colors (HSL is preferred for programmatic manipulation) */
|
|
24
|
+
--brand-primary: 360, 76%, 53%; /* The specific red */
|
|
25
|
+
--surface-default: 0, 0%, 100%;
|
|
26
|
+
--surface-muted: 210, 40%, 96%;
|
|
27
|
+
|
|
28
|
+
/* Typography */
|
|
29
|
+
--font-sans: 'Inter', system-ui, sans-serif;
|
|
30
|
+
|
|
31
|
+
/* Space / Geometry (8px grid scale) */
|
|
32
|
+
--space-1: 0.25rem; /* 4px */
|
|
33
|
+
--space-2: 0.5rem; /* 8px */
|
|
34
|
+
--space-3: 0.75rem; /* 12px */
|
|
35
|
+
--space-4: 1rem; /* 16px */
|
|
36
|
+
|
|
37
|
+
/* Radaii */
|
|
38
|
+
--radius-sm: 4px;
|
|
39
|
+
--radius-md: 6px; /* Extracted from the 6px legacy element */
|
|
40
|
+
}
|
|
41
|
+
```
|
|
48
42
|
|
|
49
|
-
|
|
43
|
+
### Tier 2: The Refactor
|
|
44
|
+
(Using Tailwind v4 CSS-First as the standard delivery mechanism)
|
|
50
45
|
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
```css
|
|
47
|
+
@theme {
|
|
48
|
+
--color-primary: hsl(var(--brand-primary));
|
|
49
|
+
--spacing-3: var(--space-3);
|
|
50
|
+
--radius-md: var(--radius-md);
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
---
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
2. **Silent Degradation:** Catching and suppressing errors without logging or handling.
|
|
58
|
-
3. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
|
|
56
|
+
## 2. Standardizing the 3 "C" Configurations
|
|
59
57
|
|
|
60
|
-
|
|
58
|
+
If building a design system inside React/Next.js, standardize the system through 3 primary mechanisms.
|
|
61
59
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
✅
|
|
60
|
+
1. **Colors (Dark Mode First):** Every single color extracted must have an inverse defined for `[data-theme='dark']`.
|
|
61
|
+
2. **Container Queries:** Media queries (`@media (min-width)`) define the *device*. Container queries (`@container (min-width)`) define the *component context*. Always extract component sizing to rely on container-driven layouts for ultimate reusability.
|
|
62
|
+
3. **Compound Variants (CVA):** Group extracted CSS classes into logical component states rather than passing 10 boolean props.
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
// ✅ Efficient Extracted Component Architecture
|
|
66
|
+
import { cva } from "class-variance-authority";
|
|
67
|
+
|
|
68
|
+
const buttonStyles = cva(
|
|
69
|
+
"inline-flex items-center justify-center rounded-md font-medium transition-colors", // Base
|
|
70
|
+
{
|
|
71
|
+
variants: {
|
|
72
|
+
intent: {
|
|
73
|
+
primary: "bg-primary text-white hover:bg-primary/90",
|
|
74
|
+
destructive: "bg-red-500 text-white hover:bg-red-600",
|
|
75
|
+
outline: "border border-input hover:bg-accent",
|
|
76
|
+
},
|
|
77
|
+
size: {
|
|
78
|
+
sm: "h-9 px-3 text-sm",
|
|
79
|
+
default: "h-10 px-4 py-2", // Extracted standard size
|
|
80
|
+
lg: "h-11 px-8",
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
defaultVariants: {
|
|
84
|
+
intent: "primary",
|
|
85
|
+
size: "default",
|
|
86
|
+
},
|
|
87
|
+
}
|
|
88
|
+
);
|
|
68
89
|
```
|
|
69
90
|
|
|
70
|
-
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 3. Auditing the Accessibility Baseline
|
|
71
94
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
95
|
+
A Design System must mandate accessibility at the token level, preventing developers from manually breaking contrast ratios later.
|
|
96
|
+
|
|
97
|
+
1. Extracted primary text colors must hit a **4.5:1 contrast ratio** against the extracted background surfaces.
|
|
98
|
+
2. Focus rings must be decoupled and standardized globally (`ring-2 ring-primary ring-offset-2`).
|
|
99
|
+
|
|
100
|
+
---
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: framer-motion-expert
|
|
3
|
+
description: Framer Motion 12+ for React. Declarative animations, layout transitions, gestures, scroll-linked motion, AnimatePresence, useAnimate, LazyMotion. Use when building component animations, page transitions, shared layout animations, or gesture-driven UI.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Glob, Grep
|
|
5
|
+
version: 3.1.0
|
|
6
|
+
last-updated: 2026-04-06
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Framer Motion 12+ — Dense Reference
|
|
10
|
+
|
|
11
|
+
## Hallucination Traps (Read First)
|
|
12
|
+
- ❌ `<Motion>` (capital M) → ✅ `motion.div` (lowercase dot notation)
|
|
13
|
+
- ❌ `motion()` wrapper function → ✅ `motion.div`, `motion.span`, etc.
|
|
14
|
+
- ❌ `exitBeforeEnter` prop → ✅ `mode="wait"` on `<AnimatePresence>` (removed in FM7+)
|
|
15
|
+
- ❌ `exit` works without `<AnimatePresence>` → ✅ REQUIRES AnimatePresence wrapper
|
|
16
|
+
- ❌ `<AnimatePresence>` children without unique `key` → ✅ ALWAYS set `key`
|
|
17
|
+
- ❌ `stiffness + damping` AND `duration + bounce` together → ✅ pick ONE pair
|
|
18
|
+
- ❌ `m.div` without `<LazyMotion>` wrapper → ✅ REQUIRES LazyMotion parent
|
|
19
|
+
- ❌ `layout` animations with `domAnimation` feature set → ✅ requires `domMax`
|
|
20
|
+
- ❌ Force-animating `width`/`height`/`top`/`left` → ✅ use `x`,`y`,`scale`,`opacity` (GPU)
|
|
21
|
+
- ❌ `viewport.once` defaults to true → ✅ defaults to **false** — add `once: true` for entrance anims
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Core Primitives
|
|
26
|
+
|
|
27
|
+
### `motion.X` / Declarative Animation
|
|
28
|
+
```tsx
|
|
29
|
+
import { motion } from "framer-motion";
|
|
30
|
+
<motion.div
|
|
31
|
+
initial={{ opacity: 0, y: 20 }}
|
|
32
|
+
animate={{ opacity: 1, y: 0 }}
|
|
33
|
+
exit={{ opacity: 0, y: -20 }}
|
|
34
|
+
transition={{ duration: 0.3, ease: "easeOut" }}
|
|
35
|
+
/>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Variants (Stagger / Orchestration)
|
|
39
|
+
```tsx
|
|
40
|
+
const container = {
|
|
41
|
+
hidden: {},
|
|
42
|
+
visible: { transition: { staggerChildren: 0.08, delayChildren: 0.1 } },
|
|
43
|
+
};
|
|
44
|
+
const item = {
|
|
45
|
+
hidden: { opacity: 0, y: 20, filter: "blur(4px)" },
|
|
46
|
+
visible: { opacity: 1, y: 0, filter: "blur(0px)", transition: { duration: 0.4 } },
|
|
47
|
+
};
|
|
48
|
+
<motion.ul variants={container} initial="hidden" animate="visible">
|
|
49
|
+
{list.map(e => <motion.li key={e.id} variants={item}>{e.name}</motion.li>)}
|
|
50
|
+
</motion.ul>
|
|
51
|
+
// Variant names propagate to children automatically — no need to set initial/animate on each child
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Transitions
|
|
55
|
+
```tsx
|
|
56
|
+
// Tween (default)
|
|
57
|
+
transition={{ duration: 0.5, ease: "easeInOut", delay: 0.2, repeat: Infinity, repeatType: "reverse" }}
|
|
58
|
+
// Spring (physics)
|
|
59
|
+
transition={{ type: "spring", stiffness: 300, damping: 20 }} // OR use duration+bounce, not both
|
|
60
|
+
transition={{ type: "spring", duration: 0.8, bounce: 0.25 }}
|
|
61
|
+
// Per-property
|
|
62
|
+
transition={{ x: { type: "spring", stiffness: 300 }, opacity: { duration: 0.2 } }}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Gestures
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
// Hover/Tap/Focus
|
|
71
|
+
<motion.button
|
|
72
|
+
whileHover={{ scale: 1.05 }}
|
|
73
|
+
whileTap={{ scale: 0.95 }}
|
|
74
|
+
whileFocus={{ boxShadow: "0 0 0 3px rgba(66,153,225,0.6)" }}
|
|
75
|
+
transition={{ type: "spring", stiffness: 400, damping: 15 }}
|
|
76
|
+
/>
|
|
77
|
+
// Drag
|
|
78
|
+
<motion.div
|
|
79
|
+
drag="x" // "x" | "y" | true
|
|
80
|
+
dragConstraints={{ left: -100, right: 100 }}
|
|
81
|
+
dragElastic={0.2} // 0=hard stop, 1=free
|
|
82
|
+
dragMomentum={true}
|
|
83
|
+
dragSnapToOrigin
|
|
84
|
+
/>
|
|
85
|
+
// Scroll-triggered
|
|
86
|
+
<motion.div
|
|
87
|
+
initial={{ opacity: 0, y: 50 }}
|
|
88
|
+
whileInView={{ opacity: 1, y: 0 }}
|
|
89
|
+
viewport={{ once: true, amount: 0.3 }} // ← once: true is almost always what you want
|
|
90
|
+
/>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Layout Animations
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
// layout prop — auto-animates position/size changes
|
|
99
|
+
<motion.div layout transition={{ type: "spring", stiffness: 200 }}>
|
|
100
|
+
{/* layout="position" = only position, layout="size" = only size */}
|
|
101
|
+
</motion.div>
|
|
102
|
+
|
|
103
|
+
// layoutId — shared element transition (morph between renders)
|
|
104
|
+
// List thumbnail → expanded modal:
|
|
105
|
+
<motion.div key={item.id} layoutId={`card-${item.id}`} /> // in list
|
|
106
|
+
<motion.div layoutId={`card-${selectedId}`} className="modal" /> // in modal
|
|
107
|
+
// ❌ TRAP: Cross-tree layoutId requires <LayoutGroup> wrapper
|
|
108
|
+
import { LayoutGroup } from "framer-motion";
|
|
109
|
+
<LayoutGroup><Sidebar /><MainContent /></LayoutGroup>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### AnimatePresence
|
|
113
|
+
```tsx
|
|
114
|
+
<AnimatePresence mode="sync"> {/* "sync"|"wait"|"popLayout" */}
|
|
115
|
+
{items.map(item => (
|
|
116
|
+
<motion.div key={item.id} /* ← REQUIRED */
|
|
117
|
+
initial={{ opacity: 0, height: 0 }}
|
|
118
|
+
animate={{ opacity: 1, height: "auto" }}
|
|
119
|
+
exit={{ opacity: 0, height: 0 }}
|
|
120
|
+
/>
|
|
121
|
+
))}
|
|
122
|
+
</AnimatePresence>
|
|
123
|
+
// mode="wait" — waits for exit before entering
|
|
124
|
+
// initial={false} on AnimatePresence — skip first-render animation
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Scroll Animations
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
import { useScroll, useTransform } from "framer-motion";
|
|
133
|
+
// Page scroll progress (0–1)
|
|
134
|
+
const { scrollYProgress } = useScroll();
|
|
135
|
+
const y = useTransform(scrollYProgress, [0, 1], [0, -200]);
|
|
136
|
+
const opacity = useTransform(scrollYProgress, [0, 0.5], [1, 0]);
|
|
137
|
+
<motion.div style={{ y, opacity }} />
|
|
138
|
+
|
|
139
|
+
// Element-scoped scroll
|
|
140
|
+
const ref = useRef(null);
|
|
141
|
+
const { scrollYProgress } = useScroll({ target: ref, offset: ["start end", "end start"] });
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Hooks
|
|
147
|
+
|
|
148
|
+
### `useAnimate` — Imperative sequences
|
|
149
|
+
```tsx
|
|
150
|
+
import { useAnimate, stagger } from "framer-motion";
|
|
151
|
+
const [scope, animate] = useAnimate(); // ← returns [scope, animate] NOT [ref, controls]
|
|
152
|
+
await animate(".item", { opacity: 1 }, { delay: stagger(0.1) });
|
|
153
|
+
<div ref={scope}>...</div>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### `useMotionValue` + `useTransform` — No re-renders
|
|
157
|
+
```tsx
|
|
158
|
+
const x = useMotionValue(0);
|
|
159
|
+
const rotateY = useTransform(x, [-200, 200], [-45, 45]);
|
|
160
|
+
// ✅ useMotionValue does NOT trigger React re-renders — key perf advantage over useState
|
|
161
|
+
<motion.div style={{ x, rotateY }} drag="x" />
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### `useSpring` / `useVelocity`
|
|
165
|
+
```tsx
|
|
166
|
+
const springX = useSpring(x, { stiffness: 300, damping: 30 });
|
|
167
|
+
const xVel = useVelocity(x);
|
|
168
|
+
const skewX = useTransform(xVel, [-1000, 0, 1000], [-15, 0, 15]);
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Performance & Bundle
|
|
174
|
+
|
|
175
|
+
```tsx
|
|
176
|
+
// LazyMotion — ~5KB vs ~30KB full bundle
|
|
177
|
+
import { LazyMotion, domAnimation, m } from "framer-motion";
|
|
178
|
+
// domAnimation ≈ 5KB | domMax ≈ 20KB (needed for layout/drag)
|
|
179
|
+
<LazyMotion features={domAnimation}><m.div animate={{ opacity: 1 }} /></LazyMotion>
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Accessibility
|
|
183
|
+
```tsx
|
|
184
|
+
import { useReducedMotion } from "framer-motion";
|
|
185
|
+
const reduce = useReducedMotion();
|
|
186
|
+
// opacity/color: always safe | position/scale/rotation: must be disabled when reduce=true
|
|
187
|
+
<motion.div animate={{ x: reduce ? 0 : 100, opacity: 1 }} transition={{ duration: reduce ? 0 : 0.5 }} />
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Rules
|
|
191
|
+
- ✅ Animate: `x`, `y`, `scale`, `rotation`, `opacity` (GPU composited)
|
|
192
|
+
- ❌ Never animate: `width`, `height`, `top`, `left`, `padding`, `margin` (causes layout thrashing)
|
|
193
|
+
- ✅ `useMotionValue` for animation-driven values — never `useState`
|
|
194
|
+
- ❌ Nest `AnimatePresence` only when necessary — each adds reconciler overhead
|
|
195
|
+
- `"use client"` required in Next.js — `motion.div` cannot run in Server Components
|