Thoughts

Thoughts

My trial and error making a design system legible for agents

Jun 2026 · 6 min read
Design SystemsAI WorkflowClaude
A design system agents can read: guessed hex colors next to a clean DSYS folder

Designers, PMs and engineers on my team now describe what they want in plain language and get working UI back. I use Claude Code and Cursor daily and pushed the team to do the same. When everyone is building, the design system is what keeps the product from looking like five different apps.

First try: pointing Claude at Figma

Once the Claude Code and Figma MCP integration shipped (and before that, with a custom MCP from the designer community), I gave the agent our Figma DSYS file and told it to reference it when building prototypes.

It mostly worked. But every task started with the agent pulling and reading the entire Figma file. Token costs climbed and sessions slowed down. Burning that much context to fix one color felt absurd. I went from free, to pro, and ultimately to max. (I need something in between pro and max, but what can I do.)

That's context bloat. Everything the agent reads stays in its context window for the rest of the session: the whole Figma file, every earlier message, every file it opened along the way. The window is finite. The more it holds, the less room is left for the actual task, and the easier it is for a rule read an hour ago to get lost in the pile. Loading an entire design file to answer a question about one color is about the worst case.

Then the same mistake, every session

Our green slate color kept showing up on an alert message. Green slate is for AI-generated responses only. I corrected it, and the next session made the same mistake. I corrected it again, explained the rule in the prompt, added more context. The agent got it right for that session and forgot it in the next.

Every new session starts with zero memory of earlier decisions. The agent doesn't know it misused green slate last week, so it makes reasonable guesses, and 200 reasonable guesses don't add up to a consistent system.

What explained it

I learned everything here from Hardik Pandya's article Expose your design system to LLMs. It named the problem. Agents fabricate values, drift within a session and lose all context between sessions. My design system was built for humans to read. Agents need structured local files they can check at the start of every session without eating the context window.

What I built

The design system now lives in a /DSYS folder at the project root:

DSYS/
  DESIGN-SYSTEM.md        ← master reference, always read first
  tokens.md               ← flat token quick-reference
  foundations/            ← color, typography, spacing, motion
  components/             ← one .md per component
  patterns/               ← layout and interaction rules

Splitting it up is what fixes the bloat. For a button change, the agent reads the master file and the button spec, and nothing else. The rest of the system stays on disk until a task needs it.

Every design value in the codebase has a named token that maps straight to a Tailwind class, and nothing is hard-coded. DSYS/tokens.md lists every token with its hex value and utility class. To find the primary text color, the agent reads one plain markdown file and gets one answer.

Each component has its own spec in DSYS/components/, always in the same eight sections: metadata, overview, anatomy, props, variants, states, usage rules and code examples. Anatomy uses ASCII diagrams so the agent sees the nesting without parsing code. Usage rules list what not to do, which heads off the most common mistakes.

CLAUDE.md, which Claude Code reads at the start of every session, sets the rules once:

  • Read DSYS/DESIGN-SYSTEM.md and the relevant component spec before any UI work
  • Run the design audit script before every commit
  • When building a new component, also create DSYS/components/<name>.md
  • When modifying a component, update the spec and sync Figma

I don't repeat these in prompts anymore.

The last piece is a commit gate. scripts/design-audit.js scans every .tsx, .ts and .css file for raw hex colors or pixel values that should be tokens, and reports the file, the line and the class to use instead. A pre-commit hook runs it on every git commit and blocks the commit until it passes. The hook installs with npm install, so a collaborator who clones the repo can't skip it by accident.

Figma still matters. The MD files are the implementation contract: what shipped and what the audit enforces. Figma is where new screens get explored and stakeholders review. When a component gets a new state or variant, both get updated in the same pass, and Claude reminds you at the end of every component change.

What changed

Green slate's rule is now written down: AI-generated response containers only. The agent reads it and the audit catches violations.

A contributor with no design background can build a new screen and get code a designer would recognize, because the system is readable by the tool doing the work. I no longer enforce consistency through reviews and repeated prompts. It took me a while to see that agents needed the design system in a different format than the one I built it in.

Keep it clean

Figma hygiene is a thing, and so is LLM hygiene. The information hierarchy, and how the agent finds and recalls components and files, matters just as much as what's in them. Keep the files clean and don't let them go stale. My advice is to build a couple of skills that keep this system tidy for you. (Cough cough, that's the next article.)

Copy editing by Claude Sonnet 5. hehe~

Resources

Expose your design system to LLMs by Hardik Pandya. Everything in this post, I learned from it.

Also on Medium.

Keep reading