Gavel Escavador’s design system
A design system that had grown to twice the size it needed, cut back until the team’s delivery rhythm doubled and other areas could build on their own.
- Where
- Escavador, a Brazilian legal-tech platform
- When
- January–October 2026
- My part
- Token architecture, Figma-to-code pipeline, governance, migration plugin
- With
- Product design and engineering
- 52%smaller library, with every component on usage tokens
- ~2×delivery rhythm, from static screens to documented prototypes
- 96% to 0%of components bound straight to raw primitives
- 3 in 4old bindings migrated automatically by a plugin
In short
- Problem
- Figma and code had drifted apart. The library was twice the size it needed and almost every component was bound straight to raw colours, so designers struggled to use it and engineering couldn’t trust it.
- What I did
- Rebuilt the tokens in layers, made code generated from Figma and checked on every release, and built Pherb, a plugin that migrated three in four old bindings on its own.
- Outcome
- A library 52% smaller, every component on usage tokens, about twice the delivery rhythm, and a system ready for AI agents.
Problem
On paper, the design system covered every brand and product need. In practice, Figma and code had drifted apart: decisions made in Figma were copied into code by hand, and parity between the two was declared rather than checked.
An audit made the cost visible. The library had grown to more than twice the size it needed, about a third of the components carried their own colours, and almost every component was bound straight to raw primitives instead of to decisions. The team felt it downstream: it shipped static screens only, with no navigable prototypes and no documentation.
Before V5
This is how a single card was wired. Each part bound a variable from whichever collection was at hand, so the same decision could live in three places, and none of them said which one was right.
- Semantic
Semantic/surface/container-low--sem-color-surface-container-low - Semantic
Semantic/on-surface/content--sem-color-on-surface-content - Component
Component/button/primary/container/color--comp-button-primary-container-color · --button-primary-bg - Semantic
Semantic/shape/radius/accentuated--sem-shape-radius-accentuated · --card-radius - Component
Component/input/border/color--comp-input-border-color - Component
Component/input/focus-ring/color--sem-color-focus-ring - Component
Component/button/primary/content/color--comp-button-primary-content-color · --button-primary-fg - Primitives
Primitives/color/blue/700no token in code
Reconstructed from the v4 library. The names are real; the card is simplified.
Solution
So the fix had to start with the structure, not the screens. The tokens were rebuilt in layers, from raw primitives to the colours components actually use, and the direction of the work flipped: code is now generated from Figma, and every release checks that the two still match. Designers pick from usage roles, never from raw primitives.
A leaner structure, though, left every existing file pointing at variables that no longer existed. Rather than migrate them by hand, I built Pherb, a plugin that simulates first, resolves what it can and asks about the rest; about three in four bindings moved on their own.
Then developers pointed out a cost no one in design could see: every page downloaded the whole library. The build moved to one file per component, so a page now ships only what it imports, about 54% less JavaScript on a search page.
In V5
The same card today. Every part binds a usage token from a single collection, and each token has one name in Figma, in CSS and in Tailwind.
- Colors
Colors/surface/layer/card--card · bg-card - Colors
Colors/text/foreground--foreground · text-foreground - Colors
Colors/surface/brand/primary/default--primary · bg-primary - Radius
Radius/md--sem-radius-brand-md · rounded-md - Colors
Colors/border/input--input · border-input - Colors
Colors/border/ring--ring · border-ring - Colors
Colors/text/primary-foreground--primary-foreground · text-primary-foreground - Colors
Colors/text/link--link · text-link
Names from Gavel V5’s token catalogue; the card is simplified.
Collections
One semantic collection held every decision, and a component collection on top of it, about a third of all variables, mostly repeated what it said. The semantic layer was split by subject instead: brand palettes in one collection with the brands as modes, usage colours in another, and one collection each for radius, spacing, size, type, effects and borders.
Dimensions are named after Tailwind, so the name picked in Figma is the class written in code. With every use covered, the component collection had nothing left to say and was removed; components bind usage tokens directly, as in shadcn. That removal accounts for most of the 52%.
Collections, before and after
Before, four collections, one of which held every decision. After, one collection per kind of question, and the component layer is gone.
| Collection | Modes | Example variables | Share |
|---|---|---|---|
| Primitives | Default | color/yellow/400
color/blue/700
font/font-sans | ~54% |
| Product | B2C, B2B, AI | color/brand/primary/light
color/surface-source/base/dark | ~10% |
| SemanticColor, radius, type and effects together | Light, Dark, A11y Light, A11y Dark | color/primary/brand
color/surface/container-low
shape/radius/accentuated
typography/heading/… | ~13% |
| ComponentMostly repeated Semantic. Removed in V5. | Default | button/primary/container/color
input/focus-ring/color | ~23% |
Share of all local variables at the September audit.
Surfaces
One scale of backgrounds carried three ideas at once: how light a surface is, how high it sits and whether it carries the brand. In two of the three brands, “dim” came out lighter than “bright”, some levels repeated a colour, and brand colour leaked into cards and menus.
The ideas were pulled apart. The scale became neutral and now expresses only height, and each level got a job named by use: sunken for fields, low for cards, highest for dialogs and menus, inverse for tooltips. Brand-tinted surfaces got their own tokens, and a release check measures the scale in every brand and mode, so a new colour can’t flatten it again.
Ready for agents
Agents invent what they can’t find: a new token, a near-copy of a component. So Gavel ships a closed catalogue for them, with documentation written for agents, every prop described and forbidden behaviours listed. The release fails when the documentation and the code disagree, and the same package feeds the team’s design agent, Perry, and the AI tools in Figma.
How it runs
Two loops keep the system honest. One carries every value from Figma to code and checks it on the way; the other decides what gets into the system at all, and keeps a record when that changes.
From a change in Figma to a release
- FigmaVariables change
- Claude CodeCommits tokens
- Merge requestReviewed, merged
- PipelineChecks pass?
NoBack to Figma
- ReleasePackage published
- 01
Figma. A designer changes the variables, working with Perry.
- 02
Claude Code. Snapshots the variables and commits the generated tokens to GitLab.
- 03
Merge request. A semantic diff shows what changed; a person reviews and merges.
- 04
Pipeline. Code must match the snapshot, and names, contrast and surface order must hold. If not, the pipeline stops and the fix goes back to Figma.
- 05
Release. The release bot publishes the package and the docs.
How a decision enters the system
- SpotA gap appears
- ProposeOptions, measured
- RecordNumbered decision
- ApplyFigma and code
Replaced by a better answer, never erased · about 1 in 7
- 01
Spot. An audit, a designer who can’t find a value, or a developer’s feedback.
- 02
Propose. Options side by side, measured by contrast, colour distance and real screens.
- 03
Record. Problem, choice and why, written as a numbered decision.
- 04
Apply. Figma and code change together, and a check keeps the rule from drifting.
Simplified: internal tools and hosts are left out.
Pherb
Publishing V5 didn’t update the bindings inside product files, so I built Pherb, a Figma plugin designers use to migrate their own files. It looks before it touches anything, applies changes only after review, saves a version first and asks when it can’t decide. Try it: the window below works.
Pherb
Migration to V5.1.0Move this file’s variables to the latest library, without changing how anything looks.
- The window is live: every button works. Use the steps to jump.
A working prototype of the plugin, with its sample file and numbers.
Capacity
The smaller library paid for itself in rhythm. The team moved from one static, undocumented project at a time to documented, prototyped deliveries at about twice the pace, and other areas now build consistent interfaces on their own.
Along the way
- “I can’t find the padding.”
One designer’s question exposed duplicate and clashing names. It ended with every dimension named after its Tailwind class, without breaking a single binding.
- Disagreeing with the reference, on purpose.
Field borders follow shadcn’s structure but not its contrast: the preset was weaker than accessibility requires for components, so the system departs from it, in writing.