Enforcing the guidelines
The UI guidelines are judgement, but a good part of them can be counted, and what can be counted should not depend on anyone remembering it. This is what Prism does about that today, and what it does not do yet.
1. Rules that travel with the system
llms.txtandSKILL.mdopen with the seven rules for AI agents and the seventeen questions, copied from the handbook at build time so they cannot drift.- Every component's usage note has a "When not to use" section. It names the situations where the component is the wrong choice and what to use instead. A component existing is never a reason to use it.
2. Reference journeys
Six mobile-first screens for the common journeys, each annotated with its job sentence: Reference journeys. Start from one when it fits.
3. Guard-rails in the components
PageHeadertakes oneprimaryActionand collapses everything else (moreActions) into a single "More actions" menu. In development it warns if the header ends up with more than one accent button.Tabscollapse past their budget:maxVisiblekeeps that many in the row and puts the rest in a "More" menu. With nomaxVisible, a phone-width screen with more than five tabs collapses to four plus "More" on its own. The row never reorders: a selected tab that is hidden shows on the "More" button.Toolbardoes the same withmaxVisible, and on a phone past five controls.- Touch targets. On a touch screen, Prism's controls are at least 44px tall at every density. Mouse and trackpad layouts are unchanged.
4. The runtime audit
RestraintAudit is a development aid. Render it once near the root of the app:
import { RestraintAudit } from '@/components/prism/RestraintAudit';
<RestraintAudit />
It draws nothing. As you use the app it reports, in the console, what on the current screen breaks a countable rule, and outlines the offending elements:
| Rule | Finding |
|---|---|
| 2.1 | More than one accent button in a view (the page, or each open dialog) |
| 3.3 | More than four key figures on a screen |
| 4.2 | A card inside a card |
| 4.7 | More than one dialog open, other than a confirmation |
| 9.2 | Tabs inside a tab panel |
| 12.1 | More than one page-level banner |
| 14.4 | On a touch screen, targets smaller than 44px |
It does nothing in a production build. In an end-to-end test, pass enabled and onReport and fail on any finding.
5. The source lint
prism-restraint-lint reads JSX and TSX source and reports where a file goes past the budgets. A file is taken to be one screen. It is one file with no dependencies:
curl -fsSL https://prism.artoftechconsulting.com/tools/prism-restraint-lint.mjs -o scripts/prism-restraint-lint.mjs
node scripts/prism-restraint-lint.mjs src
| Rule | What it counts |
|---|---|
| 2.1 | Accent buttons per view |
| 3.3 | Key figures (KpiTile, StatCard, MetricCard) per screen |
| 3.6 | Columns a Table or DataGrid starts with |
| 4.2 | A card inside a card |
| 4.7 | A dialog inside a dialog |
| 5.5 | FormRow with more than one column |
| 9.2 | Tabs or accordions nested in each other |
| 9.5 | Tabs past five with no maxVisible |
| 9.6 | Top-level destinations past seven |
| 12.1 | Page-level banners |
| 14.7 | Email, phone and password fields with no autoComplete |
Every rule starts as a warning. --strict makes the run fail; turn it on in CI once the findings in your codebase are understood. --only 2.1,4.2 runs a subset and --json gives machine-readable output. To accept a finding on purpose, say so where it is:
{/* prism-restraint-disable-next-line 2.1 — two equal choices */}
The lint reads source, so it cannot see what a loop produces or what a component renders inside itself. The audit sees the rendered screen, but only the states you visit. Use both.
6. The screen check
prism-screen-check opens a screen in headless Chrome as a 360px touch phone and runs the passes the guidelines ask a pipeline for, saving a screenshot of each. One file, no dependencies, Node 22 or newer and a local Chrome:
curl -fsSL https://prism.artoftechconsulting.com/tools/prism-screen-check.mjs -o scripts/prism-screen-check.mjs
node scripts/prism-screen-check.mjs --out shots https://preview.example/orders https://preview.example/settings
| Pass | What it checks |
|---|---|
phone | 360px wide, touch: no sideways scroll (14.2), one accent button per view (2.1), no card in a card (4.2), no tabs in tabs (9.2), no touch target under 44px (14.4) |
compact | The same at compact density |
pseudo | Every piece of text made 40% longer and accented, as a long language would: no sideways scroll, no clipped labels (15.9) |
text200 | Text at 200% size: no sideways scroll, no clipped labels (15.3) |
reflow | 320px wide, the WCAG floor: no sideways scroll |
slow | Reloaded on a slow connection: how long until the page shows text (15.6) |
It reports by default; --strict fails the run. In a pull-request pipeline, give it the URLs of the screens the change touches, on a preview deployment, and keep the screenshots as an artefact for the reviewer.
7. The detour check
Principle 17: when someone acts and we put a detour in the way (sign-in, sign-up, verification, payment authentication, a permission prompt), the original action completes afterwards. Never a home page. prism-detour-check walks such a journey in headless Chrome as a phone, from a short spec you write once per journey, and checks each promise on the way:
curl -fsSL https://prism.artoftechconsulting.com/tools/prism-detour-check.mjs -o scripts/prism-detour-check.mjs
node scripts/prism-detour-check.mjs --base https://preview.example journeys/*.json
{
"name": "Request equipment while signed out",
"start": "/equipment/monitor",
"steps": [
{ "choose": "Collect from reception" },
{ "click": "Request this monitor" },
{ "expect": { "text": "Sign in" }, "rule": "17.3", "why": "asked to sign in at the moment of need" },
{ "fill": "Work email", "value": "${E2E_EMAIL}" },
{ "fill": "Password", "value": "${E2E_PASSWORD}" },
{ "click": "Sign in" },
{ "expect": { "text": "Monitor requested", "urlNot": "/home" }, "rule": "17.1", "why": "the original action completed" },
{ "back": true },
{ "expect": { "text": "Collect from reception" }, "rule": "17.5", "why": "back returns to the page as it was" }
]
}
Controls are found by their visible text or label, the way a person finds them, or by a CSS selector. ${NAME} is read from the environment, so credentials stay out of the file; a spec whose variables are not set is skipped, not failed. Values read that way are never printed: failure messages show the ${NAME} placeholder. A failure screenshot shows the page as it was, so treat the screenshot folder as you would a test log. Each journey starts signed out with nothing remembered.
Write one spec for every action that can be interrupted:
| Rule | Journey to write |
|---|---|
| 17.1 | Signed out, press an action that needs an account; sign in; the action completes |
| 17.2 | Signed out, open a link from an email or notification; sign in; land on the thing the link named |
| 17.4 | Fill a basket, a form or a set of filters; pass through the detour; they are still there |
| 17.5 | After the detour, press back; the previous page is as it was |
| 17.9 | Fail the detour once (wrong password, declined card); the input is kept and the pending action is intact |
The sign-in reference journey ships with its own spec, templates/journey-sign-in-return/detour.json, as a working example.
What is not enforced yet
- Journeys nobody has written a spec for. The detour check walks the journeys you describe; it does not discover them.
- Wiring into pipelines. The lint, the screen check and the detour check exist; each product still has to add them to its own pull-request checks.
- Everything that is judgement. Whether a screen has one job, whether an element earns its place, whether the words are the user's own. Those are for review, with the seventeen questions.