# What is a design harness? The context, rules and checks that make a coding agent design like your team

A design harness is the context, rules, skills and checks around a coding agent that make it design like your team. The model stays the same. The harness decides which components the agent reaches for, which tokens it writes, which rules it reads, and what fails before a person ever looks.

The idea comes from agent engineering. LangChain sums it up as "Agent = Model + Harness" ([LangChain](https://www.langchain.com/blog/the-anatomy-of-an-agent-harness)), and Birgitta Böckeler calls the harness "everything in an AI agent except the model itself" ([martinfowler.com](https://martinfowler.com/articles/harness-engineering.html)). A design harness is the part of that harness that governs the UI.

This guide covers the seven parts, where each lives in the repo, and the order to build them in, with a [copyable AGENTS.md block](#rules-files-agents-md-claude-md-and-cursor-rules) and a skill template. It is for design engineers and design-system leads who already point Claude Code, Codex or Cursor at a real codebase. The UI works, but it does not look like theirs, and a longer prompt, a design skill and a newer model have not closed the gap.

> **Key takeaways**
>
> - A design harness is everything around the coding agent that shapes its UI: components, tokens, rules files, skills, memory, checks and review.
> - Rules files and skills only ask. Lint, type checks and screenshot tests decide, so move every rule that keeps breaking into a check.
> - Keep the harness in the repo, next to the code it governs, so every agent and every person reads the same version.
> - Build it in order: components and tokens first, a short rules file next, then checks, then skills and memory for what is left.

## What is a design harness?

A design harness is what a coding agent reads and runs into while it builds UI. That means your components, design tokens, rules files and skills, the agent's memory of past corrections, the checks on its output and the review at the end. Without one, the agent falls back on what it learned from public code, so its UI looks plausible and generic at once.

![Sketch diagram headed "The design harness". A small box labeled "Coding agent" sits inside a thick lime ring. Seven hatched boxes around the ring are labeled "Components", "Tokens", "Rules files", "Skills", "Memory", "Checks" and "Review".](/image/blog/design-harness-parts.jpg)

The parts come in two kinds. In Böckeler's terms, guides "anticipate the agent's behaviour and aim to steer it before it acts", and sensors "observe after the agent acts and help it self-correct" ([martinfowler.com](https://martinfowler.com/articles/harness-engineering.html)). Components, tokens, rules files, skills and memory are guides. Checks and review are sensors.

| Part | What it holds | Where it lives | Kind | Without it |
|---|---|---|---|---|
| Components | The real Button, Card and Dialog the agent imports | `components/ui` | Guide | The agent hand-builds a lookalike |
| Tokens | The only colors, spacing, type and radii | The theme file | Guide | Hex values and one-off spacing |
| Rules files | Short design rules and an index of components | `AGENTS.md`, `CLAUDE.md`, `.cursor/rules` | Guide | Each agent guesses the conventions |
| Skills | A procedure loaded when the task matches | `.claude/skills/<name>/SKILL.md` | Guide | The same long prompt, pasted every time |
| Memory | Short rules saved from corrections | A file the team can read and edit | Guide | The same correction, every session |
| Checks | Lint, type checks, screenshot tests | Lint config, `tests/` | Sensor | Drift reaches review, or production |
| Review | What a person judges before merge | The pull request | Sensor | Taste and intent go unchecked |

Most repos already hold some of these parts. What is usually missing is the wiring: the rules point at no components, nothing fails when the agent ignores them, and every correction is lost when the session ends. Modeinspect's coding agent follows your repo's CLAUDE.md, AGENTS.md and Cursor rules, plus design guidelines and saved rules your team can edit ([see how it works](/design-harness)).

## Where the idea comes from: agent harnesses and harness engineering

None of the sources behind the term is about design. They are about getting agents to write code that works, and the design harness borrows their vocabulary.

- **Anthropic** describes its Agent SDK as "the agent harness that powers Claude Code" ([Anthropic](https://claude.com/blog/building-agents-with-the-claude-agent-sdk)). Its context engineering guide frames the job as "curating and maintaining the optimal set of tokens" an agent sees ([Anthropic](https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents)).
- **OpenAI** described the practice in its own codebase. Ryan Lopopolo's harness engineering post opens its working model with "Humans steer. Agents execute." and treats AGENTS.md as "the table of contents" rather than the manual ([OpenAI](https://openai.com/index/harness-engineering/)).
- **Martin Fowler's site** gave it a structure. Böckeler splits the harness into guides and sensors, and each kind into computational (deterministic, like a linter) or inferential (another model judging) ([martinfowler.com](https://martinfowler.com/articles/harness-engineering.html)).
- **LangChain** showed what it is worth. Its coding agent went from the top 30 to the top 5 on Terminal Bench 2.0, and the team wrote: "We only changed the harness." ([LangChain](https://www.langchain.com/blog/improving-deep-agents-with-harness-engineering)).

Context engineering and harness engineering are not rivals. In LangChain's words, "Harnesses today are largely delivery mechanisms for good context engineering" ([LangChain](https://www.langchain.com/blog/the-anatomy-of-an-agent-harness)). Context is what the agent sees. The harness adds what it is allowed to do and what checks its work.

A design harness applies the same idea to one question: does the UI look and behave like the team's product? The model is rarely the variable. A new model still reads the same repo, so it reaches for the same lookalikes.



## The codebase and its components

The agent builds with what is in the repo. A component that exists, has a clear name and takes typed props gets used. One the agent cannot find, or cannot tell apart from a lookalike, gets rebuilt by hand.


That is why components come first. Every other part of the harness refers to them: the rules file indexes them, the skill tells the agent to search them, the checks fail when they are bypassed. If two Buttons exist, the agent can import either, and a rule that names one competes with every file that imports the other.

Cut duplicates before you write a single rule. Give each component one name that says what it is, put each design decision in one typed prop, and export every part of a compound component with an example. [Why AI tools recreate your components](/blog/ai-design-system#why-ai-tools-recreate-your-components) covers the failure in detail.

## The design system and its tokens

Most of the design system context an agent needs is tokens plus components. Tokens are the part of the harness that can make the wrong value impossible instead of discouraged. A rule that says "use theme colors" competes with every hex value in nearby files. A theme where the wrong color does not exist leaves nothing to compete.

Tailwind shows the mechanism. Setting a namespace to `initial` inside `@theme`, such as `--color-*: initial;`, removes all of the default utilities that use it ([Tailwind CSS](https://tailwindcss.com/docs/theme)). After that, `bg-red-500` generates no CSS, and the only named colors left are yours. Arbitrary values such as `bg-[#e11d48]` still compile, which is what the lint rule below catches.

Give the tokens two layers. A color scale holds the raw values, semantic tokens such as `surface`, `text-muted` and `primary` point at the scale, and components use only the semantic layer. Dark mode then lives in the tokens, not in a `dark:` class the agent has to remember on every element. In plain CSS or CSS-in-JS, the same rule is one tokens file and a lint rule against raw values.

An agent working inside the repo reads the theme directly. Agents working elsewhere need a lookup. [How much MCP a design system needs](/blog/design-system-mcp) compares the Storybook, shadcn and Figma servers for that job. [Design tools that connect to AI coding agents](/blog/design-tools-for-ai-coding-agents) covers the design side of that connection.

## Rules files: AGENTS.md, CLAUDE.md and Cursor rules

A rules file is the harness's written voice. AGENTS.md calls itself "A simple, open format for guiding coding agents" ([agents.md](https://agents.md)), and "Codex reads AGENTS.md files before doing any work" ([OpenAI](https://learn.chatgpt.com/docs/agent-configuration/agents-md)). Claude Code reads `AGENTS.md` when there is no `CLAUDE.md`, or imports it with `@AGENTS.md` ([Claude Code docs](https://code.claude.com/docs/en/memory)). In Cursor, "Rules provide system-level instructions to Agent", and a `.mdc` rule can apply only to files that match a pattern ([Cursor](https://cursor.com/docs/context/rules)).

Write the design rules once, in AGENTS.md, and point the others at it. Keep it to an index and the few rules the code cannot say:

```markdown
## UI
- Components live in components/ui. Search there before writing markup.
  Button, Card, Dialog, Select, Tabs, Toast. Never a raw <button> or <dialog>.
- Colors, spacing, radii and type come from styles/tokens.css only.
  No hex values, no arbitrary values like p-[13px].
- Use the semantic tokens (surface, text-muted, primary). Never dark: classes.
- Before you finish: run npm run check, then screenshot the page at 375 and 1280.
```

Keep it short. OpenAI's team treats AGENTS.md as a map, with pointers to deeper sources, because a long file crowds out the task ([OpenAI](https://openai.com/index/harness-engineering/)). If you are a designer setting up an agent for the first time, [Claude Code for designers](/blog/claude-code-for-designers) covers the setup.

A rules file is a request. The agent weighs it against the code around it, and the code usually wins. We hear the same thing on our calls with customers: a team wrote its design system up as a markdown file. New screens were still built from scratch instead of from the components.

## Skills: your design system as a procedure

A skill is a procedure the agent loads when the task matches. Claude Code keeps only the name and description in view, and "a skill's body loads only when it's used" ([Claude Code docs](https://code.claude.com/docs/en/skills)). That is the difference from a rules file: a skill can be long, because it costs almost nothing until it runs.

Public design skills fix taste. Anthropic's `frontend-design` skill pushes the model away from generic defaults, with lines such as "Spend your boldness in one place." ([Anthropic](https://github.com/anthropics/skills/blob/main/skills/frontend-design/SKILL.md)). A breakdown of Claude's frontend-design skill and a roundup of Claude design skills worth installing cover the public options. No public skill can know your components, because each was written for every repo at once.

The skill only your team can write is your design system as a procedure. Name the task it covers, then list the steps:

```markdown
---
name: build-page
description: Build or change a page with the team's components and tokens.
---
1. Find the closest existing page and list the components it uses.
2. Reuse them. Search components/ui before writing markup.
3. Use semantic tokens only (surface, text-muted, primary).
4. Run npm run check and fix every error.
5. Screenshot the page at 375 and 1280.
6. If a component is missing, stop and say so. Do not invent one.
```

## Memory: rules saved from corrections

"Each Claude Code session begins with a fresh context window" ([Claude Code docs](https://code.claude.com/docs/en/memory)). A correction you type in chat ("cards in this app never have shadows") is gone in the next session unless something writes it down. Claude Code's auto memory is one such mechanism: "notes Claude writes itself based on your corrections and preferences".

Memory belongs in the harness only if the team can see it. Rules an agent saves for itself, in a place nobody reviews, drift the same way an unreviewed component does. Keep saved rules short, keep them where the team can read and edit them, and review them like any other change.

Promote them as they prove themselves. A saved rule that keeps coming up belongs in AGENTS.md. A rule in AGENTS.md that keeps being broken belongs in a check.

## The verification loop

The verification loop turns requests into pass or fail. Claude Code's docs advise: "Give Claude something it can run that comes back pass or fail." One of its examples is "A browser screenshot next to the mockup" ([Claude Code docs](https://code.claude.com/docs/en/best-practices)).

![Sketch diagram headed "The verification loop". Four boxes joined by arrows run clockwise: "Write", "Render", a lime "Check" and "Fix", which leads back to "Write". An arrow from "Check" leads out to a box labeled "Pull request".](/image/blog/design-harness-verification-loop.jpg)

Three computational checks cover tokens, components and layout. They are fast, and they do not argue:

1. **Lint.** Fail arbitrary values, raw color classes and hand-built elements where a component exists. [Enforcing design system rules on AI-generated code](/blog/ai-design-system#how-to-enforce-design-system-rules-on-ai-generated-code) has the rules.
2. **Types.** A typed `variant` prop makes an invented variant a compile error.
3. **Screenshots.** Playwright can "produce and visually compare screenshots" with `toHaveScreenshot()` ([Playwright](https://playwright.dev/docs/test-snapshots)). Run it at a phone width and a desktop width for the pages that matter. Generate the baselines on the machine that runs the check, because Playwright's docs note that rendering varies with the operating system, browser version, settings and hardware.


Write the error messages for the agent. OpenAI's team does exactly this: "we write the error messages to inject remediation instructions into agent context" ([OpenAI](https://openai.com/index/harness-engineering/)). An error that names the token or the component to use can be fixed in one pass. Run the checks where the agent will see them. Claude Code hooks can run a lint script after every file edit ([Claude Code docs](https://code.claude.com/docs/en/hooks)), and the same checks run again on every pull request.

## The review step

Some things no check catches: hierarchy, copy, and whether the screen does what the brief meant. Nor can a check tell whether a change to a shared component was meant to reach every screen. That is the review step, and it stays with a person.

An agent is a poor judge of its own UI. Anthropic's team found that "agents reliably skew positive when grading their own work", and that "Out of the box, Claude is a poor QA agent." ([Anthropic](https://www.anthropic.com/engineering/harness-design-long-running-apps)). A separate evaluator with written criteria and screenshots does better, but it is an inferential sensor. It narrows what a person has to look at. It does not replace the look.

We hear the same thing on our calls with customers: designers want to see what an agent changed. They do not want to read the code. They want to check that the card they updated changed where they meant it to. Put the rendered result in the pull request, at the widths you check, so the designer reviews the UI and engineers review the code.

Close the loop from review: tag every design comment, so the ones that repeat become rules and checks.

## How to start a design harness

Build it in this order. Each step makes the next one shorter.

1. **Cut the component list.** One component per job, generic names, typed props. Delete or deprecate the duplicates the agent keeps finding.
2. **Lock the theme.** Remove the default palette, define the scale and the semantic tokens, and make components use only the semantic layer.
3. **Write a short AGENTS.md.** An index of components and the five to ten rules the code cannot say. Point CLAUDE.md and a Cursor rule at it.
4. **Add two lint rules first:** arbitrary values and hand-built elements where a component exists. Run them in a hook and on every pull request.
5. **Add screenshot checks** for the pages that matter, at a phone width and a desktop width.
6. **Write one skill** for the task the team does most, usually building or changing a page from the system.
7. **Tag review comments for a month.** Turn every comment that repeats into a rule, and every rule that keeps breaking into a check.

Start with step 1 this week. A clean component list makes every later step shorter, and deciding which duplicate survives is a call only your team can make.

## Frequently asked questions

### What is an AI harness?

An AI harness, also called an agent harness, is everything around a model that turns it into a working agent: its tools, prompts, context and loops. A design harness is the part of it that governs UI.

### What is the difference between an agent harness and a design harness?

A design harness is the part of an agent harness that governs UI. It decides which components and tokens the agent uses and what fails when the result drifts from the team's design.

### Is a design harness the same as harness engineering?

Harness engineering is the practice of improving the harness around a coding agent instead of fixing each output by hand. OpenAI's harness engineering post described it, and Birgitta Böckeler's article on martinfowler.com gave it a structure of guides and sensors. A design harness is what that practice produces when the goal is UI that matches the team's design.

### What is the difference between a design harness and a design system?

A design system is the tokens, components and guidelines a team builds its interface from. A design harness includes the design system and adds what makes an agent use it: rules files, skills, memory, checks and review. A good design system with no harness still gets ignored by agents that cannot find it or are never stopped.

### Does a design harness need an MCP server?

No. An agent working in the repo reads the components, the theme and the rules files directly. MCP servers, such as Storybook's or shadcn's, help agents that work outside the repo look up what exists. Code an MCP returns is one more copy, so the import should still come from the repo.

### Which coding agents can use a design harness?

Any agent that reads files in the repo. Codex reads AGENTS.md, Claude Code reads CLAUDE.md or AGENTS.md, and Cursor reads `.cursor/rules`. Lint, type checks and screenshot tests run the same whichever agent wrote the change, which is why checks carry the most weight.

### Does a design harness fix generic-looking AI UI?

It fixes the part that comes from not knowing your product. A design skill can push the agent away from generic defaults. Only your components, tokens, rules and checks make the result look like your product instead of a well-made template.

### Where should a team start?

With the component list. Cut duplicates, give each component one clear name and typed props, then lock the theme to your tokens. A short AGENTS.md and two lint rules come next. Skills and memory pay off once those are in place.
