Home

Building an agentic design system

Contracts that stop coding agents drifting.

somesh-ks/singularityfm-design-system

  • One gate command that fails on drift
  • Three token tiers in W3C DTCG
  • Contracts in AGENTS.md
Role
Designer and engineer, solo
Timeline
Built alongside the Singularity app
Problem
Agents treat a design system as suggestions and ship off-system values.
Stack
W3C design tokens, TypeScript, React, CI

@singularityfm/design-system runs the Singularity app. Agents write most of its code and I review it. That showed me a design system built for people does not survive an agent.

The live style guide shows the components. This page is about what keeps an agent on the system.

Why agents drift

  • Agents chase the screenshot. If a raw #3B82F6 looks closer than --color-interactive, they use the hex.
  • Docs are advice. A Storybook note carries as much weight as a random answer online.
  • Drift compounds. One off-grid value becomes the example the next agent copies.

Design engineering, this week

12 stories · 18 min listen

Play briefingSave

Design engineering, this week

12 stories · 18 min listen

Play briefingSave
From a screenshotThrough the gate
Drag the handle, or focus it and use the arrow keys.

Contracts, not docs

Each package has an AGENTS.md that reads like a contract: what an agent may import, which token does which job, and what it must never do. Agents follow rules they can check. "Spacing comes from --space-*" is checkable. "Visual harmony" is not.

Tokens are the only values

Tokens come in three DTCG tiers: primitive (sand.600), semantic (text.secondary) and component (button.bg). Components never read primitives. So there is one right answer for "secondary text colour", and an agent can search for it.

One gate, run by everyone

pnpm run gate runs types, lint, token lint and contrast checks. Every AGENTS.md ends with it, and CI runs the same command. The token lint fails on raw colours, off-scale spacing and primitives in components. The contrast check fails any pair that breaks WCAG 2.2 AA.

The same card, built from a screenshot and built through the gate:

Which agent built it

Design engineering, this week

12 stories · 18 min listen

Play briefingSave
background: #FAFAF9; /* raw colour */
padding: 13px 15px; /* off the 4px scale */
border-radius: 7px; /* not a radius token */
gap: 10px; /* off the 4px scale */
color: #3B82F6; /* raw colour, fails 4.5:1 on white */

pnpm run gatefailed with 5 token violations

What changed

Review got faster. Wrong greys and wrong gaps stopped reaching me, so review became about the design itself. The system also got smaller: when every value must be a token, unused tokens stand out.

Looking back

  • A strict gate slows exploration. I turn it off for throwaway prototypes.
  • When a rule changes, AGENTS.md changes in the same commit.

The top gate failure: gap: 12px. That's what --space-3 is for.