Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
johnlindquist avatar

Uxspec

  • 2 installs
  • 5 repo stars
  • Updated March 20, 2026
  • johnlindquist/uxspec

Walks through building a .uxspec.json file that unifies a component's state machine and visual specification, then compiling and verifying the output.

About

An interactive workflow for creating UXSpec files, gathering requirements, designing the state machine, defining visuals, then compiling and verifying. A developer uses it when they want to scaffold a .uxspec.json describing a component's states and visuals for AI agents.

  • Phased flow: requirements, state machine, visuals, compile, verify
  • Every compound state needs an initial child; events map to guarded transitions

Uxspec by the numbers

  • 2 all-time installs (skills.sh)
  • Ranked #1,564 of 1,880 Design & UI/UX skills by installs in the Skillselion catalog
  • Data as of Aug 2, 2026 (Skillselion catalog sync)
npx skills add https://github.com/johnlindquist/uxspec --skill uxspec

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs2
repo stars5
Last updatedMarch 20, 2026
Repositoryjohnlindquist/uxspec

What it does

Walks through building a .uxspec.json file that unifies a component's state machine and visual specification, then compiling and verifying the output.

Files

SKILL.mdMarkdownGitHub ↗

UXSpec Builder

Interactive workflow for creating UXSpec files — the JSON format that unifies state machines and visual specifications for AI agents.

Trigger

Use when the user wants to create, build, or scaffold a .uxspec.json file, or asks "help me write a uxspec".

Workflow

Follow these phases in order. Each phase produces a concrete artifact before moving on.

Phase 1 — Gather Requirements

Ask the user: 1. What is this component/page? (e.g., "login form", "toast notifications", "media player") 2. What are the key states? (e.g., "idle, loading, error, success") 3. What events drive transitions? (e.g., "SUBMIT, INPUT_CHANGED, HTTP_OK, HTTP_ERROR") 4. What context data is needed? (e.g., "email: string, password: string, error: string | null") 5. Any reusable elements? (e.g., "input field with label, action button")

Summarize back to the user as a bullet list before proceeding.

Phase 2 — Design the State Machine

Build the $machine section:

  • Define compound states (parents) and leaf states (children)
  • Every compound state needs an initial child
  • Map events to transitions with optional guards and actions
  • Add entry/exit actions where needed (e.g., set loading flag, clear errors)
  • Add invoke for long-running effects (HTTP calls, timers)

Present the state graph as a text diagram:

idle --SUBMIT--> loading
loading --HTTP_OK--> success
loading --HTTP_ERROR--> error
error --RETRY--> loading

Phase 3 — Define Tokens and Visuals

1. Define $tokens — colors, spacing, radius, font, timing (follow W3C Design Tokens format) 2. Define $elements — reusable element templates with params 3. Add $visual to each leaf state — container layout, slots with elements 4. Add testId to interactive elements for assertions 5. Add aria labels for accessibility

Read references/format-reference.md for token syntax, element types, and visual structure.

Phase 4 — Add Runtime Semantics

1. Define $context — typed fields with defaults 2. Define $events — with source and payload types 3. Define $actions — assign, emit, log 4. Define $effects — http, timer, navigate, focus 5. Wire binding, visibleWhen, enabledWhen, onPress, onChange on elements

Read references/runtime-semantics.md for expression syntax and action/effect kinds.

Phase 5 — Generate and Verify

1. Write the spec to examples/<name>.uxspec.json 2. Validate: bun run src/compiler/cli.ts validate examples/<name>.uxspec.json 3. If validation fails, fix reported issues (the compiler returns structured issue codes) 4. Compile: bun run src/compiler/cli.ts compile examples/<name>.uxspec.json 5. Inspect: bun run src/compiler/cli.ts inspect examples/<name>.uxspec.json 6. Report to the user:

  • Number of states and assertions
  • Whether initial resolves to a leaf state
  • Any unresolved refs or token aliases
  • The compiled output path

Issue Resolution

If the compiler reports issues, map codes to fixes:

CodeFix
UNDECLARED_CONTEXT_VARAdd missing field to $context
UNDECLARED_EVENTAdd missing event to $events
UNDECLARED_TARGETFix transition target to match a valid state path
UNSUPPORTED_EXPR_OPReplace with a supported operator (see spec)
INVALID_ASSIGN_PATHEnsure path starts with context.
UNKNOWN_TOKEN_REFERENCEAdd missing token to $tokens or fix the path
UNKNOWN_ELEMENT_REFERENCEAdd missing element to $elements or fix the name
INVALID_MACHINE_INITIALSet $machine.initial to a valid top-level state
INVALID_COMPOUND_INITIALSet compound state initial to a valid child name

Key Rules

  • File extension: .uxspec.json
  • Schema: https://uxspec.dev/0.2/schema.json
  • Required top-level: $schema, $description, $machine
  • $machine requires: id, initial, states
  • Leaf elements (text, button, input, icon, shape, badge, bar) MUST NOT have children
  • Container elements (group, layer, grid, stack-h, stack-v) MAY have children
  • Token references: "{path.to.token}" — curly braces inside a string
  • Element references: { "$ref": "name", ...params }
  • Expressions: S-expression arrays like ["==", ["var", "context.x"], true]
  • All $-prefixed properties are reserved

Reference Files

  • references/format-reference.md — Token syntax, element types, visual structure, layout primitives
  • references/runtime-semantics.md — Context, events, actions, effects, expressions, transitions
  • references/minimal-example.md — Complete minimal spec you can use as a starting template

Related skills

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.