Skip to content

Guide

How to keep AI-generated UI consistent across a whole app

Updated

Why ten prompts give ten different screens

Each prompt is a fresh decision. Ask Claude Code, Cursor or Codex for an orders list on Monday and a suppliers list on Thursday, and you get two tables that each look reasonable and do not match. One has a filter row, the other a search box in the header. One opens a record in a dialog, the other on a new page. The padding, the empty state and the date format all differ.

The tool is not careless. It fills every gap you leave with the most likely answer from everything it has seen, and for a table there are thousands of likely answers. It also does not remember last week's screen unless that screen is in front of it, and in a growing repository it often is not.

So the drift comes from the gaps, not from the model. The fix is to close the gaps where the tool looks first: the code it imports, the instructions it reads and the checks that run after it.

What actually fixes it

One source of components

If a table can be written from scratch, it will be. Keep one folder or package that owns every building block (button, field, table, side panel, empty state) and make importing from it the only allowed way to build a screen. The tool then composes screens instead of drawing them, and a fix in the table reaches every list at once.

Make the source easy to find. A short index of what exists, with one line on when to use each piece and what it replaces, saves the tool from writing its own modal because it did not know yours was there.

Rules the tool reads

Coding tools read a standing instruction file before they start: AGENTS.md for most of them, CLAUDE.md for Claude Code. Rules there are read on every task, so they are worth more than any prompt. Good ones are short, concrete and checkable:

  • Use the semantic colour classes from the kit; never write a hex, rgb or hsl value in a component.
  • Every list loads through one data hook and shows four states: loading, error with retry, empty, and the data.
  • A screen header has a title, one primary action and at most two secondary ones; the rest goes behind a menu.
  • Tables never scroll sideways on a phone; less important columns hide and fold into the first cell.

Write each rule once. When the same rule sits in three files in three wordings, the tool follows whichever it read last. Our guide on what to put in AGENTS.md covers the file itself.

Checks that fail the build

A rule nothing checks is a suggestion. The tool will follow it most of the time, and the exceptions pile up. Turn every rule that can be checked into a script that fails:

  • A token check that searches components for raw colour values and stops the commit when it finds one.
  • A lint rule (no-restricted-imports) that forbids importing the underlying UI library anywhere outside your component package.
  • A states check that finds data loaded without the loading, error and empty branches.
  • End-to-end tests with an accessibility scan, and screenshots at phone and desktop width you actually look at.

The tool reads the failure and fixes it in the same session. Run the cheap checks after every edit (Claude Code can do this with a hook) and the slower ones before you call a task done.

Screen archetypes

The biggest source of drift is the layout of a whole screen: how wide it is, what sits in the header, what scrolls and how a record opens. Name a small set of screen types and give each a component that owns those decisions. A list is a list, a form is a form, and the tool picks the type instead of inventing a page. We use nine; the guide to screen archetypes describes each.

What you can do today, without buying anything

  1. Pick one component library and write in AGENTS.md that every screen is built from it. Say where it lives.
  2. Add the four or five rules above that matter most to your app, each in one sentence.
  3. Add no-restricted-imports for the libraries the components wrap, and a ten-line script that fails on a hex colour in your components.
  4. Write down what "done" means: which commands pass and which screen sizes you look at.
  5. When you correct the tool twice for the same thing, add a rule. When you correct it three times, add a check.

None of this needs a framework. It needs someone to decide once, write it down in one place and let a script enforce it.

How Meadowstack Framework packages it

The framework is that setup, finished and kept up to date. It holds a component kit with a manifest of what each piece is for, an AGENTS.md and CLAUDE.md with one wording per rule, Claude Code skills for repeat jobs (a new screen, a new module, an approval flow, a final check), Cursor rules generated from the same file, and an MCP server that answers "which component do I use for this" before the tool writes its own.

Screens are <Screen archetype="index"> and its eight siblings; a slot the archetype does not have is a type error. Checks for tokens, contrast, screen states, column types, markup and motion run in npm run check, and an editor hook runs the formatter and the token check after every edit. You can see the result in the example apps: 9 trades, one look.

Questions about this guide

Can better prompts fix inconsistent UI?

Only for the screen in front of you. A prompt does not carry over to the next task. Rules in a file the tool reads every time, and checks that fail the build, do.

Does this work with Cursor and Codex as well as Claude Code?

Yes. The rules live in plain files and the checks are npm scripts, so any tool that reads an instruction file and runs commands follows them. Claude Code adds hooks and skills on top.

Is a design system the same thing?

A design system gives you the parts and the reasons. Consistency with an AI tool also needs the rules in a file it reads and checks that stop a change, because the tool cannot attend a design review.

Two ways

Build it yourself, or have it built

  • Build it yourself

    Build your app on the framework

    Get the codebase these apps stand on and build yours with Claude Code, Cursor or Codex.

    One-time, from €249

    Get the framework
  • Have it built

    Have us build your app

    Tell us how your team works. We plan the app with you and build it on the same framework at a fixed price.

    After launch, Care keeps it improving, from €99 a month.

    from €1,990

    Describe your app