existing-ui-audit
Use BEFORE writing or editing any non-trivial UI — inventories components, design tokens, shadcn primitives, and reusable patterns into state.ui_audit. Hard gate for fe-design.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 19
- Forks
- 1
01 前言 Front Matter
- name
- existing-ui-audit
- packs
- [ "engineering-base" ]
- domain
- discovery
- personas
- [ "frontend-engineer" ]
- model_tier
- high
- workspaces
- [ "engineering" ]
- description
- Use BEFORE writing or editing any non-trivial UI — inventories components, design tokens, shadcn primitives, and reusable patterns into state.ui_audit. Hard gate for fe-design.
02 资源文件 16
- 参考文档evals/triggers.json2.0 KB
- 参考文档procedure.yaml1.6 KB
- 参考文档references/anti-slop-cross-reference.md1.9 KB
- 参考文档references/component-taxonomy-detection.md3.1 KB
- 参考文档references/steps/00-inspect-stack-and-input.md307 B
- 参考文档references/steps/01-enumerate-components.md1.4 KB
- 参考文档references/steps/01b-detect-component-taxonomy.md907 B
- 参考文档references/steps/02-identify-design-system.md780 B
- 参考文档references/steps/03-detect-design-tokens.md2.5 KB
- 参考文档references/steps/04-detect-shadcn-inventory.md904 B
- 参考文档references/steps/04b-live-storybook-read.md1.9 KB
- 参考文档references/steps/05-list-reusable-patterns.md718 B
- 参考文档references/steps/06-match-candidates.md2.8 KB
- 参考文档references/steps/07-greenfield-branch.md1.9 KB
- 参考文档references/steps/08-a11y-baseline.md1.5 KB
- 参考文档references/steps/09-validate-and-write.md430 B
03 SKILL.md 正文
existing-ui-audit
Interplay: this audit answers what exists (components, tokens, primitives →
state.ui_audit);design-intelligenceanswers what to build (corpus-grounded style/token/typography/pattern selection for the brief). Audit runs first, and its reuse findings outrank corpus suggestions — never let a grounded recommendation introduce a new component the inventory already covers.
When to use
Use this skill when:
- The dispatcher has routed work to
directive_set="ui"(intentui-buildorui-improve) - A
mixedflow is about to enter its UI phase - The user asks "what UI do we already have for X?"
Do NOT use when:
directive_set="ui-trivial"— the trivial path bypasses audit by precondition (≤1 file, ≤5 lines, no new component, no new state, no new dep)directive_set="backend"— no UI surface to inventory- The audit findings already exist in
state.ui_auditfor this state-file — the gate round-trips through SUCCESS onceaudit_pathis set, and does not re-run for the life of that state-file (see Gotchas for what that does and does not cover)
Resource-first context gate (design fidelity)
Any request to recreate, redesign, mock, prototype, or improve a UI runs this gate BEFORE styling — the Inspect stage of the design-artifact lifecycle. Design starts from project truth, not generic aesthetic memory.
- Search first (owned UI). Before proposing anything, search the project for: design tokens, global CSS, the component library / design system (§ 2), supplied screenshots or exported design context, Figma/exported context when connected, assets (logos, icons, fonts), and copy tone. Procedure steps 1–5 produce this inventory — do not skip them for a "quick" redesign.
- Hard stop on a promised-but-inaccessible source. When the user explicitly
references a design system, local folder, Figma file, or codebase you cannot
read, STOP and ask for access — never invent a design from memory to paper
over the missing source. A promised source that can't be reached is a blocking
question (
ask-when-uncertain), not a licence to improvise. (fixture:daf-inaccessible-design-system.) - Source priority — code beats screenshots. For exact values (tokens, spacing, component props) the design-system/code context is authoritative; a screenshot conveys gestalt but is not enough for component/token fidelity. Never read pixel values off a screenshot when the source is available.
- Tool composition — inspect before you generate. Owned UI → repository
search + local files FIRST. Connected/imported design data (Figma, tokens
export) → that connector next, when available. Browser / image search → only
for public references or current product/place imagery, never a substitute
for inspecting owned code. Generated imagery → only when the user asks for
synthetic assets, or no real inspection is required. (fixtures:
daf-no-context,daf-missing-asset.)
Procedure: Audit the existing UI surface
The order is held by procedure.yaml. Open the steps one at a time, in order, and start a step only after the one before it has met its exit. A judgement exit is sequenced, not verified: state what you decided before moving on.
- 0. Inspect stack and input — exit:
judgement - 1. Enumerate components and templates — exit:
check: ui-audit-components-in-tree - 1b. Detect the component-granularity taxonomy — exit:
check: ui-audit-taxonomy-root-in-tree - 2. Identify the design system — exit:
judgement - 3. Detect design tokens — exit:
judgement - 4. Detect shadcn inventory (react-shadcn only) — exit:
judgement - 4b. Prefer a live Storybook read when one is running — exit:
judgement - 5. List reusable patterns — exit:
check: ui-audit-patterns-in-tree - 6. Match candidates for the current input (with the 6b conformance gate) — exit:
check: ui-audit-candidates-from-inventory - 7. Greenfield branch — exit:
check: ui-audit-greenfield-consistent - 8. (Optional) Capture an a11y baseline — exit:
judgement - 9. Validate and write findings — exit:
check: ui-audit-complete
Section index — load on demand
Load on demand once the audit needs the pitfall catalog:
references/anti-slop-cross-reference.md— Anti-slop cross-referencereferences/component-taxonomy-detection.md— Component-taxonomy detection rules
Output format
state.ui_audit.components— array of component/template descriptors (path, name, kind, exports)state.ui_audit.design_system— single string identifying the dominant system orcustom-or-nonestate.ui_audit.design_tokens— object grouped by category (colors, spacing, radius, font, shadow, breakpoint, other)state.ui_audit.shadcn_inventory— object with version, style, base_color, primitives (only when stack isreact-shadcn;nullotherwise)state.ui_audit.patterns— object with forms, tables, modals, empty_states, navigation, data_display arraysstate.ui_audit.candidates— top-5 similarity matches for the current input (may be empty)state.ui_audit.greenfield— boolean; when true,greenfield_decisionMUST also be set before the dispatcher advances 7b.state.ui_audit.component_taxonomy/component_root— the project's own granularity tiers joined with/(ornone), and where the components live relative to the project root. Never a canonical tier list — a project with three tiers records three;noneis the value that leaves every downstream step unchanged.state.ui_audit.a11y_baseline(optional) — array of{rule, selector, severity?}entries documenting pre-existing a11y violations the review gate should treat as informational. Omit the key entirely when no baseline applies; do not write[]for "I checked and there are none" — that disables the gate's filter for every future run.
Design-system export (current-repo source): when the goal is to seed
DESIGN.md from this repo, emit the inventory as a design-system.json
artifact (the import contract in
design-system-capture)
and hand it to design-system-capture — the same shape an external extraction
tool produces, so the import path is uniform.
Gotcha
- The model tends to skip the audit and start designing straight from the request — the dispatcher gate at
directives/ui/audit.tsenforces "no design without audit findings". Never treat this skill as optional for non-trivial UI. - The model tends to misidentify a single Tailwind utility as a "design token" — tokens come from the config or
:root, not from class strings in templates. - Don't assume a Radix-only
package.jsonmeans shadcn — shadcn requirescomponents.jsonat the workspace root that owns the components. Each workspace carries its own; the repository root carries none, which is the layout the shadcn CLI scaffolds. state.ui_audit.shadcn_inventory.versionis often missing; the shadcn CLI does not always pin itself inpackage.json. Recordnullrather than guessing.- Greenfield is detected, not assumed — a project with one Blade layout and no components is still greenfield only if tokens AND design system markers AND components are all empty.
- There is no mtime cache. An earlier revision told you to cache by
(composer.json mtime, package.json mtime)and re-audit when either changed. No code implemented it, and the key was the wrong one anyway:applyadds components without touching a manifest, so a manifest-keyed cache never invalidates on the change that matters. What the engine does is simpler and stricter —audit.tsreturns SUCCESS unconditionally onceaudit_pathishigh_confidenceorambiguous, so the inventory is computed once per state-file and never refreshed. - What that means in practice. A single request is one pass, so the
inventory is fresh where it matters. The bounded gap is a run that reuses one
state-file across several component additions: components written earlier in
that run are absent from the inventory the later ones are checked against.
Adding a second component in the same run → re-read the component directories
directly rather than trusting
state.ui_audit.components_found.
Do NOT
- Do NOT advance to
directives/ui/design.tsorapply.tsifstate.ui_auditis empty. - Do NOT advance to design or apply if
state.ui_audit.greenfield == trueandstate.ui_audit.greenfield_decisionis unset. - Do NOT silently skip the greenfield halt because "Tailwind has defaults" — the user picks the path explicitly.
- Do NOT write paths outside the project root into the inventory.
- Do NOT rewrite
state.ui_auditonce it is populated unless re-detection is triggered by mtime change — design and apply read from it.
04 同仓库更多 Skills
unknown-key-fixture
Declares a key the schema does not know.
portable-fixture
Declares only semantics the MCP-lite carrier transports whole.
non-portable-fixture
Declares a runtime semantic the carrier drops.
candidate-zero-width
A candidate whose prose carries an invisible joiner.
candidate-disclosure-suppression
A candidate whose prose tells the agent to withhold from the user.
candidate-dangerous-frontmatter
A candidate claiming an unscoped tool grant and a permission bypass.