Plan, build, and iterate UX-friendly frontend mockups via a ground→contract→mockup→test→fix→learn loop, acting as an expert UX designer who grounds every decision in externally documented public design rules (Nielsen heuristics, Laws of UX, WCAG, GOV.UK/USWDS/Material). Uses the bundled serve_mockup, score_mockup, and init_ui_contract tools plus a ui-contract.md design control plane to keep screens consistent. Works in any React/Tailwind/shadcn (or plain HTML) project. Use when designing new screens, adapting existing UI, enforcing cross-screen consistency, or doing a UX review. Triggers: \"design a screen\", \"mockup this UI\", \"wireframe\", \"make the UI consistent\", \"adapt the existing design\", \"improve this layout\", \"UX review\", \"is this good UX\".
npx skills add https://github.com/BlackBeltTechnology/pi-agent-dashboard --skill frontend-mockup-loop
A disciplined loop for designing frontend surfaces. It exists to defeat
distributional convergence: an undirected agent regresses to the
statistical mean of its training data — generic Inter font, a purple gradient,
a centered hero. "Make it look better" just returns the average again.
The fix the whole agentic-design field converged on, and what this loop
enforces every time:
This skill is paired with an extension that registers five tools:
serve_mockup, score_mockup, init_ui_contract, list_design_systems,
validate_mockup.
The loop runs design-system agnostic by default (generic anti-slop rubric).
To target a specific system, pick a preset and pass its id to the tools'
system param. v1 presets (list_design_systems enumerates them):
| id | system | platform | substrate |
|---|---|---|---|
| shadcn | shadcn/ui + Tailwind | web | HTML + Tailwind |
| mui | Material UI | web | HTML |
| material-3 | Material Design 3 | web | HTML |
| fluent-2 | Fluent 2 | web | HTML |
| apple-hig | Apple HIG | iOS | HTML approximation → SwiftUI on promote |
With a system selected: init_ui_contract{system} writes that system's DTCG
token contract (from a bundled, offline snapshot; refresh:true re-fetches
upstream), score_mockup{system} swaps in the system's boolean rubric, and
validate_mockup{system,dir} runs the gated pipeline.
Validation is layered. Gates block pass; advisory layers only score
and drive the fix loop (LLM visual scores skew positive — never hard-block):
literals fail shadcn/material-3).
hig-doctor / material3-mcp etc., advisory,shelled out only if installed (absent → skipped + noted, never errors).
score = pass/N computed incode, advisory.
validate_mockup returns { gates, advisory, pass }; pass is gate-only.
Apple publishes no token JSON, so apple-hig ships a hand-authored rule pack
(presets-data/apple-hig/rules.md). Render an HTML approximation of the iOS
screen so serve_mockup can serve it and hig-doctor (if installed) can audit
it — no SwiftUI/Xcode required in-loop:
font-family: -apple-system, "SF Pro Text", system-ui.padding: env(safe-area-inset-top) … env(safe-area-inset-bottom).systemBlue), no hardcoded brand hex on system chrome.
On PROMOTE, optionally emit real SwiftUI — validated on source by
hig-doctor / orchard-hig (no live browser preview; real-device fidelity
needs macOS/Xcode). SwiftUI is never required for the in-loop preview.
**Rule: ground every UX decision in an externally documented, public-facing
design rule — never invent one.** When you make a call, you must be able to name
the rule and cite its public source. "I think it looks better" is not a reason;
"Hick's Law — reduce the choices here (lawsofux.com/hicks-law)" is.
The full citable rule corpus lives in
references/ux-best-practices.md:
Nielsen's 10 heuristics, Laws of UX, Gestalt, cognitive load, per-component
pattern rules, the 5-step expert evaluation protocol, and a 22-item checkable
rubric seed. Read it before designing or reviewing.
Source order (adapt, don't copy): the selected design system's documented
guidance first → then the universal sources, in licensing-safe order (USWDS is
CC0; GOV.UK is OGL; NN/g + Laws of UX cite-with-attribution; Material/Carbon are
Apache-2.0). Adapt the *principle* to this product; never copy proprietary
assets/text (Apple HIG, Refactoring UI, Mobbin).
Anti-slop companion (advisory). For the *AI-tell* layer — the countable
signatures an undirected model defaults to (AI-purple, Inter-everywhere,
em-dashes, div-based fake screenshots, eyebrow-per-section, Jane Doe / Acme
data) — pull the anti-slop-frontend skill
(@blackbelt-technology/anti-slop-frontend). It is advisory only: its tells
feed the FIX step's defect list (step 5), but they NEVER override this loop's
hard gates. When an anti-slop tell conflicts with a cited public rule or the
WCAG-AA / severity-4 floor, the cited rule and the gate win. Apply its Part A
(universal) to any surface; skip its Part B (marketing-only) for product UI.
Designing or refining any frontend surface — new screens, redesigns, or a
consistency pass across existing screens. Skip for trivial one-class tweaks.
Not for backend/protocol work.
Two grounds, both external:
source. Capture the EXACT tokens already in use: class names, CSS custom
properties (--background, --primary, --radius), spacing, dark + light.
references/ux-best-practices.md and theselected design system's public guidance. Identify the specific patterns and
laws that govern this surface (e.g. a form → NN/g web-form-design + GOV.UK
error-summary; a nav → Hick's Law + hamburger-menu guidance).
Designing without either ground produces a parallel style that looks "off" and a
UX that violates well-known rules — the opposite of adapting documented design.
Read or scaffold ui-contract.md (run init_ui_contract). It is the single
source of truth for cross-screen properties: color ramps, spacing scale, type
scale, radius, elevation, motion, component invariants. **Every value
references a design token — never a raw hex or px literal.** If a surface needs
a token that doesn't exist, add it to the theme layer first, then cite it in
the contract. This file is what stops screens from drifting apart.
Build standalone HTML/Tailwind mockups grounded in steps 1–2. Serve them with
serve_mockup and hand back the clickable local + LAN URL (the LAN URL
opens on a phone) — not a screenshot — so the human reacts to a real page.
Render dark AND light.
Run score_mockup to capture full-page screenshots at mobile/tablet/desktop
widths, then apply the 5-step protocol from references/ux-best-practices.md:
visible, color-not-sole-channel, reduced-motion.
+ component rules) scored yes/no; for a user flow, the cognitive-walkthrough
4 questions per step.
Score = passed / N, derived in code — never a subjective "looks good" and
never a free-form float (LLM visual scores skew positive). Each failed check
cites the rule it violates.
Apply the top failing item, re-serve, re-score. Loop 3–5 until every rubric
line passes in both themes at all three breakpoints.
Translate the approved HTML direction into real React/shadcn components.
Do this in an ISOLATED environment (temp workspace, non-production ports),
never against a live server. Map the mockup's tokens 1:1 so shipped code
matches the approved mockup with zero drift.
Record durable taste decisions so the next run starts smarter: stable rules →
agent memory; repo design rules → patch ui-contract.md; one-off rationale →
the change's notes.
serve_mockup{dir, port?, stop?} — Node static server on 0.0.0.0; returnslocal + LAN URLs. Zero external deps.
score_mockup{url, widths?, outDir?, system?} — Playwright breakpoint screenshots +scoring rubric. Falls back to install guidance if Playwright is absent
(npm i -D playwright && npx playwright install chromium).
init_ui_contract{path?, force?, system?, refresh?} — scaffold thetoken-referencing contract. With system, write that preset's DTCG contract
(offline snapshot; refresh re-fetches upstream first). No system →
generic blank template (unchanged).
list_design_systems{} — enumerate the preset registry (id, label, platform,substrate, validators).
validate_mockup{system, url?, dir?} — run L1+L2 (gates) + L3+L4 (advisory);returns { gates, advisory, pass }. Pass dir so L1/L2 can scan the source.
edits actually load.
consistency erodes the moment a theme changes.
Screenshots are for the AGENT's scoring step; live URLs are for the human.
named rubric.
external documented public source (see references/ux-best-practices.md).
remains — the accessibility floor is the hard gate.
ui-contract.md exists; every value references a token; the new surface'stokens appear in it.
mobile/tablet/desktop.
WCAG criterion), not taste.
untouched.
Take blackbelttechnology/frontend-mockup-loop from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.
The instructions reference npm, npx.
Without those the skill loads but fails at the first command.