agentleFS
bydioramabydiorama/ui/AGENTS.md

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

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
  1. Distinctive:

    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 …

    line 23
  2. Very specific:

    Run pnpm verify before considering any change done.

    line 60
  3. Very specific:

    Create registry/ui/<name>/ with the component, its *.doc.ts, and stories.

    line 96
  4. Distinctive:

    Do not commit or push anything without explicit consent — see § Git.

    line 153
  5. Distinctive:

    Do not add a third-party component library, design language, block set or theme preset.

    line 154
  6. Very specific:

    Do not hand-edit generated files (registry.json, r/*.json).

    line 157
  7. Distinctive:

    Do not widen a component's API to avoid a composition problem — slots and hooks exist for that.

    line 158
  8. Distinctive:

    Do not skip the ledger entry because a change "is small".

    line 160

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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

  1. CONVENTIONS.md is 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.
  2. 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.
  3. The manifest is the source of truth. ui.manifest.json describes every distributable item. registry.json and r/*.json are generated — never hand-edit them; run pnpm registry:build.
  4. 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

CommandWhat it does
pnpm verifyThe full local gate: manifest, registry freshness, ledger, licensing
pnpm registry:buildRegenerate registry.json and r/*.json from the manifest
pnpm check:registryFail if the generated registry is stale (CI runs this)
pnpm check:licensingFail on non-distributable fonts or paid-tier assets
pnpm skills:buildRegenerate .claude/skills/ and the ui plugin (plugins/ui/) from registry/skills/
pnpm check:skillsFail on a broken skill contract or a stale generated copy
pnpm check:boundariesFail if the behaviour layer leaks into a public signature
pnpm check:motionFail on a literal duration, an unguarded keyframe, or undocumented motion
pnpm check:design-specFail if a design geometry spec breaks its own laws, or nothing renders it
pnpm check:strokesFail on a literal stroke width (border-2, ring-[1.5px] …) — use the scale (ADR 0020 §2)
pnpm check:type-rolesFail 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:fxFail 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-consumersFail on a contract token that nothing in registry/ reads, unless it is declared with a reason (ADR 0020)
pnpm ledger:newScaffold a change-ledger entry
pnpm type-checktsc --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 lintESLint
pnpm site:dataRegenerate public library data from the manifest, typed docs, registry, contrast report and ledger
pnpm check:site-dataFail if the public library data is stale or a public component lacks documentation
pnpm site:buildBuild the public site and check generated routes and internal links
pnpm site:devStart the local public library site
pnpm test:siteBuild and test public pages, accessibility and rendered theme preferences in Chromium
pnpm test:cli-packageRun 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 in registry/. 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-family reference. Same rule for paid-tier assets from third-party libraries. pnpm check:licensing enforces both.
  • griddy-icons only 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.

  1. 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).
  2. Create registry/ui/<name>/ with the component, its *.doc.ts, and stories.
  3. Register it in ui.manifest.json, then pnpm registry:build.
  4. 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.
  5. pnpm ledger:new to record the addition.
  6. 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).

TierTeachesIn the manifestShips as
Authoringbuilding this libraryno— (loads only here)
Productusing the system in an app, in Paper, in demo mediatype: "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.01 lets 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 in apps/registry/ — a directory that should not exist and that no __screenshots__ rule matched. They were committed. The artifact NAMES are ignored globally now; still run git 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-darwin for local runs, -chromium-linux for the CI visual job, 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.