DESIGN.md with Cursor

Learn about AI Coding Agents and DESIGN.md
On this page

Cursor doesn't read DESIGN.md automatically. Add a rule in .cursor/rules (or reference it from AGENTS.md) that instructs Cursor to load DESIGN.md before UI work. The rule plus the file give Cursor persistent design context across sessions.

The setup takes five minutes. What takes judgment is writing the rule so Cursor actually complies, and knowing what to check when it still invents an off-brand blue. Both are covered below.

Quick refresher on the format itself: DESIGN.md is an open-source file format from Google that stores a complete design system in a single Markdown file: machine-readable design tokens (colors, typography, spacing, components) in YAML frontmatter, plus human-readable rationale in Markdown prose. AI coding agents like Claude Code, Cursor, and Copilot read it to generate UI that consistently matches your brand. New to it? Start with what DESIGN.md is; the DESIGN.md guide has the full token schema.

Quick setup#

  1. Put DESIGN.md in your repository root. Keep the YAML frontmatter spec-valid: well-formed token maps, quoted hex colors, {token.references} that resolve. Run npx @google/design.md lint DESIGN.md to confirm before wiring it into Cursor; a broken file gives the model license to improvise.

  2. Create a rule file at .cursor/rules/design-md.mdc (full snippet below). As of July 2026, Cursor stores project rules as Markdown files under .cursor/rules/; older versions used a single .cursorrules file. If your Cursor version differs, the rule text is what matters. Put it wherever your version keeps always-on project instructions.

  3. Test in a fresh session. Prompt: "Build a login screen with a primary button. Use only tokens from DESIGN.md." Then search the generated code for your actual primary hex. If Cursor shipped a generic palette instead, the rule isn't being applied. See troubleshooting.

Here is the copy-paste rule file:

---
description: Project design system, apply to all UI work
alwaysApply: true
---

Before writing or modifying any UI code (components, styles, layouts, themes):

1. Read DESIGN.md in the repository root. Its YAML frontmatter is the
   single source of truth for colors, typography, spacing, radii, and
   component styles.
2. Use token values exactly as written. Never approximate a color, font
   size, or spacing value, and never introduce values that are not in
   DESIGN.md.
3. If a value you need is not defined in DESIGN.md, do NOT guess or
   invent one. Ask which token to use or whether to add one.
4. Treat the "Do's and Don'ts" section of DESIGN.md as hard constraints.
5. After completing UI work, list which DESIGN.md tokens you used.

The metadata keys (description, alwaysApply) follow Cursor's rule format as of July 2026; check Cursor's docs if your version rejects them.

Should the reference go in .cursor/rules or AGENTS.md?#

Both routes work; they differ in scope and portability. The reason you want either at all: chat prompts don't persist. A style instruction you type today is gone in tomorrow's session, and every teammate starts from zero. A rule file or AGENTS.md entry is committed to the repo, so the "read DESIGN.md first" behavior survives new sessions, new branches, and new hires.

ApproachBest whenTrade-off
.cursor/rules rule fileYour team is all-in on Cursor and wants always-on enforcementCursor-specific; other tools won't see it
AGENTS.md referenceMultiple agents (Cursor, Claude Code, Copilot) share the repoOne instruction file for every tool that supports the convention; enforcement depends on each tool honoring it

A pragmatic default: put the instruction in AGENTS.md so every agent gets it, and keep a thin .cursor/rules file that says the same thing for Cursor specifically. The DESIGN.md file itself stays identical either way. That's the format's portability argument. If part of your team uses Claude Code, the equivalent setup is described in DESIGN.md with Claude Code; same file, different pointer.

How do you verify Cursor's output?#

Make the check visual, not vibes-based:

  • Render your tokens. Paste DESIGN.md into the DESIGN.md viewer to see the palette, type scale, and component styles as swatches. Compare the generated screen against that rendering: a wrong radius or near-miss color is obvious side by side.
  • Grep for fabricated values. Search new code for hex values and check each against your colors: map. Any hex not in DESIGN.md is fabricated and worth a follow-up prompt: "Replace every color not defined in DESIGN.md with the nearest defined token, or ask me."
  • Ask Cursor to self-audit. "List every color, font size, and radius you used, next to the DESIGN.md token it came from." Values without a token next to them are your drift report.

Troubleshooting#

SymptomLikely causeFix
Cursor ignores the file completelyRule not loading, or written as a suggestionConfirm the rule file location for your Cursor version; use imperative wording ("read", "never"), not "please consider"
Cursor invents colors for hover/error statesToken fabrication: your file doesn't define themAdd the missing tokens (e.g. error, variant components like button-primary-hover) so there's nothing to invent; keep rule 3 ("ask, don't guess")
Styles mutate over a long sessionWithin-session drift: early context loses influenceRe-anchor mid-session ("re-read DESIGN.md before continuing") or start a new session per UI surface
Responses get slow or the model summarizes the fileDESIGN.md too largeMedian community file size is about 7,050 tokens (our analysis of all 74 files in the awesome-design-md collection, run 2026-07-08). If you're far above that, delete orphaned color tokens, the single largest warning category in that same analysis at 684 findings across 61 files, which npx @google/design.md lint flags, and prose the agent can infer

Cursor-specific tips#

These are working heuristics from our own use, not documented guarantees (Cursor's internals change quickly):

  • Long agent runs drift more than short chats. Multi-file agent sessions accumulate context that dilutes your rule. For big UI features, restate the constraint in the task prompt itself ("follow DESIGN.md tokens exactly") rather than relying on the rule alone.
  • Stronger models comply better. In our experience, larger frontier models follow exact token constraints more reliably than fast/cheap tiers. If brand fidelity matters for a task, pick the stronger model for it.
  • Keep the rule short and the file authoritative. Don't duplicate token values inside the rule. Values belong in DESIGN.md only. Two sources of truth will eventually disagree, and the model has no way to know which one wins.
  • Commit .cursor/rules to version control. The rule only helps teammates if it ships with the repo. Review changes to it like code: a well-meaning edit that softens "never" to "prefer" measurably loosens compliance.

Next step: lint your file (npx @google/design.md lint DESIGN.md), then drop it into the DESIGN.md viewer to see exactly what Cursor will be told to follow, and if teammates use Claude Code, wire up the same file there with DESIGN.md + Claude Code.

Frequently asked questions

Does Cursor read design.md automatically?

No. As of July 2026, Cursor has no native DESIGN.md support and will not load the file on its own. You make it persistent by adding a .cursor/rules rule (or an AGENTS.md instruction) that tells Cursor to read DESIGN.md before any UI work. The rule supplies the trigger; the file supplies the tokens.

.cursor/rules or AGENTS.md: which is better?

Use .cursor/rules for always-on, Cursor-specific enforcement; use AGENTS.md when several tools share the repository and you want one instruction file. They are not exclusive: many teams keep the canonical instruction in AGENTS.md and mirror a short Cursor rule. The DESIGN.md itself is identical in both setups.

Why does Cursor still invent colors sometimes?

Usually token fabrication: your file does not define the value the task needs (a hover state, an error red), so the model fills the gap from its training priors. Define the missing tokens, keep an explicit 'ask, don't invent' line in the rule, and re-anchor long sessions by having Cursor re-read DESIGN.md.

Can I share one DESIGN.md across Cursor and Claude Code?

Yes, that is the point of the format. The file is tool-agnostic Markdown plus YAML tokens; only the pointer differs (.cursor/rules for Cursor, CLAUDE.md for Claude Code, AGENTS.md for both and others). One source of truth, every agent reads the same tokens, no per-tool duplication to keep in sync.