An executable evolution of design systems.
Design Systems were built to be read.
Design Models are built to be executed.
This repository is a small, focused proof of that idea.
This repo demonstrates a Design Model:
a design system expressed as an executable model that AI tools and engineers can safely operate inside.
Instead of documenting rules and hoping they’re followed,
a Design Model enforces design decisions at runtime.
The demo intentionally starts small — with a single Button component — to make the idea clear without distraction.
AI-assisted coding tools can generate UI extremely fast.
AI:
- doesn’t read design documentation unless enforced
- doesn’t remember conventions
- doesn’t prevent invalid UI from being produced.
The result is often inconsistent, off-brand, or unshippable UI.
Design Models address this by turning design decisions into machine-enforceable rules.
A Design Model has three executable layers:
Define what styles are allowed
(colors, spacing, typography, radius, etc.)
Define what components exist and what props are valid
(variants, sizes, defaults)
Define what decisions are not allowed
(e.g. only one primary action per view)
UI is not generated.
It is resolved against these rules.
| Design System | Design Model |
|---|---|
| Documentation-first | Execution-first |
| Built for humans | Built for humans and AI |
| Rules are advisory | Rules are enforced |
| Violations caught in review | Violations blocked at runtime |
Design systems explain decisions.
Design models enforce them.
No.
- Component libraries ship components
- Storybook documents usage
- Design Models govern what is allowed to exist
AI can ignore documentation.
It cannot ignore enforcement.
Because constraints are authored, not assumed.
In the demo:
- UI renders freely
- You add a constraint
- The same prompt now resolves differently
Nothing else changes — not the renderer, not the intent.
This makes governance explicit and intentional.
On purpose.
Buttons are:
- universally understood
- easy to misuse
- easy to govern
- visually obvious when wrong
If a model can’t govern a Button, it won’t scale to more complex UI.
The system does not crash or fail.
Instead it:
- acknowledges the intent
- explains which constraint applies
- offers structured suggestions for AI agents (e.g. downgrade to secondary)
This is assistive governance, not policing.
The Design Model sits between the AI and the code:
Intent / Prompt ↓ AI assistant or agent ↓ Design Model (tokens + contracts + constraints) ↓ Resolved UI spec (valid by construction) ↓ Code generation
AI proposes.
The Design Model decides.
- Run the demo
- Create two primary buttons → works
- Add constraint: “Only one primary button per view”
- Run the same prompt → constrained resolution
- Remove the constraint → works again
Then try:
- adding a new constraint
- adding a new component
- observing how behavior changes without touching the renderer
shadcn/ui is used ONLY for the demo shell (layout, panels, tabs, inputs, code area, run/reset controls).
The rendered component preview must be our own renderer output, using ONLY:
tokens/tokens.jsoncontracts/*.jsonconstraints/*.json- Resolver logic
The renderer MUST NOT import or depend on shadcn components. The preview output for components (e.g., Button) must be a plain <button> (or our own internal component), styled using resolved tokens (inline styles or simple class mapping).
This repo is intentionally small and focused.
Good contributions:
- a new component
- a new constraint
- a clearer rule or remediation
The goal is not feature completeness.
The goal is clarity.
- Install dependencies:
npm install- Run the development server:
npm run dev- Open http://localhost:3000 in your browser.
Try this prompt (default on page load):
Create a primary button with label "Continue"
This will:
- Parse the intent
- Resolve tokens to CSS values
- Render a primary button with proper styling
Try this prompt:
Create two primary buttons
Without constraints: This will pass and render two primary buttons.
With constraints:
- Go to the Constraints tab in the Model Editor
- Type "only one" in the search field
- Click "Only one primary button per view" to add it as a pill
- Click Run
- This will:
- Parse the intent (creates two primary buttons)
- Fail constraint validation (
onlyOnePrimaryPerView) - Show error message referencing the constraint
- Prevent rendering (nodes array is empty)
- Remove the constraint pill and Run again → it will pass
The Design Model exposes an MCP (Model Context Protocol) server that allows AI agents to validate view specs, suggest fixes for constraint violations, and apply those fixes automatically.
- Install dependencies (if not already done):
npm install- Run the MCP server:
npm run mcp:devThe server runs on stdio and exposes the following tools:
- getDesignModel() - Returns tokens, contracts, and enabled constraints metadata
- validate(viewSpec, enabledConstraints) - Validates a view spec against constraints (read-only)
- suggestFixes(viewSpec, enabledConstraints, violations) - Suggests JSON patch operations to fix violations
- applyFixes(viewSpec, fixes) - Applies JSON patch operations to a view spec
In the demo app, you can use the "Run with MCP (Auto-fix)" button to see the auto-fix flow in action:
- Create a prompt with constraint violations (e.g., "Create two primary buttons")
- Add the "Only one primary button per view" constraint
- Click "Run with MCP (Auto-fix)"
- The system will:
- Validate and detect violations
- Suggest fixes (downgrade second primary button to secondary)
- Apply the fixes
- Re-validate to confirm compliance
- Show the resolution flow with helpful explanations
The auto-fix flow displays:
- Constraint triggered: Initial violations detected
- Suggested fixes: JSON patch operations
- Resolution applied: What constraints fired and what they did
- Node decisions: Actions applied to specific nodes
- Final state: Compliant view with resolved components
- Next.js 16 - App Router with TypeScript
- Tailwind CSS - Styling
- shadcn/ui - Demo shell UI components only
- React - Component rendering
The resolver and renderer logic are fully implemented. The system:
- Parses natural language prompts deterministically
- Validates component props against contracts
- Enforces design constraints
- Resolves design tokens to CSS values
- Renders pure HTML elements with inline styles
- Provides MCP server for AI agent integration
- Supports auto-fix for constraint violations
/tokens- Design tokens (colors, spacing, typography, etc.)/contracts- Component contracts (props, variants, defaults)/constraints- Design constraints (rules and limits)/resolver- Core resolution logic (parseIntent, resolveComponent, validate, suggestFixes)/renderer- Component renderers (pure React components)/mcp- MCP server implementation/app- Next.js demo application
Design Systems scale consistency.
Design Models scale decision-making.
MIT
