Underlith logo Underlith

AI & Agents

AI can generate UI. But only governed systems can scale it.

Editors, automation pipelines, and AI agents can now write components, refactor styles, and modify layouts directly inside the codebase.

The faster you ship without governance, the faster your brand fragments.

Underlith keeps generated UI inside the same design contracts that govern everything else.

Agent thinking
resolve
import @acme/tokens acme.brand.css ✓ loaded
check --ul-color-brand-primary
resolves → oklch(0.91 0.22 122) via @acme/tokens
check --ul-color-text
resolves → oklch(0.98 0 0) · contract loaded · 3 tokens resolved
validate
scan Button.tsx checking for literals
lint background-color var(--ul-color-brand-primary)
lint padding var(--ul-space-3)
lint border-radius var(--ul-radius-sm)
3 properties · 0 literals · consumption path intact
drift
drift Badge.tsx color: #3b82f6 ✗ literal
expected: var(--ul-color-info) — replacing
fix --ul-color-info oklch(0.70 0.13 240) ✓ patched
1 literal intercepted · 1 replacement applied
output
write Button.tsx ✓ no changes
write Badge.tsx 1 fix applied
2 files processed · 1 patched · brand contract enforced
result lint:tokens-check ✓ passed
0 literals · 0 unmapped vars · governance intact

The Problem

AI generates hardcoded UI

When AI generates UI without design constraints, it usually produces raw values.

color: #3b82f6;
padding: 12px;
border-radius: 6px;
font-size: 14px;

These values may look correct in isolation, but they bypass the design system.

At scale this leads to:

Automation accelerates development. Without governance, it also accelerates design drift.


Token governance for AI-generated UI

Underlith turns design tokens into enforceable infrastructure.

Instead of generating arbitrary values, AI generates UI through tokens.

color: var(--ul-color-brand-primary);
padding: var(--ul-space-3);
border-radius: var(--ul-radius-sm);
font-size: var(--ul-font-size-sm);

This ensures that both human-written and machine-generated code follow the same visual system.

Tokens act as hard constraints, not suggestions.


Governance model for automation

Underlith separates responsibilities across three levels. AI and automation operate at Level 3 — as product consumers, not decision-makers.

Level 1 — Underlith core (primitives, slow, stable)
      ↓
Level 2 — @your-org/tokens (brand contract, your cadence)
      ↓
Level 3 — Every product: web app, mobile, admin, AI agent
      ↓
CI enforcement (drift check, contrast, visual regression)
      ↓
Validated UI output

Automation executes the system. It does not redefine it.


Automated safeguards

Underlith integrates with CI pipelines to ensure automation cannot bypass design governance.

Token validation

lint:tokens

Ensures tokens follow schema rules, naming conventions, and semantic structure. CI fails when tokens violate the contract.

Drift detection

lint:tokens-check

Detects hardcoded design values in the codebase — hex, rgb, hsl, oklch literals and var(-- references not resolving to --ul-* or --ul-color-*.

Example — drift detected:

padding: 12px;

Expected:

padding: var(--ul-space-3);

Contract protection

breaking-change detection

Detects token changes that break downstream consumers.

Examples of breaking changes:

CI blocks these changes until they are properly versioned.


AI-assisted workflows

Underlith is designed to work safely with AI-driven development. Tokens provide the machine-readable structure that allows AI to generate deterministic UI.

underlith init --shadcn

Reads an existing globals.css, maps CSS variables to semantic tokens, and rewrites the file.

No component changes required.

underlith brand init

Separates base tokens from brand tokens and scaffolds a publishable @your-org/tokens package — your Level 2 brand contract.

AI extracts structure from the token layer without inventing values.

underlith migrate (roadmap)

Scans a codebase for hardcoded design values and replaces them with the correct tokens.

This enables safe large-scale migrations.


Token-aware AI prompts

AI systems can operate directly within token constraints.

Example prompt:

Generate a Card component using only the following tokens:

Colors
--ul-color-neutral-0
--ul-color-neutral-200
--ul-color-neutral-900
--ul-color-brand-primary

Spacing
--ul-space-3
--ul-space-4

Radius
--ul-radius-sm
--ul-radius-md

Typography
--ul-font-size-sm
--ul-font-weight-medium

Motion
--ul-duration-fast
--ul-ease-inout

AI output remains aligned with the design system by design.


Result

Automation can safely generate and modify UI.

AI becomes a constrained executor within the design system, not a source of arbitrary visual decisions.

Design governance remains intact even as development becomes increasingly automated.

AI is a constrained executor, not a decision-maker.

Underlith ensures that automated workflows respect the same design contracts that define your brand.


What's available today

CI inputs & outputs

CI operates on canonical inputs and produces deterministic artifacts.

Inputs

  • src/tokens/** — base token definitions
  • underlith.tokens.css — canonical source
  • your-org.brand.css — brand layer
  • Consumer code (token-aware lint)

Outputs

  • underlith.tokens.css
  • underlith.css
  • your-org.brand.css and your-org.base.css
  • CI reports (lint, breaking changes, audits)

Core CI jobs

CI quickstart

name: Tokens CI
on:
  pull_request:
    paths:
      - 'src/tokens/**'
      - 'styles/**'
jobs:
  build-tokens:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npm run build:tokens
      - run: npm run lint:tokens

  drift-check:
    runs-on: ubuntu-latest
    needs: build-tokens
    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npm run lint:tokens-check

Reduced motion

Motion tokens automatically respect accessibility preferences. When prefers-reduced-motion: reduce is set, durations collapse to near-zero.

@media (prefers-reduced-motion: reduce) {
  :root {
    --ul-duration-nano:     0ms;
    --ul-duration-micro:    0ms;
    --ul-duration-fast:     0ms;
    --ul-duration-base:     0ms;
    --ul-duration-moderate: 0ms;
    --ul-duration-slow:     0ms;
    --ul-duration-glacial:  0ms;
    --ul-duration-epic:     0ms;
  }
  *, *::before, *::after {
    animation-duration:        0.01ms !important;
    animation-iteration-count: 1      !important;
    transition-duration:       0.01ms !important;
  }
}

What's next

A slice of the Roadmap focused on Automation & AI.

Q3 2026 — Automation

Q4 2026 — Automation & AI