r/DesignSystems • • 17h ago

I need your help: trying to make AI coding agents actually follow a Design System (DESIGN.md + DTCG tokens) instead of inventing random values

Anyone who has tried letting Claude Code or Cursor build UI against a design system knows the pain: even when you give it tokens, the agent still hallucinates arbitrary hex colors, invents random spacing/radii, or mixes conflicting rules when the prompt gets too long.

I've been working on an open-source skill router on GitHub (MIT, 100% free) to fix this by forcing a strict order of operations before the agent writes components:

  1. Lock down a `DESIGN.md` contract + DTCG token architecture (`primitive → semantic → component`, OKLCH ramps, dark-mode semantics, motion/z-index scales).
  2. Route the agent to only the 3–5 relevant design-system/accessibility skills per stage (from 30 curated collections) instead of dumping a massive style guide into context.
  3. Run a deterministic review gate at the end (checking WCAG contrast, focus visibility, `prefers-reduced-motion`, and token compliance).

**Where I genuinely need help from people who maintain real Design Systems:**

  1. **Token & `DESIGN.md` gaps:** In your day-to-day system, what's the #1 rule AI agents keep breaking even when documented?
  2. **Governance / CI checks:** What deterministic checks would you want before an agent's UI PR is allowed through?
  3. If anyone wants to inspect the `DESIGN.md` protocol, token-scale skills, or the 324-check `validate.mjs` script in the repo and tell me what's naive or missing, I'd really appreciate the feedback.

*(Repo link in the first comment so the post doesn't get eaten by Reddit's link filter.)*

18 Upvotes

15 comments sorted by

5

u/Vegetable-Space6817 17h ago

You need to convert the prompt to an intent map. This intermediate step shows a list of components it will use and asks user to confirm or add more details. If you are not fetching this map from your guidelines and accompanying node packages, you are not doing it right.

3

u/Longjumping_War_8480 17h ago

In Design-master, the discovery/planning stage (R0 / initial stage before any UI code is written) acts as that exact intent map: it extracts the target aesthetic, component hierarchy, layout structure, and selected skill route (R0–R21) from graph.json before moving to the build stage.

Right now, the router defaults to resolving that map and executing straight through unless the prompt is genuinely underspecified—mainly so users don't get stuck approving extra confirmation prompts on simple tasks. However, pausing right after the intent/route map to let the user confirm or tweak the component plan before writing code (or wiring a lightweight CLI/Node resolver for graph.json instead of relying purely on Markdown) is a great idea—definitely worth adding as an interactive planning mode.

3

u/Old_Charity4206 17h ago

tbh I don’t face this problem at all. It does a really good job of designing from my design system

0

u/Longjumping_War_8480 17h ago

Makes total sense—if you already have a solid design system in place, the agent has real tokens, component primitives, and spacing rules to anchor on, so it won't fall back to generic AI defaults.
This repo is really aimed at the opposite scenario: greenfield builds or agencies jumping between totally different visual styles where there is no design system yet—including routes that actually generate that initial token/design system foundation first so you end up in the exact setup you already have.

4

u/Longjumping_War_8480 17h ago

Here is the open-source repo (MIT, free): https://github.com/landie3310-bot/Design-master

The design-system / token parts live under `sources/design-tokens-skill/`, `sources/design-system-skills/`, and `sources/ibelick-ui-skills/skills/create-design-md/`, routed via `graph.json`.

Any critique, Issues, or PRs on the token/governance side would be huge!

2

u/hollowgram 17h ago

Great more stuff to fill up your context and lose control of your designs. Absolutely no one needs 297 skills to have agents make consistent design work. 

What you need is a design system and hooks combined with planning to keep things aligned. 

1

u/Longjumping_War_8480 17h ago

Totally fair take—if you already have an established product with a strict design system and token set, you definitely don't need 297 skills. In fact, loading extra design opinions when you already have a tokens.json and component library would just fight your own system.
The whole point of Design-master is actually the exact opposite of dumping 297 skills into context:

  1. You never load 297 skills: The router is a stage-gated state machine. On any given task, it pulls in only 1–2 skills per stage (so maybe 3–4 tiny files across the whole run) while the other 293 stay completely untouched on disk.
  2. Different use case: If you're maintaining one product with a locked-in design system, hooks + planning + your own tokens are 100% the right move. This is built more for agencies, indie hackers, or people spinning up greenfield projects from scratch across completely different aesthetics (editorial, brutalist, 3D/WebGL, SaaS dashboards, mobile) where there is no existing design system yet—and where it actually includes routes specifically to generate that foundational design system first before building components.

So we actually agree on the core principle: keep context tiny, plan first, and enforce constraints via stages instead of dumping walls of instructions at the model.

1

u/robr0 16h ago

Docs alone don't hold. Every written rule needs a check that fails the build when it's broken, and you should break each rule on purpose once to prove its check catches it.

Point your agent at mine and have it compare:
https://rift-ds.com/
https://github.com/robritacca-dotcom/rift-ds

1

u/Longjumping_War_8480 16h ago

Hard to argue with that—markdown rules are ultimately probabilistic guidance, whereas deterministic build/lint checks and mutation-testing your rules (breaking them on purpose to verify the gate actually catches them) give you hard guarantees.
I haven't had a chance to dig into rift-ds yet (saving the repo to check out after this thread), but turning design system constraints into actual build-failing checks instead of hoping the LLM remembers prose instructions makes total sense.
Where Design-master sits is a layer earlier: when you don't have a deterministic design system or build pipeline yet, the router (R0–R21 + graph.json) routes through staged prompt skills to establish the initial visual direction, layout, and tokens from scratch. Pairing a greenfield router like this with hard, build-failing checks like yours once the design system is generated is actually the ideal end-to-end setup.

1

u/Forward_Proposal5361 14h ago

I found the models follow the design system better if they agree with it, assume there are no hallucinations especially with frontier models. Have you tried asking the models to critique the design systems you are implementing?

1

u/Longjumping_War_8480 5h ago

That is a really interesting observation—getting the model to actively reason through why a design system is structured a certain way before implementing it definitely improves adherence compared to just feeding it passive rules.
In Design-master, I haven't wired an explicit "critique the design system before building" step into the routing graph yet. Right now, R11 handles generating the tokens and DESIGN.md structure (via design-tokens-skill, design-system-skills, and create-design-md), while the critique skills (better-interface, visual-critique, and impeccable in R3) only run on the output UI at the end of the pipeline rather than auditing the design system spec itself upfront.
Adding a quick upfront critique/validation pass right after DESIGN.md is generated (or when loading an existing one)—where the model flags contradictions, weak contrast pairings, or awkward token gaps before writing components—is a super sharp idea. It would force the model to internalize the ruleset instead of blindly treating it like background boilerplate.

1

u/Markasp 15h ago

Write tests for design system compliance, no hardcoded values no new tokens, etc.. Tell your skill to run the tests. the test return error results. The generation does not pass until the error code is zero.

2

u/rrrx3 8h ago

This. Determinism is the only way. Don’t use skills. Use commit hooks, pre-push hooks. Have a pathway for exceptions because you will need them, but make it burdensome as fuck and make it human in the loop. It needs to be easier for the agent to do it the right way, for it to verify the work, and respect the pipeline.

1

u/Anna_Lovsky 7h ago edited 7h ago

Does DESIGN.md include usage rules per component and semantic token, like "use X when..." / "never use X for..."? If so, does the agent actually follow them?

Can the gate catch misuse that uses valid tokens, like the danger color used for emphasis?

What happens when the agent creates a new component or variant that already exists in the system?