design-tokens-validator
[Design System] Validate that code and styles use official design tokens instead of hard-coded values. Use when (1) reviewing CSS/SCSS/Tailwind/styled-components for hard-coded colors/spacing, (2) checking SwiftUI/UIKit for raw color/font values, (3) auditing Unity styles for magic numbers, (4) enforcing design system compliance, (5) user asks to 'check design tokens', 'validate tokens', 'find hard-coded values', or 'audit design system usage'.
When & Why to Use This Skill
The Design Tokens Validator is a specialized Claude skill designed to automate the auditing of source code for design system compliance. It identifies hard-coded colors, typography, spacing, and shadows across various frameworks—including CSS, Tailwind, SwiftUI, and Unity—and suggests official token replacements. By eliminating 'magic numbers' and raw hex codes, it ensures visual consistency, simplifies UI maintenance, and streamlines the handoff between design and engineering teams.
Use Cases
- Automated Code Reviews: Integrate into the pull request workflow to automatically flag non-compliant styles and enforce the use of official design tokens in CSS, SCSS, or styled-components.
- Legacy Codebase Auditing: Scan large existing projects to identify hard-coded values and 'magic numbers' that need to be refactored for better maintainability and brand alignment.
- Cross-Platform UI Validation: Ensure consistent styling across different platforms by checking SwiftUI/UIKit for raw color values and Unity styles for non-standardized spacing or fonts.
- Design System Migration: Assist development teams in transitioning from hard-coded styles to a token-based architecture by mapping detected raw values to their corresponding design system tokens.
| name | design-tokens-validator |
|---|---|
| description | "[Design System] Validate that code and styles use official design tokens instead of hard-coded values. Use when (1) reviewing CSS/SCSS/Tailwind/styled-components for hard-coded colors/spacing, (2) checking SwiftUI/UIKit for raw color/font values, (3) auditing Unity styles for magic numbers, (4) enforcing design system compliance, (5) user asks to 'check design tokens', 'validate tokens', 'find hard-coded values', or 'audit design system usage'." |
Design Tokens Validator
Scan source files for hard-coded design values and suggest official token replacements.
Quick Start
python3 scripts/validate_tokens.py --tokens tokens.json --source src/
Supported Token Categories
| Category | Example Token | Detects |
|---|---|---|
| Colors | color.primary.500 |
Hex (#FF0000), rgba(), hsl(), named colors |
| Typography | font.size.md, font.weight.bold |
px/rem font sizes, numeric weights |
| Spacing | spacing.4, spacing.lg |
px/rem padding/margin/gap values |
| Radius | radius.md |
Border-radius values |
| Shadows | shadow.lg |
Box-shadow definitions |
Detection Examples
CSS/SCSS
/* Violation */
.card { color: #222222; padding: 17px; }
/* Correct */
.card { color: var(--color-text-primary); padding: var(--spacing-4); }
SwiftUI
// Violation
Text("Hello").foregroundColor(Color(hex: "#222222"))
// Correct
Text("Hello").foregroundColor(.textPrimary)