ui
AGENTS.md11 starsChanged 6 days agoMITView on GitHub
Instructions for AI coding agents working in bydiorama/ui. Humans: start with README.md, then CONVENTIONS.md. Where the library currently stands, and what closes each open gate, is PLAN.md — measured, with the command behind every number. Read it before proposing what to build next; the build order there is not the order in TODO.md's design list, and the difference is deliberate. The Diorama design system: design tokens, React components, and the docs and tooling around them. Consumed by Diorama products as…
- Commits and pushes
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 35,117 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository15 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- add-componentSkill
- app-motionSkill
- craftSkill
- create-skillSkill
- demo-pageSkill
- design-componentSkill
- effectsSkill
- motion-componentSkill
- motion-mediaSkill
- review-uiSkill
- static-renderingSkill
- stills-renderSkill
- video-renderSkill
- visual-reviewSkill
The file
We split this AGENTS.md into the rules it gives an agent
8 rules. About 0 are common, 5 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 23
Typed sources beat prose: If you find yourself documenting a constraint in markdown, ask whether it can be a type, a lint rule or a CI …
- Very specific: line 60
Run pnpm verify before considering any change done.
- Very specific: line 96
Create registry/ui/<name>/ with the component, its *.doc.ts, and stories.
- Distinctive: line 153
Do not commit or push anything without explicit consent — see § Git.
- Distinctive: line 154
Do not add a third-party component library, design language, block set or theme preset.
- Very specific: line 157
Do not hand-edit generated files (registry.json, r/*.json).
- Distinctive: line 158
Do not widen a component's API to avoid a composition problem — slots and hooks exist for that.
- Distinctive: line 160
Do not skip the ledger entry because a change "is small".
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
Instructions for AI coding agents working in bydiorama/ui.
Humans: start with README.md, then CONVENTIONS.md.
Where the library currently stands, and what closes each open gate, is
PLAN.md — measured, with the command behind every number. Read it before
proposing what to build next; the build order there is not the order in
TODO.md's design list, and the difference is deliberate.
What this is
The Diorama design system: design tokens, React components, and the docs and tooling around them. Consumed by Diorama products as source — apps copy components in rather than installing a package — so everything here is written to be read, owned and modified downstream.
Ground rules
CONVENTIONS.mdis binding. It defines prop naming, variants, composition, forwarding, styling, motion, boundaries and a11y. Read it before writing a component; do not invent a second dialect.- Typed sources beat prose. If you find yourself documenting a constraint in markdown, ask whether it can be a type, a lint rule or a CI check instead. Prose is the fallback, not the default.
- The manifest is the source of truth.
ui.manifest.jsondescribes every distributable item.registry.jsonandr/*.jsonare generated — never hand-edit them; runpnpm registry:build. - Record what you changed. Any change to a distributed item needs a ledger
entry (
pnpm ledger:new). Consumers and their agents learn what moved from the ledger, not from git archaeology.
Commands
| Command | What it does |
pnpm verify | The full local gate: manifest, registry freshness, ledger, licensing |
pnpm registry:build | Regenerate registry.json and r/*.json from the manifest |
pnpm check:registry | Fail if the generated registry is stale (CI runs this) |
pnpm check:licensing | Fail on non-distributable fonts or paid-tier assets |
pnpm skills:build | Regenerate .claude/skills/ and the ui plugin (plugins/ui/) from registry/skills/ |
pnpm check:skills | Fail on a broken skill contract or a stale generated copy |
pnpm check:boundaries | Fail if the behaviour layer leaks into a public signature |
pnpm check:motion | Fail on a literal duration, an unguarded keyframe, or undocumented motion |
pnpm check:design-spec | Fail if a design geometry spec breaks its own laws, or nothing renders it |
pnpm check:strokes | Fail on a literal stroke width (border-2, ring-[1.5px] …) — use the scale (ADR 0020 §2) |
pnpm check:type-roles | Fail on a declared type-role exception naming a part that no longer exists; the roles themselves are enforced in every story at runtime (ADR 0020 §3) |
pnpm check:fx | Fail if the effects layer drifts from EFFECTS, breaks the shader admission rule, leaves @layer fx, runs a keyframe under reduced motion, or paints more light under glass text than the resolver's floor counts (ADR 0022) |
pnpm check:token-consumers | Fail on a contract token that nothing in registry/ reads, unless it is declared with a reason (ADR 0020) |
pnpm ledger:new | Scaffold a change-ledger entry |
pnpm type-check | tsc --noEmit and the storybook project's own. Run the script, never bare tsc: apps/storybook has a separate tsconfig, and every *.stories.tsx error appears only there |
pnpm lint | ESLint |
pnpm site:data | Regenerate public library data from the manifest, typed docs, registry, contrast report and ledger |
pnpm check:site-data | Fail if the public library data is stale or a public component lacks documentation |
pnpm site:build | Build the public site and check generated routes and internal links |
pnpm site:dev | Start the local public library site |
pnpm test:site | Build and test public pages, accessibility and rendered theme preferences in Chromium |
pnpm test:cli-package | Run the packed owned CLI through npm exec in a fresh app |
Run pnpm verify before considering any change done. It needs no node_modules
— the checks are dependency-free Node scripts on purpose, so they also run in a
cold clone.
Hard boundaries
These are not style preferences; violating them breaks consumers:
- No
next/*, no i18n runtime, no data layer, no stores inregistry/. Components take strings and data as props and render links through a slot. - No licensed or paid assets. Aspekta (OFL) is the single bundled typeface
(ledger/decisions/0007). Retired faces (Saans, PT Serif) must never appear
here — not the files, not even a
font-familyreference. Same rule for paid-tier assets from third-party libraries.pnpm check:licensingenforces both. griddy-iconsonly for iconography.- Semantic tokens only for styling — no raw hex, no palette utilities.
Effects
Glass, grain, sheen, glow, shimmer and ink (registry/lib/fx) and the
optional shaders — the parametric gradient ground and halo (registry/lib/shader) are applied as a
class on a component's root — className={fx("glass")} — never as a prop
(CONVENTIONS §12, ADR 0022). Adding or changing one: the row in EFFECTS
first, then its stylesheet, then pnpm check:fx and the two browser tests
beside them. Never admit a shader that reads the page behind it.
Adding a component
The full pipeline — order of operations, tests, traps, definition of done —
is the add-component skill (registry/skills/add-component/SKILL.md).
Invoke it before starting; the steps below are the summary, not the manual.
- Design spec exists in
design/(exported from Paper) — implement against it, not against a screenshot. No spec yet? That step is its own skill:design-component(registry/skills/design-component/SKILL.md). - Create
registry/ui/<name>/with the component, its*.doc.ts, and stories. - Register it in
ui.manifest.json, thenpnpm registry:build. - Story must include the brand-theme case: rendered under theme zero and under a stress brand theme. A component that only looks right in Diorama's own colours is not finished.
pnpm ledger:newto record the addition.pnpm verify,pnpm type-check,pnpm lint.
Public registration is part of adding a component: the manifest needs
category and docs, and its typed doc needs a public lead. Run
pnpm site:data after registry and ledger changes. The public catalog,
reference routes, Markdown twins and agent index are generated from those
sources; there is no second list to register. A live specimen still needs
an explicit composition importing registry source. See
docs/public-library-workflow.md. Keep HTML references minimal and expose
the same type-checked example file in its preview and code view. Use library
controls for appearance and verify computed colors when switching schemes.
Public copy carries no changing library
or test totals.
Skills
registry/skills/ is the source of truth for every skill. .claude/skills/
and plugins/ui/skills/ are generated — never edit them. The manifest
decides which skills ship, the same way it decides which components do
(ADR 0013). Shipped skills travel as the ui agent plugin (marketplace
diorama-ui, .claude-plugin/marketplace.json), never through the registry
or the CLI (ADR 0027).
| Tier | Teaches | In the manifest | Ships as |
| Authoring | building this library | no | — (loads only here) |
| Product | using the system in an app, in Paper, in demo media | type: "skill" | ui:<directory> |
A skill's front-matter name is its directory, with no prefix. Do not install
the ui plugin while working here — .claude/skills/ already loads the same
skills.
Creating or editing one is the create-skill skill
(registry/skills/create-skill/SKILL.md) — invoke it rather than copying an
existing skill's shape. Run pnpm skills:build after any edit; check:skills
fails on drift.
Git
Never git add, git commit, git push or git tag without being asked
for that specific change. Finish the work, run the gates, report what is
done, and leave the working tree alone — staging and committing are the
maintainer's decision, not a tidy-up step. A staged tree the maintainer did
not ask for hides the diff they were about to review.
Asked to commit? Commit exactly what was agreed and nothing else. Never
git checkout/restore a file to undo your own probe — it destroys
uncommitted work alongside it.
What not to do
- Do not commit or push anything without explicit consent — see § Git.
- Do not add a third-party component library, design language, block set or
theme preset. This library is built from scratch; we interoperate with tools,
we do not inherit designs. See
README.md§ Independence. - Do not hand-edit generated files (
registry.json,r/*.json). - Do not widen a component's API to avoid a composition problem — slots and hooks exist for that.
- Do not skip the ledger entry because a change "is small". Small silent changes are exactly what strands downstream copies.
Does it match the design?
That question used to be unanswerable here: design/paper/ holds PNG and PDF
exports, which its own README calls evidence of what was approved, not
values. So it was settled by a person comparing two pictures — and a person
cannot see one pixel. Tabs' track was inset 3px at the sides and 4px top and
bottom for its whole life, past every gate.
The numbers now live in the repo. design/paper/specs/<item>.geometry.json
records what Paper lays out — gaps derived from world coordinates, not from
its declared padding, and the used border width, because both Paper's
canvas and Chromium snap a 1.5px hairline to 1px at DPR 1. Four laws in
scripts/lib/geometry-laws.mjs run over both sides:
pnpm check:design-spec— the sheet obeys the laws it declares.registry/visual/geometry.browser.test.tsx— the render obeys them and reproduces the sheet's four insets, measured in Chromium.
Neither is optional and neither is sufficient; a sheet can be internally wrong, and a component's geometry does not exist until something lays it out. Each half fails if the other has no case for a spec, so they cannot drift apart.
Coverage is partial, and the gate prints how partial — an ungated
component is not a passing one, it is an unmeasured one. Run
pnpm check:design-spec for the count; it is deliberately not written down
here. It was once ("one item, Tabs") and was still saying that after the
count had quadrupled, which is the same failure TODO.md records for the
open-questions list: a number maintained by hand is a number that goes stale
while reading as authoritative. ADR 0019 has the reasoning, including what the
perceptual half is allowed to decide (nothing: it proposes, arithmetic
disposes).
Visual regression
pnpm test:visual diffs each component's matrix against a committed baseline,
in both schemes. It is the only layer that catches what computed-style
assertions cannot — a badge whose two sizes are identical, a label hugging the
top of its row, a panel with no visible boundary. All three of those shipped.
- Baselines live in
registry/visual/__screenshots__/and are committed (explicitly un-ignored). Review a changed baseline like any other diff. - Intentional visual change? Delete the affected baseline, re-run, and commit the new PNG after looking at it.
- It has a sensitivity floor.
allowedMismatchedPixelRatio: 0.01lets a small element change colour ENTIRELY without tripping the diff — a Switch track is under 1% of its frame. Treat a green visual run as evidence about large surfaces, not proof that nothing moved. - Audit what is tracked, not just what is ignored. A failing compare writes
-actual-/-diff-PNGs relative to the vitest root, which put four of them inapps/registry/— a directory that should not exist and that no__screenshots__rule matched. They were committed. The artifact NAMES are ignored globally now; still rungit ls-files '*.png'before committing and confirm every tracked image is a baseline you reviewed. - In CI, in a container. Baselines are platform-specific: font
rasterisation differs between macOS and Linux, so the repo commits BOTH
sets —
-chromium-darwinfor local runs,-chromium-linuxfor the CIvisualjob, which runs in the pinned Playwright container that recorded them. A visual change therefore touches two PNGs per case; regenerate the Linux half with the Generate visual baselines workflow (see.github/workflows/visual-baselines.yml— download, LOOK at the PNGs, commit), never by hand-editing or copying darwin output.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

