design-system-aware
Design System Aware Code Generation
Trigger condition: This skill activates when ANY .tsx or .jsx file inside src/ or app/ is being created or modified, AND .claude/design-tokens/design-tokens.json exists.
When writing or editing React/Next.js frontend code in this project, follow these rules:
Before Writing Code
- Check if
.claude/design-tokens/design-tokens.jsonexists. - If it exists, read it and use it as the source of truth for all design decisions.
- Check the
componentssection before creating any new component — reuse what exists.
Token Usage
- All colors, spacing, font sizes, shadows, and border radii must come from
.claude/design-tokens/design-tokens.json. - Never hardcode design values. No raw hex colors, no magic number padding or margins.
- Use the project's styling approach as specified in
styling_approach.
Preferred Library Conventions
- If
preferred_librariesexists indesign-tokens.json, always use theselectedlibrary for each capability category. - Data fetching: use whatever is at
preferred_libraries.data_fetching.selected. If React Query, useuseQuery/useMutation. If SWR, useuseSWR. If axios, use the project's axios instance. Never use an alternative library that is installed but not selected. - Dates: use whatever is at
preferred_libraries.dates.selected. Never mix date libraries (e.g., don't usemomentifdate-fnsis selected). - Forms, validation, icons, animation, charts, etc.: same rule — always use the
selectedlibrary for each category. - Follow the project's error handling and loading state patterns as documented in the
apisection. - Place API-related code in the same directory structure the project already uses.
Component Reusability
- If a UI pattern appears 2+ times, extract it into a reusable component. A pattern is "repeated" if 2+ elements share the same HTML structure (same nesting, same tag types) AND the same visual styling (same colors, spacing, border treatment). Different text content does not make a pattern different.
- New components must be props-driven. No hardcoded content inside components.
- Compose complex UI from small pieces: a
PageHeaderusesHeading+Breadcrumbs+ActionBar. - Sub-component extraction rule: Extract sub-components into separate files if they exceed 15 lines. Sub-components of 15 lines or fewer may stay in the parent file.
SOLID
- Single Responsibility: One component, one job.
- Open/Closed: Extend via props and composition, not source modification.
- Interface Segregation: Don't bloat props. Split if needed.
- Dependency Inversion: Depend on props and hooks, not concrete implementations.
DRY
- Shared logic → custom hooks.
- Shared layout → layout components.
- Shared styles → design tokens.
- No copy-paste between components.
More from codestate-cs/figma-to-design
figma-to-design-init
Initialize the design-to-code workflow. Scans your codebase for styling patterns, extracts design tokens, discovers reusable components, detects API call patterns, and generates design token files under .claude/design-tokens/. Run this once per project before using /figma-to-design-build.
16figma-to-design-audit
Audit your codebase for design token drift. Finds hardcoded colors, spacing, and font values that should use design tokens. Reports unused tokens and components not following the design system. Run periodically to keep your codebase consistent.
13