
Ask AI to build five screens, get five design languages. Different grays, three button styles, random border radii. Each screen looks fine alone. Together, a mess.
Problem isn’t the model. No constraints given, so it guesses every time. DESIGN.md fixes that: one file, your visual rules, AI reads before generating.
What DESIGN.md Actually Is
Plain markdown in the repo root. A style guide written for machines: tokens (colors, type, spacing), component rules, dark mode behavior, things to never do. AI agents (Claude Code, Cursor, OpenCode) pick up root markdown as context automatically — same way they read AGENTS.md.
Think of it like this: AGENTS.md tells AI how to work, DESIGN.md tells AI how things should look.
Why AI Output Drifts Without It
Every generation starts from scratch. The model picks whatever gray feels right in that moment. Nothing remembers what the last screen chose. A human designer carries the system in their head; AI carries nothing between prompts.
So drift isn’t a bug, it’s the default. The only fix is writing the system down somewhere AI can read it.
What Goes Inside
Four sections handle most of it. Keep each tight — AI follows short, specific rules better than long essays.
1. Tokens
Exact values, no vibes. Colors as hex, spacing as scale, radii as named steps:
## Tokens
- Colors: bg `#FAFAF9` (stone-50), text `#44403C` (stone-700),
headings `#1C1917` (stone-900), borders `stone-950/20`.
- Dark mode: bg `#0C0A09` (stone-950), text `#A8A29E` (stone-400).
- Font: monospace everywhere — JetBrains Mono, Fira Code fallback.
- Spacing: section padding `py-16 px-20`, gaps `gap-5`.
- Radius: cards `rounded-lg`, pills `rounded-full`. Nothing else.
Real values beat adjectives. “Subtle border” means five things to five generations. stone-950/20 means one thing.
2. Component Rules
How the pieces you build over and over should behave. Buttons, cards, headers — whatever AI generates often:
## Components
- Buttons: solid stone-900 bg, underline links with 4px offset.
No gradients, no shadows, no glow effects.
- Cards: flat, 1px border, `rounded-lg`. No drop shadows.
- Section titles: bold, stone-900, never centered.
- Code blocks: `rounded-lg`, mono font, `text-sm`.
Each rule like this kills off a whole category of drift. “No gradients” alone prevents half the AI-slop look.
3. Dark Mode
AI loves forgetting dark mode exists. State the rule explicitly:
## Dark Mode
- Every screen ships both modes. No exceptions.
- Dark isn't inverted light — text stone-400 on stone-950,
borders stone-50/16, selection lime-950.
- Check contrast in both before calling it done.
4. Don’t List
Telling AI what not to do works better than you’d expect. Left alone, models fall back on decorative habits — gradients, emojis, purple-blue everything — unless told otherwise:
## Never
- No gradients, glassmorphism, or drop shadows.
- No emojis as icons. Use the icon set.
- No new colors outside the tokens above.
- No centered body text. Left align.
Full Minimal Example
Whole file fits on one screen. That’s the point — if it’s long, nobody (human or AI) reads it:
# DESIGN.md
Visual system for this site. Follow on every UI change.
## Tokens
- Light: bg stone-50, text stone-600, headings stone-900.
- Dark: bg stone-950, text stone-400, headings stone-100.
- Borders: stone-950/20 light, stone-50/16 dark.
- Font: mono everywhere. Body 15px, line-height 2.
## Components
- Cards: flat, 1px border, rounded-lg. No shadows.
- Links: underline, 4px offset, 1px thick.
- Section layout: `flex flex-col gap-5 py-16`.
## Dark Mode
- Ship both modes every time. Dark text stone-400 on stone-950.
## Never
- No gradients, shadows, glassmorphism, or emojis as icons.
Making AI Actually Follow It
Just having the file isn’t enough. Three habits make it stick:
- Point at it in the prompt. “Build a pricing section following DESIGN.md” beats hoping context includes it.
- Keep it current. When a new pattern emerges, add it to the file. A stale guide goes bad fast — and AI follows old rules literally.
- Review visually, not just code. AI can satisfy every token and still produce ugly spacing. Screenshot the result, compare it against existing screens.
For repo-level workflow rules (commands, branch habits), that lives in AGENTS.md — separate file, separate job.
Final Thoughts
DESIGN.md isn’t documentation for humans. It’s constraints for a generator with no memory. Tokens stop the guessing. Component rules stop AI from reinventing your buttons every run. And the don’t-list stops the default decoration habits — gradients, glow, emoji icons.
One page, exact values, updated whenever the design moves. No prompt engineering needed, just rules written down where the model can see them.