Visual organ for UI projects: one design contract (tokens, references, screen states), captures by named state, deterministic checks, and a fresh critic that decides within the contract while the user reviews after. Use on /visual setup, audit, verify, rollback, break, match (rebuild a UI to match a reference image, scored), or when /cycle runs a UI project.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Visual?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ackeskin-visual)
---
name: visual
description: "Visual organ for UI projects: one design contract (tokens, references, screen states), captures by named state, deterministic checks, and a fresh critic that decides within the contract while the user reviews after. Use on /visual setup, audit, verify, rollback, break, match (rebuild a UI to match a reference image, scored), or when /cycle runs a UI project."
disable-model-invocation: true
---
# visual
The **visual organ**. Text-reading organs cannot see a UI, compare a screen with its siblings, or keep a theme steady, and a model asked for a coherent look re-derives its taste every run. This organ fixes the taste in a **contract** the user writes once, then checks every change against it: fresh captures of named states, deterministic checks, and a **fresh critic** that decides within the contract. The user reviews the critic's decisions afterwards on the cycle status page and can roll any baseline back.
Its rules come from a hand-run on a real UI project, where an uninstructed critic got 2 of 5 findings wrong: a stale screenshot, and a deliberate choice recorded in a code comment. So every claim cites a contract line, is checked against the code, and uses captures of the current head.
`visual.mjs` next to this file does all the deterministic work; this file says when to run it and what the critic must do. `<skill-dir>` means the folder holding this file.
## When to run
- `/visual setup` — write the contract, once per project, with the user present.
- `/visual audit [run]` — find visual gaps for an audit; never fixes.
- `/visual verify <run>` — inside a cycle's stage 4: capture what the change touched and hand it to the loop's critic.
- `/visual critic <run>` — **only** as the loop's headless critic session.
- `/visual rollback <state>` — restore an earlier baseline.
- `/visual match <reference> [--level structure|faithful|exact]` — rebuild a screen or component to match a reference image, scored until it passes. No contract needed.
- `/visual break <component>` — render one component under every worst case that can reach it, on a throwaway page, and report what broke. Procedure: [break.md](break.md).
- User-invoked, or run by `/cycle` when `.claude/visual/contract.json` exists. Never on its own.
## Setup
1. **Canonical tokens.** Find the file that holds the design tokens (JSON, CSS custom properties, a theme file). Ask which one is canonical when there are several, and list the others as `copies`. Design tokens in several places drift; the organ reads only the canonical file and reports drift in the copies. A plugin styled through its host's theme variables carries its values only as fallbacks (`var(--interactive-accent, #6965db)`); those fallbacks are read as tokens too.
2. **References.** Ask for 3 to 5 images (the project's own best screens, other products, mood images), each with one line on what to take from it. Copy them under `.claude/visual/references/`.
3. **States.** List the states that matter, not only the screens: for example a card you can afford, one you can't, and a maxed one. Each state names what it shows, the command that writes its image (no env prefix; variables go in `env`), and the output path. Reuse the project's own screenshot tooling. States that share one command and env run it once. When the capture starts a dev server on a fixed port, set `capture_port` (or a state's `port`): a capture refuses to run while something else already listens there, because a reused server may be serving another tree. Add setting states for the main screen when the UI ships to people who set them (ui-floor-settings): `dark`, `contrast-more` and `forced-colors` (Playwright: `page.emulateMedia({ colorScheme: 'dark' })`, `{ contrast: 'more' }`, `{ forcedColors: 'active' }`), and `zoom-200`: half the viewport width at `deviceScaleFactor: 2`, which is what 200% browser zoom renders.
4. **Style dump (optional).** A command that writes computed styles as JSON (`state`, `selector`, `color`, `background`, `fontSize`, `scrollWidth`, `clientWidth`). With it the checks cover off-contract values, contrast and overflow; without it only pixel diff runs.
5. **Tells and critic settings.** Show the default tell list (`contract-defaults.json`) and ask which, if any, this project allows. `critic.scope` is `touched+1` by default (the touched states plus one unchanged sibling) or `all`; `critic.image_cap` defaults to 12. `diff.noise` (default 0.01, or a state's own `noise`) is the share of pixels two captures of the same code may differ by (font hinting, thumbnail timing) before a change is reported.
6. Write `.claude/visual/contract.json` after the user confirms it, then run `node <skill-dir>/visual.mjs contract <repo>` and `drift <repo>`. Make sure `.claude/visual/` is gitignored (propose the line; never add it silently).
```json
{
"tokens": { "source": "docs/design/tokens.json", "copies": ["src/theme.css"] },
"references": [{ "file": ".claude/visual/references/hud.png", "take": "dense but calm HUD" }],
"states": [
{ "id": "shop-affordable", "shows": "merchant, enough gold", "command": "npx playwright test tests/e2e/shots.spec.ts -g shop-affordable", "env": { "SHOTS": "1" }, "output": "docs/screens/shop.png" }
],
"style_dump": { "command": "npx playwright test tests/e2e/styles.spec.ts", "output": "out/styles.json" },
"tells_off": [],
"critic": { "scope": "touched+1", "image_cap": 12 },
"notes": "Cyan glow is only for the time loop, Convergence UI and sci-fi heroes."
}
```
## Audit (`/visual audit`)
1. `node <skill-dir>/visual.mjs capture <repo> --out <run>/visual/audit --tree <worktree of origin/base>` for every state.
2. Diff each capture against its baseline, run `styles` when a dump exists, and run `node <skill-dir>/slop.mjs <repo>`: the tells and ui-craft slips that show in code (gradient text, glow, glass, bounce, reflex fonts, emoji icons, made-up stats, removed focus outlines, clickable divs). It needs no contract and respects `tells_off`. For a page a URL can load, run `node <skill-dir>/align.mjs --url <url>`: it lists edges 1-3px off a line other boxes share, and text under 11px or click targets under 24px (in your own Playwright spec: `page.evaluate(probe)` and `page.evaluate(sizeProbe)` from `align.mjs`, then `align.mjs <boxes.json> --sizes <sizes.json>`).
3. Look at the captures against the contract, the references and the tell list, and list gaps under the audit's *Polish* heading: state, region, the contract line, the evidence. **Check every claim against the code first**: a code comment can record that a "defect" is deliberate. A gap the contract does not settle is a taste-call row, not a defect.
## Verify (`/visual verify <run>`, inside stage 4)
Inside a `/cycle` run, **the loop** takes the captures, not the stage: after stage 4 records `done` it cuts a worktree of `origin/<base>`, runs setup's `install` there, captures every state into `<run>/visual/before`, captures every state from the run branch's worktree into `<run>/visual/after`, and runs `visual.mjs touched`, which diffs each pair above that state's `noise` and writes `touched.json`. A failed capture parks the slice with the capture's error. No change above the noise in any state means no critic.
What stage 4 still does:
1. Leave the run branch's worktree in place and built.
2. Run `slop.mjs <repo> --since origin/<base>` on the run's worktree and fix what it finds, or mark the line `slop-ok: <why>` when the contract or brief asked for it. Run `styles` when a dump exists, and write findings to `<run>/visual/findings.json`. `styles` groups findings by likely cause and puts the biggest effect first: when one selector holds all the others in a group, it is the `cause`, so fix it there and the rest follow. Fix from the top. A contrast finding carries `fix`: `token` is the nearest contract color that passes (use it first); `shift` is the same color with only its OKLCH lightness moved, for when no token fits (add it as a token). `visual.mjs contrast <fg> <bg> [--large] [--tokens <file>]` gives the same for one pair, with no contract. Optionally write `<run>/visual/touched.json` with `regions` (`{ "<state>": "x,y,w,h" }`) for the parts you changed; the loop keeps them.
3. Stop there. **Do not judge your own work.** The loop starts the critic as its own session once stage 4 records its outcome. On a rerun of stage 4 after the critic asked for a revision, read `<run>/visual/verdicts.json` and fix each `needs-revision` first.
## The critic (`/visual critic <run>`, headless only)
You are the critic: a fresh session that has not seen how the change was made. Judge only what the files show.
1. Read `<run>/visual/critic-input.json`. It lists the states to judge, their before / after / baseline images, the references with what to take from each, the contract summary, the active tells, and the deterministic findings.
2. Look at every image it lists, and nothing else of the run's history.
3. For each state, decide one verdict:
- `consistent`: it matches the contract and its sibling. Cite the `contract_line` you checked it against.
- `needs-revision`: name the `region`, the `contract_line` it breaks, and the `evidence`. Only for a real contract line; no line means it is not a revision.
- `taste`: a real choice the contract does not settle. **Choose** an option yourself, and record `taste.chose`, `taste.alternatives` and `taste.why`. The user reviews it later; a disagreement there becomes a new contract line.
4. **Check each claim against the code** before you write it (grep the selector, the token, the comment near it), and set `checked_against_code: true`. A claim you could not check is not a verdict; leave it out and say so in `evidence` of the nearest one.
5. Write the list to `<run>/visual/verdicts.json` and stop. The loop validates it, rejects stale captures, records each decision and moves baselines on approval.
## Match (`/visual match`)
Rebuild what the user points at in their own code, then prove it with a score. Done is when `match` exits 0, not when it looks right to you.
1. **Scope.** State the reference, the destination file or route, the stack, and the level. `structure` (0.80 of pixels): "like this, with our brand". `faithful` (0.90, default): "clone this". `exact` (0.97): "pixel-perfect". Ask only when two readings lead to different work.
2. **Reference.** An image as given. A URL: screenshot it at the viewport you will ship with the project's capture tool (Playwright when nothing else). Save it under `.claude/visual/match/<name>/reference.png`.
3. **Build** with the project's own stack and tokens: tokens, layout, type, paint, then media. Take sizes and colors from the reference, not from memory of similar sites.
4. **Score.** Capture the build at the reference's size, then `node <skill-dir>/visual.mjs match <reference.png> <capture.png> --out .claude/visual/match/<name>/round-<N> --level <level>`. It passes when the whole frame and the reference's content both clear the bar (`layout`, any color, for structure; `content` for the others), so an empty page of the right background fails. Open `diff.png`, fix the top hotspot (or the top 2-3 if they share a cause), recapture, score again.
5. **Stop** at a pass or after 5 rounds. Report the score per round. After 5, list each area that still differs with the reason (licensed font, missing asset, motion).
Never game the score: no screenshot of the reference embedded in the build, no iframe of it, no editing files under `.claude/visual/match/`, no lowering the level. Use the user's own assets and copy; say which reference assets you reused. Pixels only: motion is not scored here (try `NiazMorshed2007/reanimate`), so say so when the reference moves.
## Before you finish
Applies to audit, verify, critic, break and match. Report only checks that ran on the final captures; name a skipped check as skipped.
| Mistake | Fix |
| --- | --- |
| A verdict on an image you did not open | Open every listed image after the last change, or drop the verdict |
| A capture older than the head it judges | Recapture; the loop rejects stale captures anyway |
| A "defect" a code comment calls deliberate | Grep near the selector before writing it; it is `consistent` or `taste` |
| `needs-revision` with no contract line | Make it `taste`, or a proposed contract line |
| A fix that only removes things (labels, rules, cards) and leaves the screen thin | Removing a tell is half the fix; replace it with real content or larger type, as the contract allows |
| "All checks pass" when the style dump did not run | Say pixel diff only |
## Rollback
`node <skill-dir>/visual.mjs rollback <repo> <state> [history-file]` restores the newest earlier baseline (or the one named). The current baseline goes to history first, so a rollback can be undone. The status page's Visual view has the same button.
## What visual does NOT do
- **Not a design generator.** It checks and compares; the implementer makes the UI.
- **Not a capture framework.** The project declares its capture commands. `break` builds a throwaway page but captures it the same way.
- **Not on by default.** Only repos with a contract.
- **Not the implementer's judge of itself.** The critic is always a separate session with a brief built from files.
## Relationship to other organs
- **cycle** — runs `audit` at stage 1, `verify` at stage 4, and the critic as its own session after stage 4; its status page carries the Visual view.
- **review** — reads code; this reads screens. Stage 4 runs both.
- **artifact-design** — guides building Artifacts; the default tells overlap with its list on purpose.