Skip to content
← Back

4 min read

Paying down the palette

In August I joined Mastra as a product engineer. Mastra is an open source TypeScript framework for building AI agents, and we build a few apps on top of it: Studio, Platform, and Factory. Most of my time since has gone into rebuilding the design system those apps share, with a small frontend team. It changed how I think about design.

I used to picture a design system as a folder of components. Now I think of it as a list of decisions someone made once, so nobody has to make them again on every screen: which red means error, how tall a button is, how loud a focus ring should be.

The same bug, twice

In my first couple weeks, the breadcrumbs in one of our apps were cutting off the bottoms of g, p, y, and j. A fix went in that morning. Eleven days later a ticket came in for Platform: "Breadcrumb labels clip their descenders." Same bug, different app.

  1. Projects
  2. Typography
  3. Page layouts
Same label, same font. Watch the tails of the g, p, y, and j.

The bug was never in the breadcrumb. It was in the layer underneath, and each app had its own slightly different copy of that layer. Fix it there once and every screen picks it up. That was the moment the size of the job clicked for me.

How drift happens

When a team moves fast, every screen solves its own problem in the moment. At a startup that's usually the right call. The cost shows up later, as a pile of small decisions that almost match.

Nobody did anything wrong. Each choice made sense on its own, and you only see the drift when you line things up side by side. My favorite: our small tabs rendered half a pixel taller than our medium ones.

sm,

md,

Both tabs magnified against one top edge. The small one reaches it, the medium does not.

When we started, I wrote that "the hardest part will be knocking down the 'debt' we currently have." I still think that's right.

Roles, not colors

We went type first (weight, size, and what each style is for), then color, then ported over the pieces that were already good. We rolled it out one piece at a time, with the old colors left in place during the move so nothing broke.

Color is where the idea is easiest to see. A component doesn't pick a gray. It asks for what it needs: background, card, border. The raw colors live underneath and the roles map onto them, so switching to light mode or tweaking a ramp moves everything that asked for "card" along with it.

Raw grays

Breadcrumb labels clip their descenders

Platform, eleven days later

#131313, #e7e7e7, #242424

Semantic roles

Breadcrumb labels clip their descenders

Platform, eleven days later

card, card-foreground, border

One card, built two ways. Only one of them follows the theme.

Building the ramps was hard. I posted at the time: "new appreciation for people who work regularly with color." (Color people, I see you now.)

We started with ten roles. To add one, a component has to show a state the existing roles can't describe. Without that rule the role list turns into its own pile of debt.

Turning a feeling into a number

A lot of design direction starts as a feeling, like "keep it subtle." Focus rings are a good example: they have to be visible to someone on a keyboard without distracting everyone else. Ours are set to the softest strength that still meets accessibility contrast, in light and dark.

before

after

Focus walks the controls on its own. Hover or tab in to take over.

I think this is where a system earns its keep: "keep it subtle" becomes a number every component follows.

Once the numbers exist, it's tempting to turn on strict checks right away. We fixed first and enforced after, because a check that fails on every old inconsistency mostly just blocks people from shipping. Type is enforced now: reach for a size outside the scale and the tooling points you back to the shared styles.

Why agents raise the stakes

Coding agents copy whatever patterns are nearest. If a codebase has three ways to build a form, an agent will happily make a fourth. When I point an agent at our shared UI package, it pulls in everything, including the parts we haven't cleaned up yet.

So a clean system with rules on top is one of the best things you can give an agent. Our goal is to make shipping at agentic speed help the UX instead of costing it. It's already paying off: illustrated empty and error states landed on October 5, and a new Cmd+K menu merged on Platform this week.

Mostly this work gave me a new appreciation for interfaces that just work. When the descenders aren't clipped, red means the same thing on every page, and the small tab is actually small, nobody notices. That's the point.