All blog posts
Design systems
Updated 1 Sep 2026 · 3 min read

Component spec files: the 8-⁠section template

A design system is only as good as the file an engineer, or an AI agent, opens at 11pm. This is the structure I use so that file is the same every time.

Mohammad Abdul Aleem
Mohammad Abdul AleemLead AI Product Designer

Why a spec file, not a Figma page

Figma shows what a component looks like. It doesn't say which token a border reads, what happens on disabled, or which other components break when the padding changes. Engineers rebuild from screenshots, AI agents guess, and three months later you have four buttons.

A spec file is plain Markdown that lives next to the code. It is small enough to read in two minutes and structured enough that a model can be pointed at it and produce on-system UI. On the Colaberry Design System, 20 components share this template; new brands are themes, not rebuilds.

Six tiers of files

Review foundations first. Get colour and spacing right and every component spec follows.

  1. TIER 01Foundations, colour, spacing, typography, radius, elevation, motion. The primitives every other file inherits.
  2. TIER 02Token reference, the master map of every CSS variable, grouped primitive → semantic → component.
  3. TIER 03Atoms, button, input, icon-button, badge. One spec each.
  4. TIER 04Molecules and organisms, composed components specific to your product.
  5. TIER 05Patterns, layout rules, content flow and spacing between elements.
  6. TIER 06Cross-references, "uses" and "used by" links across all files.

The 8-⁠section template

Every spec from button.md to data-table.md has the same eight headings, in the same order. Readers learn the shape once.

  1. 01MetadataName, tier, status, owner, version, last reviewed.
  2. 02OverviewWhat it is for, when to use it, when not to.
  3. 03AnatomyNamed parts, slots and their order.
  4. 04TokensEvery variable the component reads, never a raw value.
  5. 05Props / APIName, type, default, required, and the design intent behind each.
  6. 06StatesRest, hover, focus-visible, active, disabled, loading, error, with contrast noted.
  7. 07Code examplesThe three most common compositions, copy-pasteable.
  8. 08Cross-refsUses / used by, so a change shows its blast radius.

A skeleton you can copy

# button.md

## 01 Metadata
tier: atom · status: stable · owner: design-systems · v2.3

## 02 Overview
Primary action. One per view. Not for navigation.

## 03 Anatomy
[icon-left] label [icon-right]

## 04 Tokens
background  --action-primary
label       --text-on-brand
radius      --radius-pill
shadow      --shadow-brand

## 05 Props / API
variant: primary | ink | secondary | ghost   (default primary)
size:    sm | md | lg                        (default md)

## 06 States
hover → --action-primary-hover · focus-visible → --shadow-focus
disabled → opacity 0.5, cursor not-allowed

## 07 Code examples
<Button variant="primary" size="lg">Book my demo</Button>

## 08 Cross-refs
uses: icon · used by: hero, dialog-footer, form-actions
Tokens shown are from the AgentCory system the spec was written for.
Blank version of this skeleton, with the token and props tables ready to fill.

How AI agents use it

Point the model at the token reference and the spec for the component it needs. Because sections 04 and 06 are explicit, the agent has no reason to invent a hex code or skip the focus state. The cross-refs tell it what else to open. In practice this is the difference between "generate a card" and a card that passes review.

Before you publish a spec

  • Every value in section 04 is a token name, not a number.
  • Section 06 lists focus-visible and reduced-motion behaviour, with contrast ratios.
  • The code example renders in Storybook without edits.
  • Cross-refs are reciprocal: if A uses B, B lists A under "used by".

Need this built?

I build design systems with spec files like this one

Tokens, accessible components and docs your engineers and AI agents can both build from.

Fit

Zoom with + and −, move with the arrow keys, 0 fits the screen, Esc closes. Double-click the picture to zoom in there.