Skip to content
FramesField
SKILL.md Developer / Local Tooling SKILL.md
Verified Nov 30, 2026

CSS Design Tokens and Tailwind v4 Theme Skill

How to install this SKILL.md

Install into .claude/skills/, .cursor/skills/, or .agents/skills/ so your coding agent writes strict semantic Tailwind v4 utilities instead of inventing hardcoded #hex classes.

Installable SKILL.md teaching Claude Code, Cursor, and Codex to enforce a 3-tier semantic design token cascade (Primitives -> Semantic CSS Variables -> Tailwind CSS v4 @theme inline), ban arbitrary raw hex utilities in component markup, guarantee 1-block light/dark parity, and check WCAG AA contrast.

Compatible agent hosts
Claude Code Cursor Codex
Target tool: Tailwind CSS v4 / Figma Variables · License: MIT
  1. STEP 01
    Install the Tailwind v4 Token skill

    Pick Claude Code, Cursor, or Codex below to save SKILL.md directly from /raw/skills/.

  2. STEP 02
    Map Figma Variables or existing colors once

    Your agent creates a clean 3-tier :root + [data-theme='dark'] + @theme inline contract.

  3. STEP 03
    Audit every PR for zero hardcoded hex leaks

    Components use strictly semantic classes (bg-canvas, text-ink, border-hairline) verified via grep.

1. Install for your tool

Pick the app you use below for the exact verified command or config—zero manual guessing.

Direct raw file (SKILL.md) ↓
Claude Code (.claude/skills/) bash
Installs into .claude/skills/design-tokens-tailwind-v4/SKILL.md for clean design-system codegen.
mkdir -p .claude/skills/design-tokens-tailwind-v4
curl -fsSL https://framesfield.com/raw/skills/design-tokens-tailwind-v4-skill -o .claude/skills/design-tokens-tailwind-v4/SKILL.md

2. Inspect or download the full SKILL.md file

This is the exact raw file served at /raw/skills/design-tokens-tailwind-v4-skill.

CSS Design Tokens and Tailwind v4 Theme Skill SKILL.md
---
name: design-tokens-tailwind-v4
description: Architect and enforce a 3-tier semantic CSS design token system (Primitives -> Semantic Custom Properties -> Tailwind CSS v4 @theme inline) synced with Figma Variables, banning arbitrary hardcoded hex utilities, enabling single-block light/dark mode parity, and verifying WCAG 2.1 AA contrast.
---

# CSS Design Tokens & Tailwind CSS v4 Architecture Protocol

Whenever scaffolding styles, migrating from Tailwind v3/raw CSS, or translating Figma MCP components into code, strictly enforce this 3-tier token contract:

## 1. Strict 3-Tier Cascade (`src/styles/tokens.css`)
Never mix raw palette hex codes directly into components or static `@theme` blocks. Separate three explicit tiers:
```css
/* Tier 1: Primitive Palette (raw values only — NEVER used in JSX/Astro) */
:root {
  --raw-stone-50: #F7F7F5;
  --raw-white: #FFFFFF;
  --raw-stone-100: #F1F1ED;
  --raw-stone-200: #E4E4DF;
  --raw-stone-300: #C9C9C1;
  --raw-stone-600: #575754;
  --raw-stone-950: #111111;
  --raw-signal-600: #E04420;

  /* Tier 2: Semantic Roles (1:1 parity with Figma Variable names) */
  --surface-canvas: var(--raw-stone-50);
  --surface-card: var(--raw-white);
  --surface-subtle: var(--raw-stone-100);
  --border-hairline: var(--raw-stone-200);
  --border-strong: var(--raw-stone-300);
  --ink-primary: var(--raw-stone-950);
  --ink-muted: var(--raw-stone-600);
  --accent-signal: var(--raw-signal-600);
  --accent-signal-ink: var(--raw-white);
}

/* Single-block Dark Mode override — zero dark:* utility clutter in markup */
[data-theme="dark"] {
  --surface-canvas: #0F0F0E;
  --surface-card: #181817;
  --surface-subtle: #222220;
  --border-hairline: #2B2B28;
  --border-strong: #3E3E39;
  --ink-primary: #F5F5F2;
  --ink-muted: #A8A8A2;
  --accent-signal: #FF5B36;
  --accent-signal-ink: #111111;
}

/* Tier 3: Tailwind CSS v4 @theme inline binding */
@theme inline {
  --color-canvas: var(--surface-canvas);
  --color-surface: var(--surface-card);
  --color-surface-subtle: var(--surface-subtle);
  --color-hairline: var(--border-hairline);
  --color-hairline-strong: var(--border-strong);
  --color-ink: var(--ink-primary);
  --color-ink-muted: var(--ink-muted);
  --color-signal: var(--accent-signal);
  --color-signal-ink: var(--accent-signal-ink);
}
```

## 2. Hard Component Markup Rules
- **Ban raw hex utilities:** Reject `bg-[#...]`, `text-[#...]`, `border-[#...]`, and inline `style="color: #..."` inside `src/components/` and `src/pages/`. Always map to semantic classes (`bg-canvas`, `bg-surface`, `text-ink`, `text-ink-muted`, `border-hairline`, `text-signal`).
- **Ban decorative AI slop:** Never inject unrequested neon radial glows, purple/cyan gradient blobs, glassmorphic `backdrop-blur` cards, or gratuitous floating shadows unless explicitly required by the Figma design system.
- **Guarantee keyboard focus & readability:** Every interactive control must show a visible `:focus-visible` ring (`outline-2 outline-offset-2 outline-signal`), body prose must use comfortable measure (`max-w-[66ch]`), and muted foreground text must achieve **WCAG 2.1 AA (`>= 4.5:1`)** against both `--surface-canvas` and `--surface-card`.

## 3. Mandatory Pre-Commit Token Leak Check
Before completing any UI task, run:
```bash
grep -rnE '(bg|text|border|fill|stroke)-\[#[0-9a-fA-F]{3,8}\]' src/components src/pages || echo "PASS: 0 hardcoded hex classes"
```

3. Test it right away (sample prompt & result)

Sample prompt / input
"Migrate our hardcoded Tailwind colors in src/components/PricingCard.astro and src/styles/global.css to a clean Tailwind v4 @theme inline token architecture with dark mode parity."
What happens when it runs
- Extracts 14 raw hex classes into a 3-tier tokens.css block with light and [data-theme="dark"] semantic variables.
- Rewrites PricingCard.astro using exclusively bg-surface, border-hairline, text-ink, text-ink-muted, and bg-signal/text-signal-ink.
- Runs grep leak check confirming 0 arbitrary hex utilities remain and confirms WCAG AA contrast across light and dark pairs.

What you need & known limits

Requirements

  • Tailwind CSS v4 (@import 'tailwindcss';)
  • Claude Code, Cursor, or Codex

Watch out for

  • Use @theme inline (not plain @theme) whenever referencing var(--...) custom properties so dark-mode overrides stay dynamic at runtime
  • Always visually test both light and dark modes via Playwright MCP after changing surface or border tokens

Frequently Asked Questions

What happens if I omit the inline keyword from @theme in Tailwind CSS v4?
Plain @theme resolves variables statically at build time in some contexts, whereas @theme inline preserves the CSS custom property reference directly in the compiled utility class so runtime theme switches via [data-theme='dark'] work cleanly.
Can this skill coexist with Figma MCP?
Yes—it is designed specifically to pair with Skill 03 (Figma MCP). Naming your Tier 2 CSS custom properties to match your Figma Variable collection names lets coding agents bind exact tokens on Pass 1.
Use this page in AI tools or notes
raw .md