DESIGN.md UI Rules: Stop Agents Reverting Your Layout Fixes
A DESIGN.md and rules block that records locked UI decisions, so Claude Code, Codex, and Cursor stop undoing alignment, spacing, and style fixes you made.
Added
Save this as DESIGN.md in the repo root and add this line to AGENTS.md (or CLAUDE.md / an alwaysApply .cursor/rules file): "Read DESIGN.md before changing any UI. Never change a LOCKED item unless my message names it." # DESIGN.md ## Design tokens (use these, never raw values) - Colors: [primary #...], [surface #...], [text #...], [muted #...], [danger #...] - Font: [family], sizes [14/16/20/28], weights [400/600] - Spacing scale: [4, 8, 12, 16, 24, 32] px. Radius: [8] px. Max content width: [1100] px. - Where they live: [path to tailwind config / CSS variables / theme file] ## Layout conventions - Text alignment: [left-aligned everywhere except numbers in tables, which are right-aligned] - Navigation: [top bar on desktop, bottom tabs on mobile] - Forms: [labels above inputs, one column, primary button bottom-left] - Reuse components from [components/ui/]; do not create a new button, card, or modal style. ## LOCKED decisions (fixed on purpose; do not "improve") Add a line every time you fix the same UI problem twice. - [YYYY-MM-DD] [Element]: [what it must be]. Why: [reason]. Reverted before: [yes/no] - e.g. 2026-11-17 Pricing table: left-aligned text, not centered. Why: long plan names wrap badly. Reverted before: yes (3x) ## Before any UI change, the agent must 1. Check whether the element is in LOCKED or covered by a convention above. If yes and my request doesn't name it, leave it alone. 2. If a LOCKED rule seems wrong for the task, stop and ask; don't silently change it. 3. Run `git log -L` or `git blame` on lines you're about to restyle; if a recent commit message says it was a deliberate fix, keep it. 4. Use tokens and existing components only. 5. After the change, list every visual property you changed (element, before, after). ## When a fix gets reverted again Prompt: "This fix was reverted. Find which change undid it and why, add a LOCKED line to DESIGN.md with the reason, and propose a check (test, lint rule, or screenshot) that would catch it next time."
How to use it
- Click Copy template.
- Paste into ChatGPT, Claude, Grok, Cursor, or your agent framework.
- Replace the [BRACKETED] parts with your details.
Pairs well with: AI Agent Harness Starter Pack: Rules, Hooks, Status & Verify
FAQ
Why does my AI coding agent keep undoing UI fixes?
Each new session starts without memory of why a layout is the way it is. If the fix isn't written down, the agent sees an unusual choice, such as right-aligned columns or a non-standard button position, and 'corrects' it back to a common default. Recording the decision and the reason in DESIGN.md gives it that missing context.
What is DESIGN.md?
A plain Markdown file in the repo that describes your design system: tokens, layout conventions, components to reuse, and locked decisions. Claude Code, Codex, Cursor, and Gemini CLI can all read it when your AGENTS.md or CLAUDE.md points to it.
Should UI rules go in AGENTS.md or a separate file?
Keep a one-line pointer in AGENTS.md or CLAUDE.md and the details in DESIGN.md. That keeps the main rules file short, and the agent only loads the design details when it works on UI.
How do I make a UI decision stick for good?
Write it as a LOCKED line with the reason, then back it with something the agent can't ignore: a component that hard-codes the style, a lint rule, or a visual regression or screenshot test. Rules files are guidance; tests are enforcement.
Get 3 new templates every week
Free. Unsubscribe anytime.Related templates
Design SKILL.md: Stop Your Vibe-Coded Site Looking AI-Made
Wireframe-First UI Brief: Plan Screens Before Vibe Coding
This Codebase Is Yours: Ownership Rules for Coding Agents
Rules File Drift Check: Is Your AGENTS.md Lying to the Agent?
Browse all Coding & Cursor Rules templates