Skip to content
onsystemv0.12.1

Help

How it works

onsystem reads the design system from source into one model, then checks UI code against it in three places: the Claude Code hook after every edit, check_ui when an agent asks, and onsystem check in CI. Everything is static analysis: no model calls, no API key, and no network requests of its own: installed in the project, it runs offline, and through npx only npm contacts the registry (when).

Sources (components, tokens, docs, config) flow through the TypeScript checker, a cva parser, token parsers and a docs parser into a cached design-system model with a BM25 index, an OKLCH token index and the lint rules, served by an MCP server over stdio and by the check CLI, which the Claude Code hook and CI run.

Your design system

Components

  • components/ui/*.tsx

Tokens

  • globals.css
  • *.tokens.json (DTCG)

Docs

  • docs/*.md, *.mdx

Config (optional)

  • onsystem.config

Extract

TypeScript checker

  • props, defaults, JSDoc

cva() / tv() parser

  • variants and classes

Token parsers

  • DTCG · CSS vars · @theme

Docs parser

  • guidelines, examples

Model

Design-system model

  • components, tokens, docs; cached on disk, rebuilt on change
  • BM25 index

    intent search

  • Token index

    nearest color, OKLCH

  • Lint rules

    8 rules, with fixes

Interfaces

MCP server · stdio

  • list_components
  • get_component
  • search_components
  • get_tokens
  • check_ui
  • ds://tokens
  • ds://components/{name}

Hook · CLI · CI

  • Claude Code hook
  • onsystem check
  • --format github

Clients: Claude Code · Cursor · VS Code · any MCP client, and CI (GitHub annotations, exit codes)

  1. Components. One TypeScript program over the component files, with the project's tsconfig (so path aliases and dependency types resolve). For each exported PascalCase function, forwardRef, memo or class component, and each alias of a library component (const Dialog = DialogPrimitive.Root), the checker gives the props type. Props declared in the project, or by packages such as Radix, are listed with types, required flags, defaults (from destructuring, @default or defaultVariants) and JSDoc. React's DOM attributes are summarised as "…plus 290 props from React.ComponentProps<"button">" but kept in full for linting. When dependency types are missing, extraction falls back to what resolves and marks the props as open, so the linter does not guess.

  2. Variants. cva() and tv() calls are read from the AST: values in declaration order, defaults, per-value classes and compound variants. They are linked to a component through VariantProps<typeof x> or a call in the className of the element it returns; a definition used further in (a spinner's loaderVariants) only adds the variants the component's own lack and that it takes as props. Without either, a call anywhere in its body links it. Boolean keys named like a render state (isDisabled, isPending, as React Aria's starter passes renderProps to tv()) style a state rather than offer a variant, so they are not listed as variants, and a key declared by two linked definitions is listed once.

  3. Composition. Flat parts (CardHeader next to Card in card.tsx, but not a lone container such as CheckboxGroup next to Checkbox), static members (Card.Header = CardHeader) and Object.assign(Root, { List }) (members exported or not, shorthand included) become parent/part relationships. The wrapped native element comes from ComponentProps<"button">, ButtonHTMLAttributes<HTMLButtonElement>, the forwardRef element type, or the rendered JSX (including const Comp = asChild ? Slot : "button").

  4. Published libraries. An app built on a component library installed from npm (MUI for now) has its design system in node_modules. The same checker reads the library's type declarations, the files the app's own imports resolve to, together with the app's module augmentations: each exported component with the props of each of its signatures, string-literal values as variants, and the element it renders. Tokens come from the theme the app creates, where its values are written out. The project's own components win a shared name (details). A design-system package installed with compiled code and .d.ts files, whose component sources the app does not read (dist/ alone, or src/ beside exports into dist/), is read the same way: one that declares its config (design-system packages); without one, one named like a design system in the app's own npm scope (@acme/ui for @acme/web); or, in any app, the dependency its config names as importPath ("importPath": "@dub/ui"). Its declarations give the components and their props, cva variants as tsc and tsup emit them, parts and the elements they render; a package with no entry of its own is read from each subpath it exports (@acme/ui/button). Tokens come from its config or the stylesheets the app imports from it.

  5. Model. Components, tokens and docs form one JSON model, cached in node_modules/.cache/onsystem and keyed on the sizes and mtimes of the component, token and docs files, the project files the components import and the tsconfig chain, plus the lockfile, the config and the package version. The server answers server/discover and the initialize handshake immediately and loads in the background; requests wait for the load. List results carry 2026-07-28 cache hints: the tools, prompts and resource templates for an hour, the component resources not at all, both private to the client. File changes trigger a rebuild that reuses the previous TypeScript program, an edited config file is read again, and clients are notified that resources changed.

  6. Lint. check_ui parses the snippet on its own (no type-checking), resolves each JSX tag through its imports (named, default, namespace, relative, and barrels such as @/components/ui or ../components/ui) to a design-system component, and runs the rules against the model. Fixes are text edits with offsets, so an agent or a tool can apply them mechanically.

Run as is, with no config, on public apps: the counts the corpus snapshot records, rechecked on every pull request that changes the rules. These counts are not a judgement of the teams: hardcoded values and unlabeled icon buttons slip through review everywhere, and agents copy what they see.

  • vercel/ai-chatbot c2f8235

    Found with zero config
    components.json → 23 components, 52 tokens
    check findings
    73 in app/ and components/: 41 raw colors, 19 native elements the design system wraps, 12 icon-only buttons without an accessible name, 1 arbitrary radius
  • midday 5158731, apps/dashboard

    Found with zero config
    workspace package @midday/ui → 79 components
    check findings
    1,340 in src/, including 98 icon-only buttons without an accessible name. Adopted with a baseline
  • shadcn/ui website 0132174

    Found with zero config
    custom ui alias → 68 components
    check findings
    124 in app/ and components/, mostly raw colors (105)

Reading the design system is the slow part: one TypeScript program over the component files. check and the server cache what they read and read it again only when those files change, so checking a file after that is syntax work. The hook runs one check per edit to a UI file. Without onsystem installed in the project, it runs check through npx on the first edit in a project, which starts npm first; later edits there run the CLI npx installed with Node.js directly (how). A dev dependency (pin the version) takes npm out of the first edit too.

Measured with onsystem 0.11.0 on Apple M1 Max (10 cores, 32 GB), macOS 27.0.1, Node.js 24.18.0, on 2026-10-29, with node scripts/perf.mjs: each time is the median of 5 runs. The corpus checkouts have no node_modules, so the types of the libraries their components wrap are not read: in a project with its dependencies installed, reading the design system takes longer. The demo, where the hook is measured, has its dependencies installed.

  • check on vercel/chatbot c2f8235 (app and components: 61 files)

    Result
    0.51 s, or 0.80 s with --no-cache. One file: 347 ms, then 2.6 ms for each other file
  • check on midday-ai/midday 5158731 (apps/dashboard/src: 569 files)

    Result
    1.35 s, or 1.68 s with --no-cache. One file: 465 ms, then 1.6 ms for each other file
  • The Claude Code hook on one edit (the demo's app/settings/danger-zone.tsx), with onsystem installed in the project

    Result
    364 ms
  • The same edit through npx, as the plugin runs it in a project without an install (onsystem@0.11.0 in npm's cache)

    Result
    1.14 s
  • The MCP server on midday-ai/midday 5158731 (apps/dashboard, 79 components): initialize answered

    Result
    422 ms after it starts
  • Its first tool call, which waits for the design system to be read (--no-cache)

    Result
    0.80 s after it starts
  • check_ui on the app's largest file (1,349 lines)

    Result
    13 ms
  • search_components, get_component (Button)

    Result
    0.5 ms, 0.4 ms
  • The package (onsystem@0.11.0 on npm)

    Result
    0.9 MB unpacked, 16 files, 8 dependencies
  • Installed with npm into an empty project

    Result
    15 packages, 42.2 MB on disk (24.3 MB of it TypeScript, which reads the components)
  • Provenance

    Result
    Signed npm provenance (slsa.dev/provenance/v1): npm shows the workflow run and commit each release was built from

These tools work at different layers, and several combine well:

  • onsystem

    What it knows
    Your components' props, cva variants, parts, tokens and docs, read from source
    Checks what the agent wrote
    Hardcoded colors, spacing and radius; native elements the design system wraps; components, props and variants it lacks; icon buttons without a name
    Needs
    Nothing to run or write: zero config for shadcn-style projects (Tailwind v3 or v4) and design-system packages
  • @shadcn/lint

    What it knows
    Your components, variants and theme, found through components.json in shadcn/ui projects, plus per-component contracts you can write
    Checks what the agent wrote
    Tailwind classes: restyling a component, raw colors, arbitrary values, inline styles, unknown and dynamic classes
    Needs
    ESLint 9.30+ or Oxlint, Tailwind v4; React, Svelte or Vue
  • Storybook MCP

    What it knows
    Stories and a component manifest
    Checks what the agent wrote
    Runs component tests, including accessibility checks if set up
    Needs
    A running Storybook (10.6, preview)
  • shadcn MCP

    What it knows
    Registries: what you can install
    Checks what the agent wrote
    —
    Needs
    —
  • Figma MCP

    What it knows
    The design: frames, variables, Code Connect
    Checks what the agent wrote
    —
    Needs
    Figma

@shadcn/lint is a linter: it polices the classes written against a component and the theme, in React, Svelte and Vue, on Tailwind v4. onsystem gives the agent the components, props, variants and tokens before it writes, and catches what does not exist (components, props, variant values) along with native elements and missing accessible names, on Tailwind v3 or v4, without Storybook or a design file. Running both in CI is a sensible setup.

Static analysis, not another model. The agent is already the LLM; what it lacks is ground truth. Everything here is deterministic, checks a file in milliseconds once the design system is read (measured), makes no network requests, needs no API key, and can be unit-tested rule by rule. The cost: it cannot judge intent, such as whether a Dialog was the right call. That stays with the agent and the reviewer.

The TypeScript checker over react-docgen-typescript. react-docgen-typescript wraps the same API but hides the AST, and cva() parsing, composition and element inference all need it. One program serves all four. The runtime dependency is TypeScript 6, the last release with the JavaScript compiler API; TypeScript 7 (the Go port) does not expose a stable one yet.

Syntactic linting. Agents check fragments they have not saved, often without imports. Type-checking those would need the whole program and would fail on the fragment's missing context. check_ui complements tsc: it catches what types cannot express (tokens, native elements, accessible names) and says what to write instead.

BM25, not embeddings. A design system is tens to a few hundred documents whose vocabulary already lives in names, docs and variant values. Field-weighted BM25 with Porter stemming and a small synonym map ("modal" → Dialog, "delete" → destructive) ranks them well, deterministically, with no model download or API key. It does not understand paraphrases the synonym map does not cover.

OKLCH for nearest colors. Distance in OKLCH (ΔE in OKLab) tracks perceived difference, so the suggested token is the one that looks closest, not the one with the closest hex digits. It also matches how Tailwind v4 and shadcn/ui define colors.

Markdown for the model, JSON for programs. Tool results put compact Markdown in content, which costs fewer tokens than JSON and reads well to a model, and the full JSON in structuredContent for clients and scripts.

  • React only (.tsx and .jsx): no Vue, Svelte or Angular yet.

  • Styling is checked in Tailwind classes, style objects (including style functions and each branch of a conditional value) and color attributes. CSS-in-JS (styled-components, Emotion), CSS Modules and plain stylesheets are not.

  • Fix suggestions are Tailwind classes when a Tailwind theme maps the token (@theme, or a v3 tailwind.config), otherwise var(--token) (hsl(var(--token)) or rgb(var(--token)) for v3 channels). A v3 config is read without running it, so colors computed in code are not seen.

  • Colors are compared in the base theme and, for dark: classes, the dark mode. Other modes ([data-theme="brand"]) are listed by get_tokens but not used to match.

  • Linting is per file and syntactic. Class names built at runtime (`bg-${color}-500`) are not checked, and spread props are trusted. Class strings are read in className, class and the arguments of cn, clsx, cva and the like, and followed to a const, a const object map (className={statusStyles[status]}) or a function of the same file; one from another file, a parameter or a let is not followed, nor are classes in other props (tw).

  • no-unknown-prop is skipped for components whose props type does not fully resolve (dependencies not installed, which check, check_ui and inspect then say).

  • Composition is inferred from naming and static members; other patterns need explicit exports.

  • A UI package imported by path is read from what the app already imports (in its first 5,000 source files), so components nobody imports yet are not offered.

  • While the server runs, it rebuilds on changes in the component, token and docs folders, the config file, the tsconfig and the tsconfigs it extends. An edit to another file the components import (a shared lib/types.ts), or to an MUI theme or module augmentation, is picked up on the next start.

  • At a monorepo root, the server reads the list of projects when it starts; a package that gains a design system while it runs is listed from the next start, though its files are checked by it right away.

  • A design-system package published without its component sources is read from its type declarations only when it declares its config, is named like a design system in the app's own scope, or is the app's importPath: a kit from another scope named like one (@sanity/ui, @react-email/components) is not taken for the app's design system unless the app's config says so, and inspect --explain says what would make such a dependency read. Declarations carry no classes, so its components' classes and CSS variables are not known. A package whose .tsx sources the app reads (through its config's components, or exports that point at them) is read from those sources alone. A bundle's one index.d.ts declares every component in one file, so parts go by name only in families of two or more (CardHeader and CardContent next to Card, not ButtonTooltip next to Button), and icons have none. A package with an entry of its own is read from that entry alone, not its other subpaths.

  • Published libraries: MUI (@mui/material) only so far; Chakra UI, Mantine, HeroUI, Radix Themes and Ant Design are not read yet (inspect lists them on its library line, and check says so in a project without components of its own), nor are MUI's other packages (@mui/lab, @mui/x-*). MUI's sx and styled() styles are not checked for hardcoded values. Its theme is read where its values are written out; a palette computed in code or from Sass variables is not, so no-hardcoded-color does not run on such an app. --require-design-system (and the GitHub Action, where it is on by default) still passes it, since MUI's components are its design system, and says that the rule did not run. In a JavaScript app, values a computed theme adds beyond palette groups and variants written out are not known and can be reported.

  • No typography or shadow rules yet, and stdio is the only transport.

Edit this page on GitHub

Last updated