---
name: design-check
description: Use when checking a frontend against its design contract, running a design sweep, polishing or modernising UI, or when the user asks whether the UI follows the spec. Reads .design/spec.json from the current repo.
---

# Design check

Checks a frontend against the design contract committed at `.design/spec.json`,
combining a deterministic pass with judgment the script cannot supply.

## Preconditions

Read `.design/spec.json` first. If it is absent, the repo has no contract — go
to **Init** below rather than inventing one.

## Modes

| Invocation | Scope |
| --- | --- |
| `/design-check` | files changed on this branch |
| `/design-check <path or surface>` | that path prefix |
| `/design-check --all` | every route in the inventory, plus shared components |
| `/design-check --init` | create or reconcile the spec |

## Running a check

1. **Deterministic pass.** Run `pnpm --silent design:check --json` with the
   same arguments (a path prefix, or `--all`; omit both for the changed-files
   default). The `--silent` flag is required — without it, pnpm writes its own
   run banner to stdout ahead of the JSON, and a naive `JSON.parse` on the
   output fails. Parse the envelope:
   `{ violations: number, judgment: number, findings: Finding[] }` — the two
   numbers are counts; every finding is in `findings`, tagged by its own
   `severity`, as `{ rule, severity, file, line, message, fix? }`, where
   `severity` is `"violation"` or `"judgment"`. Never re-derive these by
   reading files — the script is authoritative for everything it covers, and
   duplicating it wastes context and risks disagreeing with it.

2. **Choose what to read.** Every file the script flagged, plus the `page.tsx`
   and immediate components of each route in scope. On `--all`, work through
   the route inventory in order. Do not read the whole tree.

3. **Judge what the script cannot.** For each surface, against the spec:
   - **Hierarchy** — exactly one primary action? A second `variant="default"`
     in the same view means neither reads as the main thing.
   - **Voice** — measure copy against `spec.voiceRules`. Buttons name their
     outcome. An action keeps its name through the whole flow. Errors state what
     happened and how to fix it, and never apologise.
   - **Empty and error states** — does each offer the next action, or dead-end?
   - **Token meaning** — a token used against its stated `means` or inside its
     `notFor` is a real finding even where the class name itself is legal.
   - **Job and signature** — does the surface do the `job` its route entry
     claims, and is its `signature` actually present and load-bearing?
   - **Currency** — does anything read as dated or unconsidered? Say what and
     why, in terms of the spec.

4. **Report, ranked.** Violations first, then judgment. Every finding carries
   `file:line`, what is wrong, and the specific replacement. Group by file.
   State the count of each severity up front.

5. **Stop.** Do not edit. Ask which findings to apply, then apply only those.

## Init

`--init` is this skill scanning and authoring the contract — there is no
equivalent flag on the script; it always reads an existing spec and errors if
one is missing. Build the contract by scanning, then adjudicating.

1. Read the theme/token source (`globals.css` or equivalent), the component
   variant definitions, every call site, and the route tree.
2. Where the codebase is **unanimous**, write it into the spec silently.
3. Where it **contradicts itself**, bring the conflict to the user with both
   readings and a recommendation. Their answer becomes the rule.
4. Give every token a `means`. A token with no stated meaning cannot be
   misused, so it can never be checked.
5. Record every route with its `surface`, `auth` and `job`.
6. Against an existing spec, reconcile — never overwrite. Report what changed.

## Rules

- **The script owns the mechanical findings.** Do not re-check raw colours,
  arbitrary values, or class overrides by reading source. Report what it found.
- **A finding names its fix.** "This feels cluttered" is not a finding.
- **Suppressions are legitimate.** A `design-check-disable-next-line <rule>:
  <reason>` comment with a stated reason is a decision already made. Do not
  re-litigate it.
- **The spec is the authority, not your taste.** Where you disagree with the
  spec, say so as a proposed spec change — do not quietly apply your preference.
