Your agent invented 14 shades of blue: auditing AI-generated design tokens

AI coding agents love inventing tokens: bgPrimaryBlue, color-blue-1, primary_hover_2. Here's a 15-minute audit that catches naming chaos, missing semantics, and accessibility failures before they fossilize in your codebase.

Published

Updated

Read time

4 min

Cover for 'Auditing AI-generated design tokens': the headline 14 shades of blue, with chips for five audit checks, WCAG AA contrast at 4.5 to 1, and zero raw values

Ask an agent to "build the settings page" and it will. It will also invent bgPrimaryBlue, color-blue-1, and primary_hover_2, three names for the same hex value, none of them in your token system. Multiply by every AI-assisted PR and your design tokens quietly become a junk drawer.

The fix isn't banning agents from touching styles. It's a 15-minute audit you run before the chaos fossilizes.

The audit

Pull your token file (JSON, CSS variables, Tailwind config, whatever you use) and check five things:

1. Raw values in components

Search your components for raw hex, rgb, and pixel values that should be tokens. Every hit is a token the agent invented instead of reusing.

# hex colors hiding in component files
rg -g '*.tsx' -g '!*.test.*' '#[0-9a-fA-F]{3,8}\b' components/ | grep -v 'token'

Zero is the target. Anything above zero is a fix-or-token decision.

2. Two names, one value

Dump every token value and look for duplicates. #2563eb called primary in one file and brand-blue in another means the agent couldn't find the existing token, which usually means your naming is undiscoverable, not that the agent is lazy.

3. Mixed casing, mixed conventions

bgPrimaryBlue next to color.background.primary next to BLUE_500. Pick one convention (we like category.property.variant, all lowercase, dot-separated) and normalize. Agents copy the patterns they see, mixed conventions in, mixed conventions out.

4. Missing states

Agents generate the happy path: default, maybe hover. Audit for the states they skip:

  • disabled and focus-visible variants
  • Error/destructive tokens (not just success)
  • Dark mode values, if you support it

A token system without disabled states isn't a system; it's a demo.

5. Contrast ratios

Run your text/background pairs against WCAG AA (4.5:1 for body text). Agents pick colors that look right in the mockup and fail in the audit. This is the one machines are actually good at checking; automate it and never think about it again.

The five-check design token audit: raw values in components, two names for one value, mixed conventions, missing states, and contrast ratios against WCAG AA

What a first audit usually finds

Run this on a codebase that has had a few months of AI-assisted development and the findings repeat so reliably you can almost score them in advance.

The primary color has a family. There's the real brand.primary, plus a halo of near-duplicates: primary-blue, blue-primary, btn-bg, each a slightly different hex because each was eyeballed from a screenshot instead of looked up. These are the duplicates from step 2, and they concentrate exactly where the design system matters most.

Spacing is a junk drawer. Padding values of 13px, 18px, and 22px next to a scale that supposedly goes in steps of 4. Agents asked to "add some breathing room" invent a number instead of finding the scale, and every invented number becomes permanent the moment it merges.

The dark mode tokens are a rumor. Roughly half the tokens have dark values; the other half were never given any, so dark mode is a patchwork of correct tokens and raw light-mode leftovers. The audit finds this in minutes. Users find it in the app store reviews.

Focus states exist on buttons, nowhere else. The agent styled what the design showed. Links, inputs, and custom controls got nothing, because the mockup never showed a keyboard user.

None of these are agent failures, exactly. They're discoverability failures: the agent used what it could find, and what it could find was inconsistent. That's why the fix order matters. Clean the token file first, name things the way a newcomer would search for them, and the agent's next ten PRs get better without a single prompt change. The audit isn't just cleanup; it's how you make the canonical thing the easiest thing to find.

One more finding worth naming, because it predicts the rest: the token file itself is undocumented. No header comment saying what belongs there, no examples of the naming convention in use, no note about which values are legacy. Agents read that file before they write styles, and a file with no stated rules gets treated as a suggestion box. The cheapest fix in this entire article is ten lines of comments at the top of the token file: the naming convention, the rule against raw values, and a pointer to this audit. It will not stop a human determined to paste a hex code. It reliably stops an agent, because the agent was looking for instructions and finally found some.

Make it stick

The audit is a one-time cleanup. The system that prevents the next mess:

  • A tokens file agents can read. One canonical file, documented at the top: "use these, invent nothing."
  • A lint rule, not a guideline. Stylelint or ESLint plugin that fails the build on raw values in components. Agents respect CI; they ignore wikis.
  • The audit in CI. Steps 1–3 are scriptable. Run them on every PR and the junk drawer never refills.

Design tokens are a contract between design intent and code reality. Agents don't break that contract out of malice, they break it because nobody showed them the contract. Show them, then enforce it.

Share this article

Newsletter

The NotVibesCoded Weekly

One email a week: the newest articles, project teardowns and AI-coding notes. No slop, no spam, unsubscribe anytime.

We will send a confirmation email. Click the link in it to finish subscribing.

Written by

NotVibesCoded Editorial Team

NotVibesCoded is written and reviewed by its editorial team under the standards in the editorial policy. A named author page, with full credentials, replaces this placeholder shortly.

More about the author

Related

Projects mentioned

AI Engineering

Claude Code logoClaude Code

Anthropic's agentic coding tool that works in your terminal.

Claude Code brought the agent loop to the command line: it reads your codebase, plans changes, runs commands, and iterates, with you directing, not typing. The reference implementation of terminal-native AI engineering.

TypeScript
Developer Tools

Aider logoAider

AI pair programming in your terminal, open source.

Aider is the open-source terminal chatbot for code: pair it with any frontier model, point it at your git repo, and it edits files with proper diffs and commit messages. The hacker's choice for agentic coding.

Python
Developer Tools

Zed logoZed

A next-generation code editor built for high-performance collaboration.

From the team behind Atom, Zed is a Rust editor that treats latency as a bug: GPU-rendered UI, multiplayer editing via CRDTs, and deep AI integration that doesn't get in the way.

Rust

Related

Related articles