Semantic Coding
Scan files, replace hardcoded styles with semantic design tokens (colors, typography, spacing, sizing), edit files directly.
Refactored from semantic-colors (color-only) into a comprehensive design system skill.
Usage
/semantic-coding [path]
DO NOT TOUCH (Non-Negotiable)
- Gradients:
from-*, via-*, to-*, bg-gradient-*, linear-gradient(), radial-gradient(), conic-gradient()
- SVG defs:
<linearGradient>, <radialGradient>, <stop>, url(#...), anything inside <defs>
- Glass morphism:
rgba(255,255,255,0.0x) overlays on gradient backgrounds
- Decorative shadows:
boxShadow glow effects tied to gradient LED/orb effects
- Animations:
@keyframes, animation timing values, transform values
- Template literals:
`border-${color}-500`, dynamic class construction
- Arbitrary values:
bg-[#hex], text-[14px], p-[20px] (JIT bracket syntax)
- Component props: Color/style values passed as non-className props (e.g.,
<Button color="red-500" />)
- Token source files:
globals.css, tailwind.config.*, tokens.ts, theme.ts
- Excluded dirs:
node_modules, .next, lib/generated, prisma/, dist/, __tests__/, *.test.*, *.spec.*
If a value is inside a protected context, skip and log ⚠ skipped (protected context).
Color Rules
Color Replacements
Note: Color-to-semantic mapping depends on your project's brand palette. The defaults below assume orange=brand, blue=info. If your brand uses blue/indigo/etc., map that family to brand instead and adjust accordingly.
| Hardcoded |
Semantic |
text-red-*, text-rose-* |
text-error |
text-green-*, text-emerald-*, text-teal-* |
text-success |
text-yellow-*, text-amber-* |
text-warning |
text-blue-*, text-cyan-* |
text-info |
text-orange-* |
text-brand |
text-indigo-*, text-violet-*, text-purple-* |
text-primary |
text-pink-*, text-fuchsia-* |
text-accent |
text-gray-*, text-slate-*, text-zinc-*, text-stone-*, text-neutral-*, text-ink-* |
text-muted-foreground |
text-gray-900, text-slate-900, text-zinc-900 |
text-foreground |
text-white (on semantic bg) |
text-{bg-token}-foreground |
text-black |
text-foreground |
bg-red-*, bg-rose-* (shade ≥500) |
bg-error |
bg-red-*, bg-rose-* (shade <500) |
bg-error/10 |
bg-green-*, bg-emerald-*, bg-teal-* (shade ≥500) |
bg-success |
bg-green-*, bg-emerald-*, bg-teal-* (shade <500) |
bg-success/10 |
bg-yellow-*, bg-amber-* (shade ≥500) |
bg-warning |
bg-yellow-*, bg-amber-* (shade <500) |
bg-warning/10 |
bg-blue-*, bg-cyan-* (shade ≥500) |
bg-info |
bg-blue-*, bg-cyan-* (shade <500) |
bg-info/10 |
bg-orange-* |
bg-brand or bg-brand/10 |
bg-indigo-*, bg-violet-*, bg-purple-* |
bg-primary or bg-primary/10 |
bg-gray-*, bg-slate-*, bg-zinc-*, bg-stone-*, bg-neutral-*, bg-ink-* |
bg-muted |
bg-white (page-level) |
bg-background |
bg-white (inside card/panel) |
bg-card |
bg-black/50 (overlay) |
bg-overlay |
border-gray-*, border-slate-*, border-zinc-*, border-stone-*, border-neutral-*, border-ink-* |
border-border |
border-red-*, border-rose-* |
border-error |
border-green-*, border-emerald-*, border-teal-* |
border-success |
border-blue-*, border-cyan-* |
border-info |
border-yellow-*, border-amber-* |
border-warning |
border-orange-* |
border-brand |
border-indigo-*, border-violet-*, border-purple-* |
border-primary |
shadow-emerald-*, shadow-green-* |
shadow-success |
shadow-red-* |
shadow-error |
shadow-blue-* |
shadow-info |
ring-red-* |
ring-error |
ring-green-* |
ring-success |
ring-blue-* |
ring-info |
divide-gray-*, divide-slate-* |
divide-border |
placeholder-gray-* |
placeholder-muted-foreground |
Foreground Pairing
| Background |
Foreground |
bg-primary |
text-primary-foreground |
bg-brand |
text-brand-foreground |
bg-success |
text-success-foreground |
bg-error |
text-error-foreground |
bg-warning |
text-warning-foreground |
bg-info |
text-info-foreground |
Dark Mode Override Removal
Collapse light+dark pairs into one semantic token:
- className="text-green-600 dark:text-green-400"
+ className="text-success"
- className="bg-red-100 dark:bg-red-900/20 border-red-200 dark:border-red-800"
+ className="bg-error/10 border-error"
Typography Rules
Font Family
| Hardcoded |
Semantic |
font-sans (body text) |
font-body |
font-sans (headings) |
font-heading |
font-mono |
font-mono |
font-serif |
font-display |
Inline fontFamily: 'Inter' |
var(--font-body) |
Inline fontFamily: 'monospace' |
var(--font-mono) |
Font Size (Text Scale)
| Hardcoded |
Semantic |
Use Case |
text-xs |
text-caption |
Labels, hints, timestamps |
text-sm |
text-body-sm |
Secondary content, metadata |
text-base |
text-body |
Body text, paragraphs |
text-lg |
text-body-lg |
Lead paragraphs, emphasis |
text-xl |
text-heading-sm |
Small headings, card titles |
text-2xl |
text-heading-md |
Section headings |
text-3xl |
text-heading-lg |
Page titles |
text-4xl, text-5xl |
text-heading-xl |
Hero headings |
text-6xl, text-7xl, text-8xl, text-9xl |
text-display |
Display/marketing headings |
Inline fontSize: '14px' |
var(--text-body-sm) |
|
Inline fontSize: '24px' |
var(--text-heading-md) |
|
Font Weight
| Hardcoded |
Semantic |
Use Case |
font-extralight (200) |
font-thin |
Decorative, display text |
font-light (300) |
font-light |
Subtle body text |
font-normal (400) |
font-normal |
Body text |
font-medium (500) |
font-medium |
Emphasis, labels |
font-semibold (600) |
font-semibold |
Subheadings |
font-bold (700) |
font-bold |
Headings, CTAs |
font-extrabold (800), font-black (900) |
font-heavy |
Display, marketing |
Line Height
| Hardcoded |
Semantic |
Use Case |
leading-none |
leading-none |
Display text, single-line |
leading-tight |
leading-tight |
Headings |
leading-snug |
leading-snug |
Subheadings |
leading-normal |
leading-normal |
Body text |
leading-relaxed |
leading-relaxed |
Long-form content |
leading-loose |
leading-loose |
Legal, fine print |
Letter Spacing
| Hardcoded |
Semantic |
tracking-tighter |
tracking-heading |
tracking-tight |
tracking-heading |
tracking-normal |
tracking-body |
tracking-wide |
tracking-label |
tracking-wider |
tracking-label |
tracking-widest + uppercase |
tracking-overline |
Composite Typography Patterns
Match multi-class patterns before individual classes. Apply the first matching composite rule.
| Hardcoded Pattern |
Semantic |
text-6xl+ font-bold/extrabold |
text-display |
text-4xl font-bold tracking-tight |
text-heading-xl |
text-3xl font-semibold |
text-title |
text-2xl font-semibold |
text-subtitle |
text-lg font-medium |
text-lead |
text-base |
text-body |
text-sm text-gray-* |
text-muted |
text-xs uppercase tracking-wide |
text-overline |
text-xs font-medium |
text-label |
Spacing Rules
Semantic Spacing Scale
| Hardcoded |
Semantic |
Value |
p-1, m-1 |
space-xs |
4px |
p-2, m-2 |
space-sm |
8px |
p-3, m-3 |
space-md |
12px |
p-4, m-4 |
space-lg |
16px |
p-5, m-5 |
space-xl |
20px |
p-6, m-6 |
space-2xl |
24px |
p-8, m-8 |
space-3xl |
32px |
p-10, m-10 |
space-4xl |
40px |
p-12, m-12 |
space-5xl |
48px |
Component Spacing Patterns
| Context |
Recommended Token |
| Button padding |
px-button py-button or p-4 |
| Card padding |
p-card or p-6 |
| Section padding |
p-section or py-12 px-6 |
| Input padding |
px-input py-input or px-4 py-2 |
| Gap between items |
gap-sm (8px), gap-md (12px), gap-lg (16px) |
| Stack spacing |
space-y-sm, space-y-md, space-y-lg |
Sizing Rules
Width/Height
| Hardcoded |
Semantic |
Use Case |
w-4 h-4 |
size-icon-xs |
Small icons |
w-5 h-5 |
size-icon-sm |
Default icons |
w-6 h-6 |
size-icon-md |
Medium icons |
w-8 h-8 |
size-icon-lg |
Large icons |
w-10 h-10 |
size-avatar-sm |
Small avatars |
w-12 h-12 |
size-avatar-md |
Medium avatars |
w-16 h-16 |
size-avatar-lg |
Large avatars |
h-10, h-11 |
h-input |
Input/button height |
max-w-sm |
max-w-form |
Form container |
max-w-xl |
max-w-content |
Content container |
max-w-5xl |
max-w-page |
Page container |
Border Radius
| Hardcoded |
Semantic |
Use Case |
rounded |
rounded-sm |
Subtle rounding |
rounded-md |
rounded-base |
Default rounding |
rounded-lg |
rounded-lg |
Cards, modals |
rounded-xl |
rounded-xl |
Large cards |
rounded-2xl |
rounded-2xl |
Hero sections |
rounded-full |
rounded-full |
Pills, avatars |
Shadow Rules
| Hardcoded |
Semantic |
Use Case |
shadow-sm |
shadow-sm |
Subtle elevation |
shadow |
shadow-base |
Default elevation |
shadow-md |
shadow-md |
Cards |
shadow-lg |
shadow-lg |
Modals, dropdowns |
shadow-xl |
shadow-xl |
Popovers |
shadow-2xl |
shadow-2xl |
Floating elements |
shadow-success |
shadow-success |
Success glow |
shadow-error |
shadow-error |
Error glow |
Z-Index Rules
| Hardcoded |
Semantic |
Use Case |
z-0 |
z-base |
Default layer |
z-10 |
z-dropdown |
Dropdowns |
z-20 |
z-sticky |
Sticky headers |
z-30 |
z-overlay |
Overlays |
z-40 |
z-modal |
Modals |
z-50 |
z-toast |
Toasts, tooltips |
Inline Style Replacements
| Hardcoded |
Semantic |
style={{ color: '#111827' }} |
className="text-foreground" |
style={{ color: '#6b7280' }} |
className="text-muted-foreground" |
style={{ backgroundColor: '#ffffff' }} |
var(--color-background) |
style={{ fontSize: '14px' }} |
var(--text-body-sm) |
style={{ fontWeight: 600 }} |
className="font-semibold" |
style={{ padding: '16px' }} |
className="p-4" or var(--space-lg) |
style={{ borderRadius: '8px' }} |
var(--radius-base) |
Third-Party Config Pattern
When a library requires specific values at initialization, use runtime CSS variable resolution:
function cssVar(name, fallback) {
if (typeof window === 'undefined') return fallback;
return getComputedStyle(document.documentElement)
.getPropertyValue(name).trim() || fallback;
}
// Usage: cssVar('--color-brand', '#F97316')
Initialize in useEffect (not module level) so CSS variables are available.
Scoped Token Pattern
When a page has a fixed dark background that doesn't change with theme, use var() with inline fallback:
color: 'var(--status-text-muted, #a1a1aa)'
Status Mapping
| Status |
Semantic |
DRAFT |
muted |
PENDING, SUBMITTED |
warning |
CONFIRMED, SUCCESS, COMPLETED, PAID |
success |
REJECTED, ERROR, CANCELLED |
error |
INFO, SENT, RECEIVED |
info |
Available Tokens Reference
Colors
Text: text-foreground, text-muted-foreground, text-primary, text-primary-foreground, text-brand, text-brand-foreground, text-accent, text-success, text-success-foreground, text-warning, text-warning-foreground, text-error, text-error-foreground, text-info, text-info-foreground
Background: bg-background, bg-card, bg-muted, bg-primary, bg-brand, bg-accent, bg-success, bg-warning, bg-error, bg-info, bg-overlay
Border: border-border, border-input, border-primary, border-brand, border-success, border-error, border-warning, border-info
Ring: ring-primary, ring-success, ring-error, ring-info
Shadow: shadow-success, shadow-error, shadow-info
Misc: divide-border, placeholder-muted-foreground
Typography
Font Family: font-body, font-heading, font-mono, font-display
Font Size: text-caption, text-body-sm, text-body, text-body-lg, text-heading-sm, text-heading-md, text-heading-lg, text-heading-xl, text-display
Composite: text-title, text-subtitle, text-lead, text-muted, text-overline, text-label
Font Weight: font-thin, font-light, font-normal, font-medium, font-semibold, font-bold, font-heavy
Letter Spacing: tracking-heading, tracking-body, tracking-label, tracking-overline
Line Height: leading-none, leading-tight, leading-snug, leading-normal, leading-relaxed, leading-loose
Spacing
Padding/Margin: space-xs, space-sm, space-md, space-lg, space-xl, space-2xl, space-3xl, space-4xl, space-5xl
Component: p-card, p-section, p-input, px-button, py-button
Gap: gap-xs, gap-sm, gap-md, gap-lg, gap-xl
Stack: space-y-sm, space-y-md, space-y-lg
Sizing
Icons: size-icon-xs, size-icon-sm, size-icon-md, size-icon-lg
Avatars: size-avatar-sm, size-avatar-md, size-avatar-lg
Containers: max-w-form, max-w-content, max-w-page
Input: h-input
Effects
Radius: rounded-sm, rounded-base, rounded-lg, rounded-xl, rounded-2xl, rounded-full
Shadow: shadow-sm, shadow-base, shadow-md, shadow-lg, shadow-xl, shadow-2xl
Z-Index: z-base, z-dropdown, z-sticky, z-overlay, z-modal, z-toast
Behavior
For each .tsx, .jsx, .ts, .js file in the target path (skip excluded dirs):
- Read the file
- Find hardcoded styles (colors, fonts, sizes, spacing)
- Check if inside protected context (gradient/SVG-def/animation)
- If safe → apply matching rule and edit immediately
- If protected context → skip, log as
⚠ skipped
After all files are done, re-scan to verify zero remaining violations. Print summary.
Summary Format
Semantic coding refactor: N files changed, M replacements
- file.tsx: colors (5), typography (3), spacing (2)
⚠ file.tsx:42 — skipped (gradient context)
⚠ file.tsx:88 — skipped (SVG defs)
1---2name: semantic-coding3description: Replace hardcoded styles with semantic design tokens (colors, typography, spacing, sizing) across a codebase. Use when refactoring inline hex colors/px values to a design system, migrating to CSS variables or Tailwind theme tokens, or enforcing token consistency.4---56# Semantic Coding78Scan files, replace hardcoded styles with semantic design tokens (colors, typography, spacing, sizing), edit files directly.910> Refactored from `semantic-colors` (color-only) into a comprehensive design system skill.1112## Usage1314```15/semantic-coding [path]16```1718## DO NOT TOUCH (Non-Negotiable)1920- **Gradients:** `from-*`, `via-*`, `to-*`, `bg-gradient-*`, `linear-gradient()`, `radial-gradient()`, `conic-gradient()`21- **SVG defs:** `<linearGradient>`, `<radialGradient>`, `<stop>`, `url(#...)`, anything inside `<defs>`22- **Glass morphism:** `rgba(255,255,255,0.0x)` overlays on gradient backgrounds23- **Decorative shadows:** `boxShadow` glow effects tied to gradient LED/orb effects24- **Animations:** `@keyframes`, animation timing values, transform values25- **Template literals:** `` `border-${color}-500` ``, dynamic class construction26- **Arbitrary values:** `bg-[#hex]`, `text-[14px]`, `p-[20px]` (JIT bracket syntax)27- **Component props:** Color/style values passed as non-className props (e.g., `<Button color="red-500" />`)28- **Token source files:** `globals.css`, `tailwind.config.*`, `tokens.ts`, `theme.ts`29- **Excluded dirs:** `node_modules`, `.next`, `lib/generated`, `prisma/`, `dist/`, `__tests__/`, `*.test.*`, `*.spec.*`3031If a value is inside a protected context, **skip** and log `⚠ skipped (protected context)`.3233---3435## Color Rules3637### Color Replacements3839> **Note:** Color-to-semantic mapping depends on your project's brand palette. The defaults below assume orange=brand, blue=info. If your brand uses blue/indigo/etc., map that family to `brand` instead and adjust accordingly.4041| Hardcoded | Semantic |42|-----------|----------|43| `text-red-*`, `text-rose-*` | `text-error` |44| `text-green-*`, `text-emerald-*`, `text-teal-*` | `text-success` |45| `text-yellow-*`, `text-amber-*` | `text-warning` |46| `text-blue-*`, `text-cyan-*` | `text-info` |47| `text-orange-*` | `text-brand` |48| `text-indigo-*`, `text-violet-*`, `text-purple-*` | `text-primary` |49| `text-pink-*`, `text-fuchsia-*` | `text-accent` |50| `text-gray-*`, `text-slate-*`, `text-zinc-*`, `text-stone-*`, `text-neutral-*`, `text-ink-*` | `text-muted-foreground` |51| `text-gray-900`, `text-slate-900`, `text-zinc-900` | `text-foreground` |52| `text-white` (on semantic bg) | `text-{bg-token}-foreground` |53| `text-black` | `text-foreground` |54| `bg-red-*`, `bg-rose-*` (shade ≥500) | `bg-error` |55| `bg-red-*`, `bg-rose-*` (shade <500) | `bg-error/10` |56| `bg-green-*`, `bg-emerald-*`, `bg-teal-*` (shade ≥500) | `bg-success` |57| `bg-green-*`, `bg-emerald-*`, `bg-teal-*` (shade <500) | `bg-success/10` |58| `bg-yellow-*`, `bg-amber-*` (shade ≥500) | `bg-warning` |59| `bg-yellow-*`, `bg-amber-*` (shade <500) | `bg-warning/10` |60| `bg-blue-*`, `bg-cyan-*` (shade ≥500) | `bg-info` |61| `bg-blue-*`, `bg-cyan-*` (shade <500) | `bg-info/10` |62| `bg-orange-*` | `bg-brand` or `bg-brand/10` |63| `bg-indigo-*`, `bg-violet-*`, `bg-purple-*` | `bg-primary` or `bg-primary/10` |64| `bg-gray-*`, `bg-slate-*`, `bg-zinc-*`, `bg-stone-*`, `bg-neutral-*`, `bg-ink-*` | `bg-muted` |65| `bg-white` (page-level) | `bg-background` |66| `bg-white` (inside card/panel) | `bg-card` |67| `bg-black/50` (overlay) | `bg-overlay` |68| `border-gray-*`, `border-slate-*`, `border-zinc-*`, `border-stone-*`, `border-neutral-*`, `border-ink-*` | `border-border` |69| `border-red-*`, `border-rose-*` | `border-error` |70| `border-green-*`, `border-emerald-*`, `border-teal-*` | `border-success` |71| `border-blue-*`, `border-cyan-*` | `border-info` |72| `border-yellow-*`, `border-amber-*` | `border-warning` |73| `border-orange-*` | `border-brand` |74| `border-indigo-*`, `border-violet-*`, `border-purple-*` | `border-primary` |75| `shadow-emerald-*`, `shadow-green-*` | `shadow-success` |76| `shadow-red-*` | `shadow-error` |77| `shadow-blue-*` | `shadow-info` |78| `ring-red-*` | `ring-error` |79| `ring-green-*` | `ring-success` |80| `ring-blue-*` | `ring-info` |81| `divide-gray-*`, `divide-slate-*` | `divide-border` |82| `placeholder-gray-*` | `placeholder-muted-foreground` |8384### Foreground Pairing8586| Background | Foreground |87|------------|------------|88| `bg-primary` | `text-primary-foreground` |89| `bg-brand` | `text-brand-foreground` |90| `bg-success` | `text-success-foreground` |91| `bg-error` | `text-error-foreground` |92| `bg-warning` | `text-warning-foreground` |93| `bg-info` | `text-info-foreground` |9495### Dark Mode Override Removal9697Collapse light+dark pairs into one semantic token:9899```diff100- className="text-green-600 dark:text-green-400"101+ className="text-success"102103- className="bg-red-100 dark:bg-red-900/20 border-red-200 dark:border-red-800"104+ className="bg-error/10 border-error"105```106107---108109## Typography Rules110111### Font Family112113| Hardcoded | Semantic |114|-----------|----------|115| `font-sans` (body text) | `font-body` |116| `font-sans` (headings) | `font-heading` |117| `font-mono` | `font-mono` |118| `font-serif` | `font-display` |119| Inline `fontFamily: 'Inter'` | `var(--font-body)` |120| Inline `fontFamily: 'monospace'` | `var(--font-mono)` |121122### Font Size (Text Scale)123124| Hardcoded | Semantic | Use Case |125|-----------|----------|----------|126| `text-xs` | `text-caption` | Labels, hints, timestamps |127| `text-sm` | `text-body-sm` | Secondary content, metadata |128| `text-base` | `text-body` | Body text, paragraphs |129| `text-lg` | `text-body-lg` | Lead paragraphs, emphasis |130| `text-xl` | `text-heading-sm` | Small headings, card titles |131| `text-2xl` | `text-heading-md` | Section headings |132| `text-3xl` | `text-heading-lg` | Page titles |133| `text-4xl`, `text-5xl` | `text-heading-xl` | Hero headings |134| `text-6xl`, `text-7xl`, `text-8xl`, `text-9xl` | `text-display` | Display/marketing headings |135| Inline `fontSize: '14px'` | `var(--text-body-sm)` |136| Inline `fontSize: '24px'` | `var(--text-heading-md)` |137138### Font Weight139140| Hardcoded | Semantic | Use Case |141|-----------|----------|----------|142| `font-extralight` (200) | `font-thin` | Decorative, display text |143| `font-light` (300) | `font-light` | Subtle body text |144| `font-normal` (400) | `font-normal` | Body text |145| `font-medium` (500) | `font-medium` | Emphasis, labels |146| `font-semibold` (600) | `font-semibold` | Subheadings |147| `font-bold` (700) | `font-bold` | Headings, CTAs |148| `font-extrabold` (800), `font-black` (900) | `font-heavy` | Display, marketing |149150### Line Height151152| Hardcoded | Semantic | Use Case |153|-----------|----------|----------|154| `leading-none` | `leading-none` | Display text, single-line |155| `leading-tight` | `leading-tight` | Headings |156| `leading-snug` | `leading-snug` | Subheadings |157| `leading-normal` | `leading-normal` | Body text |158| `leading-relaxed` | `leading-relaxed` | Long-form content |159| `leading-loose` | `leading-loose` | Legal, fine print |160161### Letter Spacing162163| Hardcoded | Semantic |164|-----------|----------|165| `tracking-tighter` | `tracking-heading` |166| `tracking-tight` | `tracking-heading` |167| `tracking-normal` | `tracking-body` |168| `tracking-wide` | `tracking-label` |169| `tracking-wider` | `tracking-label` |170| `tracking-widest` + `uppercase` | `tracking-overline` |171172### Composite Typography Patterns173174Match multi-class patterns before individual classes. Apply the first matching composite rule.175176| Hardcoded Pattern | Semantic |177|-------------------|----------|178| `text-6xl+ font-bold/extrabold` | `text-display` |179| `text-4xl font-bold tracking-tight` | `text-heading-xl` |180| `text-3xl font-semibold` | `text-title` |181| `text-2xl font-semibold` | `text-subtitle` |182| `text-lg font-medium` | `text-lead` |183| `text-base` | `text-body` |184| `text-sm text-gray-*` | `text-muted` |185| `text-xs uppercase tracking-wide` | `text-overline` |186| `text-xs font-medium` | `text-label` |187188---189190## Spacing Rules191192### Semantic Spacing Scale193194| Hardcoded | Semantic | Value |195|-----------|----------|-------|196| `p-1`, `m-1` | `space-xs` | 4px |197| `p-2`, `m-2` | `space-sm` | 8px |198| `p-3`, `m-3` | `space-md` | 12px |199| `p-4`, `m-4` | `space-lg` | 16px |200| `p-5`, `m-5` | `space-xl` | 20px |201| `p-6`, `m-6` | `space-2xl` | 24px |202| `p-8`, `m-8` | `space-3xl` | 32px |203| `p-10`, `m-10` | `space-4xl` | 40px |204| `p-12`, `m-12` | `space-5xl` | 48px |205206### Component Spacing Patterns207208| Context | Recommended Token |209|---------|-------------------|210| Button padding | `px-button py-button` or `p-4` |211| Card padding | `p-card` or `p-6` |212| Section padding | `p-section` or `py-12 px-6` |213| Input padding | `px-input py-input` or `px-4 py-2` |214| Gap between items | `gap-sm` (8px), `gap-md` (12px), `gap-lg` (16px) |215| Stack spacing | `space-y-sm`, `space-y-md`, `space-y-lg` |216217---218219## Sizing Rules220221### Width/Height222223| Hardcoded | Semantic | Use Case |224|-----------|----------|----------|225| `w-4 h-4` | `size-icon-xs` | Small icons |226| `w-5 h-5` | `size-icon-sm` | Default icons |227| `w-6 h-6` | `size-icon-md` | Medium icons |228| `w-8 h-8` | `size-icon-lg` | Large icons |229| `w-10 h-10` | `size-avatar-sm` | Small avatars |230| `w-12 h-12` | `size-avatar-md` | Medium avatars |231| `w-16 h-16` | `size-avatar-lg` | Large avatars |232| `h-10`, `h-11` | `h-input` | Input/button height |233| `max-w-sm` | `max-w-form` | Form container |234| `max-w-xl` | `max-w-content` | Content container |235| `max-w-5xl` | `max-w-page` | Page container |236237### Border Radius238239| Hardcoded | Semantic | Use Case |240|-----------|----------|----------|241| `rounded` | `rounded-sm` | Subtle rounding |242| `rounded-md` | `rounded-base` | Default rounding |243| `rounded-lg` | `rounded-lg` | Cards, modals |244| `rounded-xl` | `rounded-xl` | Large cards |245| `rounded-2xl` | `rounded-2xl` | Hero sections |246| `rounded-full` | `rounded-full` | Pills, avatars |247248---249250## Shadow Rules251252| Hardcoded | Semantic | Use Case |253|-----------|----------|----------|254| `shadow-sm` | `shadow-sm` | Subtle elevation |255| `shadow` | `shadow-base` | Default elevation |256| `shadow-md` | `shadow-md` | Cards |257| `shadow-lg` | `shadow-lg` | Modals, dropdowns |258| `shadow-xl` | `shadow-xl` | Popovers |259| `shadow-2xl` | `shadow-2xl` | Floating elements |260| `shadow-success` | `shadow-success` | Success glow |261| `shadow-error` | `shadow-error` | Error glow |262263---264265## Z-Index Rules266267| Hardcoded | Semantic | Use Case |268|-----------|----------|----------|269| `z-0` | `z-base` | Default layer |270| `z-10` | `z-dropdown` | Dropdowns |271| `z-20` | `z-sticky` | Sticky headers |272| `z-30` | `z-overlay` | Overlays |273| `z-40` | `z-modal` | Modals |274| `z-50` | `z-toast` | Toasts, tooltips |275276---277278## Inline Style Replacements279280| Hardcoded | Semantic |281|-----------|----------|282| `style={{ color: '#111827' }}` | `className="text-foreground"` |283| `style={{ color: '#6b7280' }}` | `className="text-muted-foreground"` |284| `style={{ backgroundColor: '#ffffff' }}` | `var(--color-background)` |285| `style={{ fontSize: '14px' }}` | `var(--text-body-sm)` |286| `style={{ fontWeight: 600 }}` | `className="font-semibold"` |287| `style={{ padding: '16px' }}` | `className="p-4"` or `var(--space-lg)` |288| `style={{ borderRadius: '8px' }}` | `var(--radius-base)` |289290---291292## Third-Party Config Pattern293294When a library requires specific values at initialization, use runtime CSS variable resolution:295296```js297function cssVar(name, fallback) {298 if (typeof window === 'undefined') return fallback;299 return getComputedStyle(document.documentElement)300 .getPropertyValue(name).trim() || fallback;301}302303// Usage: cssVar('--color-brand', '#F97316')304```305306Initialize in `useEffect` (not module level) so CSS variables are available.307308---309310## Scoped Token Pattern311312When a page has a fixed dark background that doesn't change with theme, use `var()` with inline fallback:313314```js315color: 'var(--status-text-muted, #a1a1aa)'316```317318---319320## Status Mapping321322| Status | Semantic |323|--------|----------|324| `DRAFT` | `muted` |325| `PENDING`, `SUBMITTED` | `warning` |326| `CONFIRMED`, `SUCCESS`, `COMPLETED`, `PAID` | `success` |327| `REJECTED`, `ERROR`, `CANCELLED` | `error` |328| `INFO`, `SENT`, `RECEIVED` | `info` |329330---331332## Available Tokens Reference333334### Colors335**Text:** `text-foreground`, `text-muted-foreground`, `text-primary`, `text-primary-foreground`, `text-brand`, `text-brand-foreground`, `text-accent`, `text-success`, `text-success-foreground`, `text-warning`, `text-warning-foreground`, `text-error`, `text-error-foreground`, `text-info`, `text-info-foreground`336337**Background:** `bg-background`, `bg-card`, `bg-muted`, `bg-primary`, `bg-brand`, `bg-accent`, `bg-success`, `bg-warning`, `bg-error`, `bg-info`, `bg-overlay`338339**Border:** `border-border`, `border-input`, `border-primary`, `border-brand`, `border-success`, `border-error`, `border-warning`, `border-info`340341**Ring:** `ring-primary`, `ring-success`, `ring-error`, `ring-info`342343**Shadow:** `shadow-success`, `shadow-error`, `shadow-info`344345**Misc:** `divide-border`, `placeholder-muted-foreground`346347### Typography348**Font Family:** `font-body`, `font-heading`, `font-mono`, `font-display`349350**Font Size:** `text-caption`, `text-body-sm`, `text-body`, `text-body-lg`, `text-heading-sm`, `text-heading-md`, `text-heading-lg`, `text-heading-xl`, `text-display`351352**Composite:** `text-title`, `text-subtitle`, `text-lead`, `text-muted`, `text-overline`, `text-label`353354**Font Weight:** `font-thin`, `font-light`, `font-normal`, `font-medium`, `font-semibold`, `font-bold`, `font-heavy`355356**Letter Spacing:** `tracking-heading`, `tracking-body`, `tracking-label`, `tracking-overline`357358**Line Height:** `leading-none`, `leading-tight`, `leading-snug`, `leading-normal`, `leading-relaxed`, `leading-loose`359360### Spacing361**Padding/Margin:** `space-xs`, `space-sm`, `space-md`, `space-lg`, `space-xl`, `space-2xl`, `space-3xl`, `space-4xl`, `space-5xl`362363**Component:** `p-card`, `p-section`, `p-input`, `px-button`, `py-button`364365**Gap:** `gap-xs`, `gap-sm`, `gap-md`, `gap-lg`, `gap-xl`366367**Stack:** `space-y-sm`, `space-y-md`, `space-y-lg`368369### Sizing370**Icons:** `size-icon-xs`, `size-icon-sm`, `size-icon-md`, `size-icon-lg`371372**Avatars:** `size-avatar-sm`, `size-avatar-md`, `size-avatar-lg`373374**Containers:** `max-w-form`, `max-w-content`, `max-w-page`375376**Input:** `h-input`377378### Effects379**Radius:** `rounded-sm`, `rounded-base`, `rounded-lg`, `rounded-xl`, `rounded-2xl`, `rounded-full`380381**Shadow:** `shadow-sm`, `shadow-base`, `shadow-md`, `shadow-lg`, `shadow-xl`, `shadow-2xl`382383**Z-Index:** `z-base`, `z-dropdown`, `z-sticky`, `z-overlay`, `z-modal`, `z-toast`384385---386387## Behavior388389For each `.tsx`, `.jsx`, `.ts`, `.js` file in the target path (skip excluded dirs):3903911. Read the file3922. Find hardcoded styles (colors, fonts, sizes, spacing)3933. Check if inside protected context (gradient/SVG-def/animation)3944. If safe → apply matching rule and edit immediately3955. If protected context → skip, log as `⚠ skipped`396397After all files are done, re-scan to verify zero remaining violations. Print summary.398399## Summary Format400401```402Semantic coding refactor: N files changed, M replacements403- file.tsx: colors (5), typography (3), spacing (2)404⚠ file.tsx:42 — skipped (gradient context)405⚠ file.tsx:88 — skipped (SVG defs)406```