← back

Creating a design.mdA rulebook people and AI both follow

A Markdown rulebook that people and AI both read to build Wealth Manager UI without Figma-to-code drift.

Wealth Manager is Afi's platform for wealth advisors: dense tables and forms, used by people who care more about their data than about delight. It's built on PrimeNG, an off-the-shelf component library.

The problem

Off-the-shelf libraries drift

Teams using one usually take the defaults, and the product looks like every other PrimeNG app. Or they theme it heavily in Figma while the code keeps its defaults. We were doing the second, but nobody had written down the rules.

design.md

A design.md is the rulebook next to the library

A design.md is a plain Markdown file with the system's tokens, rules, component usage and anti-patterns. Designers read it, and so does any AI coding tool that generates UI in the repo.

PrimeNG made it necessary. Its Figma library has component tokens but no base layer for spacing, radius or type sizes. Theming it means inventing those layers yourself, usually in Figma, where the code never sees them.

Three tiers

Three tiers, pulled from the real file

With Claude and the Figma connection, we pulled the actual variables instead of guessing from screenshots:

  • Primitives (87): raw values, like dimension-8.
  • Semantic (39): names with meaning, like spacing/md.
  • Component (22): PrimeNG overrides, like p-datatable/padding/normal, which I had to create because PrimeNG's Figma didn't expose them.

The component tier is where Figma and code drift apart, so I checked all 22. Almost every one routed back to a semantic value.

Gray

The brand gray blurred dense tables

Claude's first pass used our brand gray for surfaces. Its steps are too close together, so a 12-row table read as one gray block. I switched surfaces to PrimeNG's Slate ramp for contrast and kept the brand gray for tags and charts. Every claim the AI made about the system got checked the same way.

Primary

Name the palette, not the role

PrimeNG has one primary slot for actions. We use two blues: deep navy in light mode, where the bright blue fails contrast on small text, and the bright blue in dark mode.

The doc calls the slot AzulProfundo, not "primary." An AI reading "primary" reaches for the main brand color. A palette name leaves nothing to guess.

Breakpoints

Three breakpoints, on purpose

Advisors work on laptops and desktops, so the doc commits to tablet, laptop and desktop (768, 1024 and 1440) with rules for tables, navigation, forms and dialogs. It names no phone breakpoint, because naming one promises support we don't give.

Next

The lessons moved into the README

Writing it taught me how to write rules an AI can follow. When Afi moved design to Claude Design, I carried those lessons into the README of Afi apps, the design system the team now generates products from: real token names, palette names instead of roles, and the anti-patterns spelled out.

More from the blog

See all →