The error text looks right on the default theme: #FF4D4F, close enough to the brand red. In dark mode it glows like a highlighter. In the high-contrast theme it fails the contrast check the design system already passed for --color-danger-text.

I’ve started treating a raw hex, rgb(), or Tailwind arbitrary color in an agent UI patch as a merge blocker, the same way a magic font-size should be. If the repo has semantic tokens — danger, text-muted, border-subtle — the agent should use those names, not repaint the brand by eye.

Why the hex always drifts

The model has seen #FF0000 and #111827 in a million examples. It does not know your --color-danger-text is slightly desaturated on purpose, or that background and text come in pairs. A one-off hex also skips dark-mode aliases, focus rings, and the forced-colors adjustments you already paid for.

It is also un-greppable in a useful way. You can find #FF4D4F. You cannot find “every unofficial danger color” after three agents have used #F00, red, and rgb(255 60 60).

A simple color policy

  • Semantic tokens only in product UI: var(--color-danger-text), text-danger, theme('colors.danger.DEFAULT')
  • No raw hex / rgb / hsl in JSX or CSS modules unless the file is the token source
  • Pairs stay paired — if you set a danger background, use the matching danger foreground
  • New colors go in the token file first, with a name and a theme variant, not in the component

If the request is “make this look like the mock,” paste the token names from the mock or the Figma inspect, not a screenshot alone.

What to put in the prompt

Use only semantic color tokens from src/theme/colors.css (or the Tailwind theme keys listed below). Do not add hex, rgb, or arbitrary color classes in components. If a new color is required, add a named token with light and dark values in the token file and use that name. 

Paste the token list — it is usually shorter than the component. In review, grep the diff for #, rgb(, hsl(, and Tailwind -[#. Those hits should all live in the token file.

The same gate applies to borders, shadows, and chart series. A one-off #E5E7EB border looks fine until the dark theme uses a different hairline token. Chart palettes should come from the same token file, or from a documented chart subset, not from a D3 example’s category10 colors pasted into a React component.

If the mock is slightly off-token, fix the mock or file a token change. Do not honor a screenshot by hard-coding the eyedropper value. That is how the design system and the running app diverge in a week.

Reject / send back

Reject

  • style={{ color: '#FF4D4F' }} or text-[#FF4D4F] in a component
  • A one-off red / rebeccapurple that ignores the scale
  • A dark-mode fix that adds a second hex instead of a token alias
  • “I picked a color close to the mock” without a token name

Accept

  • An existing semantic token, including its hover/disabled variants
  • A new token in the theme file, used by the component, with both themes filled in