Skip to main content
BuildOfficialCertifiedReviewed Jul 21, 2026

Css Token Sweep

Statically scan a CSS / single-file HTML / multi-file frontend project for references to undefined CSS custom properties — the silent class of bug where `color: var(--ink-2)` is written but `--ink-2` is never declared in any `:root { ....

v1.0.1New

Install this skill

No account required. Pick your tool, or use the command that detects it for you.

Run in your terminal. It detects your AI tool.

npx @skills-hub-ai/cli install css-token-sweep
Or get the file:
Browse all CLI commands →
Manual setup by platform

Claude Code

~/.claude/skills/css-token-sweep/SKILL.md

Setup guide →

Signing

SignedSLSA L2
Signed by
skills-hub.ai distributor
Method
Distributor-signed by skills-hub.aiSigned with the skills-hub.ai Ed25519 distributor key over this exact slug, version and content. Check it with `npx @skills-hub-ai/cli verify`.
Key
skills-hub-ed25519-2026-11
Signed
0Save

Instructions

css-token-sweep

Find every var(--name) in a project where --name is not defined in any
:root { ... } block. Surface tokens defined in default :root but
quietly inherited (not overridden) by theme variants. Optionally flag
hardcoded colors that duplicate an existing token's value.

This is the missing lint pass that most design-system codebases never
add. Without it, a typo like var(--ink-2) instead of var(--ink-soft)
renders text in the unset color (often invisible against a white button)
and ships to production unnoticed.

The skill bundles scripts/sweep.py — a zero-dependency Python scanner.
Most of the work is mechanical, so the script does it deterministically;
the skill body just orchestrates running it, interpreting the output, and
proposing fixes.


=== PRE-FLIGHT ===


Before running, verify:

  • A path was either passed in the slash-command args or there's an
    obvious project root in the current working directory.
  • python3 is on PATH (python3 --version).
  • The path contains at least one .css, .html, .htm, .jsx,
    .tsx, .vue, or .svelte file. If it doesn't, the scan has nothing
    to do — say so and exit.

Recovery:

  • No path given → default to the current working directory.
  • No CSS sources found → tell the user and exit; do not invent files.
  • Python missing → tell the user to install Python 3.8+ and stop.

=== PHASE 1: RUN THE SCANNER ===


Invoke the bundled scanner with the user's path (or .):

python3 ~/.claude/skills/css-token-sweep/scripts/sweep.py <PATH>

Useful flags:

FlagWhen to use
--strictWire into CI — exit 1 if any errors.
--skip-warningsFirst-pass triage; surface only the invisible-text errors.
--ignore=--dx,--dy,--rSuppress CSS custom properties that are set at runtime via JS (element.style.setProperty('--dx', '12px')). The static scanner cannot see runtime sets, so animation-param vars are false positives unless added here.
--jsonMachine-readable output for chaining into other tools or for the optional runtime-contrast follow-up below.

The scanner reports three findings:

  1. Errors — undefined var(--name) with no fallback. This is the
    canonical invisible-text bug. A var(--ink-2) reference where
    --ink-2 is defined nowhere falls back to the unset initial value;
    for color that is the unset paint color, which depending on context
    may render the text the same color as the background.

  2. Warnings — tokens defined in :root but not overridden in a
    [data-theme="..."] variant.
    Heuristic: only color-like tokens
    (anything whose name contains ink, surface, paper, bg,
    border, accent, text, etc.) are surfaced, because shape and
    shadow tokens often legitimately stay shared across themes. The
    warning is a prompt to confirm the default value still reads
    correctly under each variant, not an automatic fix.

  3. Warnings — hardcoded hex colors that duplicate a token's value.
    These are stylistic; the code works fine, but switching themes won't
    move them. Suggest replacing with var(--matching-token).

VALIDATION: scanner exits cleanly and prints either "Clean." or a
report with concrete file:line locations.
FALLBACK: if the scanner errors on a specific file (permissions, weird
encoding), note the file in the report and continue with the rest.


=== PHASE 2: INTERPRET AND FIX ===


For each error, the report includes a "Did you mean?" suggestion
based on edit distance to the closest defined token. Take that
suggestion seriously — in nine cases out of ten it is exactly the right
fix, because the bug pattern is almost always a typo / wrong tier name
(--ink-2 vs --ink-soft, --bg-muted vs --surface-muted, etc.).

Workflow:

  1. Read the file the scanner pointed at.
  2. Replace the bad var(--…) with the suggested token, or — if the
    suggestion is wrong — define the new token in :root (and in each
    theme variant).
  3. Re-run the scanner. The errors block should be empty.

For theme-variant warnings, do not blindly add overrides. Read each
warning, look at the component that uses the token, and decide whether
the default value actually reads correctly in that variant. Many
shadow / radius / motion tokens legitimately stay the same across
themes — only color tokens need variant-specific overrides.

For hardcoded-color warnings, replace in place. This usually takes
one sed pass per color.

VALIDATION: a second scanner run reports 0 errors.
FALLBACK: if you cannot resolve an error (e.g., the token genuinely
does not exist anywhere in any related file), surface it to the user
explicitly with a recommendation — either define the token or remove
the dead reference.


=== PHASE 3 (OPTIONAL): RUNTIME CONTRAST SWEEP ===


Static token-existence checks do not catch a token that exists but
resolves to an unreadable color under a given theme. If the project has
multiple data-theme variants and the user wants belt-and-suspenders
coverage, do a runtime sweep with Playwright:

// Pseudocode — adapt to the project's entry point.
for (const theme of ["light", "dark", "morning", "dusk"]) {
  await page.evaluate((t) => {
    document.documentElement.dataset.theme = t;
  }, theme);
  const lowContrast = await page.evaluate(() => {
    const out = [];
    const interactive = document.querySelectorAll(
      'button, a, input, [role="button"]',
    );
    for (const el of interactive) {
      const cs = getComputedStyle(el);
      const ratio = contrastRatio(cs.color, cs.backgroundColor);
      if (ratio < 3.0)
        out.push({ tag: el.tagName, text: el.textContent.slice(0, 40), ratio });
    }
    return out;
  });
  console.log(theme, lowContrast);
}

Only do this if (a) Playwright is already available in the environment
and (b) the project actually has multiple themes. Otherwise it is more
overhead than the static scan.

VALIDATION: each theme returns 0 low-contrast interactive elements, or
the user has reviewed and accepted any remaining hits.
FALLBACK: if Playwright is not available, document the gap in the final
report and stop. Do not try to install Playwright unprompted — the
static check already catches the highest-impact bugs.


=== SELF-REVIEW ===


Score the output (1–5):

  • Complete: Every undefined-var error has been resolved (or
    explicitly noted as needs-human-judgment)?
  • Robust: Did you account for runtime-set custom properties via
    --ignore? Did you skip false-positive warnings rather than apply
    noisy fixes?
  • Clean: Is the report concise enough that the user can act on it
    without reading the underlying CSS line by line?

If any score < 4:

  • Re-run with different flags to narrow the noise.
  • For genuinely ambiguous cases (the suggested token is wrong), flag
    the case to the user with the two or three candidate tokens rather
    than silently picking one.

=== LEARNINGS CAPTURE ===


After each run, append one entry to
~/.claude/skills/css-token-sweep/LEARNINGS.md:

## <YYYY-MM-DD> — <project name + scan scope>

- **What worked:** <specific suggestion that was correct, or a flag
  combo that produced an actionable report>
- **What was awkward:** <false positive that the scanner could have
  avoided, a missed bug, or a slow step>
- **Suggested patch:** <one concrete improvement — "auto-detect
  inline-style runtime vars and skip them", "add `--include` glob
  to scan only one subdirectory", etc.>
- **Verdict:** [Smooth / Minor friction / Major friction]

Anti-patterns this skill refuses

  • Inventing a token to "fix" the error. If var(--ink-2) is bad, fix
    the reference or genuinely add the token — do not silently leave the
    reference and pretend the bug went away.
  • Adding var(--name, fallback) everywhere as a workaround. Fallbacks
    hide real bugs and create theme inconsistency. Use them only for
    intentionally optional vars (e.g., user-customizable accents) and
    document the intent.
  • Disabling the scanner for a whole file with --ignore instead of
    fixing the underlying issue. --ignore is for runtime-set vars,
    not for silencing bugs.
  • Treating every theme-variant warning as a fix-required error. Many
    are intentional. Read each one and decide.
This skill doesn’t include stateful context yet, instructions only. Learn about stateful skills.

Security

Loading security scan...

Reviews (0)

Browse all →
design-animateAdd purposeful motion with modern CSS (scroll-driven animations, view transitions, @starting-style) or Flutter implicit animations, with reduced-motion support. Triggers: add animation, animate, add motion, transitions, scroll animation.80 installsdesign-auditRead-only design quality audit (WCAG 2.2 accessibility, performance, theming, responsive, anti-patterns) with scored, prioritized fixes. Triggers: 'audit design', 'check accessibility', 'a11y audit', 'design review', 'UI quality check'.63 installsdesign-polishFinal quality pass before shipping: fixes alignment, spacing, type hierarchy, color consistency, interactive states and motion timing to match the existing design language. Triggers: 'polish the UI', 'make it pixel perfect', 'final design pass'.57 installssecureRead-only full-stack security posture assessment with a 0-100 risk score: dependency CVEs, dangerous code patterns, auth gaps, config and secrets, PII handling; routes to deeper skills. Triggers: 'security posture', 'how secure is this', 'security scan', 'risk score'.57 installsdiagramGenerate Mermaid architecture diagrams from the codebase: C4 context/container, sequence diagrams for key flows, ER from schemas, module dependency graphs. Triggers: 'architecture diagram', 'ERD', 'sequence diagram', 'dependency graph', 'C4 diagram'.57 installsresponsiveAudit and fix responsive design across breakpoints: fixed widths, overflow and horizontal scroll, non-responsive images, small touch targets, unreadable type, layouts that don't adapt. Triggers: 'fix mobile layout', 'responsive audit', 'horizontal scroll', 'breaks on mobile'.50 installs

More from Skills Hub

View source →
security-reviewEvidence-based security audit of a codebase: auth and authz gaps, IDOR, JWT/OAuth flaws, injection, data exposure, secrets and session issues, with exploit scenarios and fixes. Triggers: security review, audit auth, find vulnerabilities.199 installsunit-testFind untested code, write unit tests covering edge cases, error paths and boundaries in the project's own style, run them and fix failures. Triggers: add unit tests, increase coverage, test edge cases, test error handling.168 installshumanizerRewrite AI-drafted content so it reads human: cut filler and hedging, vary sentence length, curb em dashes, add specifics and voice. Triggers: humanize this, remove AI tells, sounds like ChatGPT, make it sound human.138 installsweb-gameScaffold a production-ready browser game (Phaser, PixiJS or Three.js) with Vite, TypeScript, input, audio, saves, responsive canvas and itch.io/PWA deploy. Triggers: web game, browser game, html5 game, phaser game, pixi game, three.js game.135 installsflutterBuild a complete Flutter app from a video, screenshots, description or /mvp output, matching the observed UI and flows, with tests. Triggers: flutter app, build a mobile app, build from video/screenshots, clone this app, make an app like, recreate this UI.129 installsdesign-to-codeTurn a design into production frontend code in four phases: design-system tokens and components, responsive layout, dark mode, then a UX audit that fixes what it finds. Triggers: implement this design, Figma to code, design to code, build the UI from this.126 installs

More Build skills

Browse category →
senior-frontendBuild and review React, Next.js, TypeScript or Tailwind frontends: components, scaffolding, performance and bundle size. Use whenever the user wants a new component or app, a page feels slow, the bundle is too big, or asks for a frontend code review.646 installsui-design-systemUse when building a design system: tokens, component docs, responsive scales or developer handoff. Generates tokens with design_token_generator.py.549 installsfrontend-designGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.357 installssenior-backendBuild and fix backend services: REST or GraphQL APIs, auth, microservices, PostgreSQL queries, migrations and load tests. Use whenever the user's API is slow or broken, needs login or auth added, a schema change, or a new endpoint or service scaffolded.256 installsself-improving-agentCurate what the agent has learned into durable project knowledge. Reviews Claude Code auto-memory (MEMORY.md and its topic files) for learnings worth keeping, promotes proven ones into CLAUDE.md or .claude/rules/, records a correction as a lesson that persists across sessions, prunes stale or duplicate entries, and turns a recurring fix into a reusable skill. Use whenever the user asks what you have learned or saved about the project, which memories should become permanent rules, to remember a lesson or stop repeating a mistake, or to clean up, audit or check memory health.183 installsusing-superpowersUse when starting any conversation - establishes how to find and use skills, requiring skill invocation before ANY response including clarifying questions147 installs

Frequently asked questions about css-token-sweep

What does the css-token-sweep skill do?

Statically scan a CSS / single-file HTML / multi-file frontend project for references to undefined CSS custom properties — the silent class of bug where `color: var(--ink-2)` is written but `--ink-2` is never declared in any `:root { .... It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.

How do I install the css-token-sweep skill?

Run `npx @skills-hub-ai/cli install css-token-sweep` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/css-token-sweep/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.

Which AI tools does css-token-sweep work with?

css-token-sweep runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.

Is the css-token-sweep skill free?

Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.

How do I use css-token-sweep after installing it?

In Claude Code, type `/css-token-sweep` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.

Can I share the css-token-sweep skill with my team?

Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.