@jeiemgi/cckit 0.4.1 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +9 -1
- package/bin/cckit +18 -0
- package/cckit.config.json +2 -2
- package/package.json +1 -1
- package/scripts/benchmark/benchmark-test.sh +83 -0
- package/scripts/benchmark/gate.sh +55 -0
- package/scripts/benchmark/lib/bench-common.sh +70 -0
- package/scripts/benchmark/lib/model.sh +116 -0
- package/scripts/benchmark/report.sh +105 -0
- package/scripts/benchmark/run-quality.sh +102 -0
- package/scripts/benchmark/run.sh +166 -0
- package/scripts/benchmark/stop-check.sh +83 -0
- package/scripts/commitlint-test.sh +58 -0
- package/scripts/init.sh +26 -0
- package/scripts/kit-self-update.sh +55 -0
- package/scripts/lib/commitlint.sh +53 -0
- package/scripts/lib/kit-task-ops-test.sh +21 -0
- package/scripts/lib/kit-task-ops.sh +50 -2
- package/scripts/orchestrate.sh +8 -1
- package/scripts/portable-test.sh +1 -1
- package/scripts/status.sh +53 -40
- package/scripts/task-sync.sh +13 -0
- package/scripts/ux-a11y-scan.sh +96 -0
- package/scripts/ux-ds-audit.sh +146 -0
- package/scripts/ux-graph-scan.sh +188 -0
- package/skills/kit-autopilot/SKILL.md +6 -1
- package/skills/kit-ux-audit/SKILL.md +241 -0
- package/skills/kit-ux-audit/references/a11y.md +79 -0
- package/skills/kit-ux-audit/references/consistency.md +106 -0
- package/skills/kit-ux-audit/references/graph-model.md +92 -0
- package/skills/kit-ux-audit/references/heuristics.md +157 -0
- package/skills/kit-ux-audit/references/report.md +172 -0
- package/templates/agents/ux.md +89 -0
- package/templates/benchmarks/SCHEMA.md +75 -0
- package/templates/benchmarks/abstain.jsonl +8 -0
- package/templates/benchmarks/adversarial.jsonl +8 -0
- package/templates/benchmarks/benchmark.config.json +14 -0
- package/templates/benchmarks/quality.jsonl +8 -0
- package/templates/benchmarks/retrieval.jsonl +7 -0
- package/templates/settings/settings.json.tmpl +9 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: kit-ux-audit
|
|
3
|
+
description: Expert UX/UI audit of a front-end app, driven by a component/screen graph instead of a screen-by-screen walkthrough. Three lanes over one graph and one report — flows (routes ↔ screens ↔ containers ↔ components ↔ data entities ↔ forms; a UX agent runs 12 heuristics to surface confusing or erratic flows: the same data editable from many screens, deep paths to frequent actions, orphan/dead-end screens, heavy forms, structurally inconsistent patterns, overloaded screens, unguarded deletes, nav-away data loss), consistency (deterministic design-system pass: hand-rolled UI, className overrides on shared primitives, sibling-screen layout drift, variants-in-disguise, dead CSS — the model only classifies), and a11y (semantic-HTML + accessibility: non-semantic interactive elements, missing text alternatives, unlabeled controls, heading/landmark gaps, focus and keyboard problems). Emits a self-contained, accessible HTML report. Use AUTOMATICALLY when the user asks for a UX audit / UX review, to analyze app flows or navigation, to find where a piece of data can be edited, to check form usability, to review information architecture, to find confusing / hard-to-fill screens, for a design-system consistency pass / DS audit / "is this page consistent" / "what should be a variant" / "find hand-rolled solutions", OR for an accessibility / semantic-HTML review / "is this markup accessible" / "find non-semantic divs". Optional graphify integration; falls back to a dependency-free deterministic scan. Visual verification (Playwright / Chrome screenshots) is opt-in via --visual.
|
|
4
|
+
when_to_use: Before a redesign, after a feature that added screens or forms, when users report "I can't find where to change X" or "there are too many places to edit this", before scoping a UI refactor effort, or on demand for an IA / flow / consistency / accessibility health check. Targets component front-ends (Next.js, React Router v7, Vite React, Vue). For a purely visual per-screen critique of a running app, use a visual design-critique skill instead — this one reasons over structure. The a11y lane is a source-level check, not a substitute for axe / Lighthouse against the running app.
|
|
5
|
+
argument-hint: "[--lane flows|consistency|a11y|all] [--path <dir>] [--app <name>] [--visual] [--rebuild-graph] [--primitives <index.ts>] [--css <theme.css>] [--css-prefix <p>] [--dry-run]"
|
|
6
|
+
allowed-tools: Bash, Read, Write, Glob, Grep, AskUserQuestion, Task, Skill
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# kit-ux-audit — graph-driven UX/UI audit
|
|
10
|
+
|
|
11
|
+
Analyze how a front-end app's **flows, data-editing surfaces, forms, and design-system usage** hang
|
|
12
|
+
together by reasoning over a **graph** of the app — not by opening screen after screen. Two lanes,
|
|
13
|
+
one graph, one HTML report. Detection is deterministic (a script / the graph); judgment is the
|
|
14
|
+
model. Never eyeball a codebase for something a script already finds — run it, read it, then think.
|
|
15
|
+
|
|
16
|
+
| Lane | What it does | Detector | Judge | Heuristics |
|
|
17
|
+
| --- | --- | --- | --- | --- |
|
|
18
|
+
| `flows` (default) | Confusing / erratic flows, IA, edit surfaces, forms | graph (graphify or fallback scan) | **ux** agent | `references/heuristics.md` (H1–H12) |
|
|
19
|
+
| `consistency` | Design-system consistency: hand-rolled UI, primitive className drift, sibling-screen drift, variants-in-disguise, dead CSS | `scripts/ux-ds-audit.sh` | **ux** agent → routes decisions to designer/frontend | `references/consistency.md` (C1–C6) |
|
|
20
|
+
| `a11y` | Semantic HTML + accessibility: non-semantic interactives, missing text alternatives, unlabeled controls, heading/landmark gaps, focus/keyboard | `scripts/ux-a11y-scan.sh` | **ux** agent | `references/a11y.md` (A1–A5) |
|
|
21
|
+
| `all` | All three lanes, merged into one report | all | | all |
|
|
22
|
+
|
|
23
|
+
Kit lives at `${CLAUDE_PLUGIN_ROOT}`. Engines:
|
|
24
|
+
- `scripts/ux-graph-scan.sh` — `--apps <root>` (enumerate app-like packages) · `--scan <dir>`
|
|
25
|
+
(deterministic, dependency-free flows graph: routes, renders, nav, data reads/writes, forms).
|
|
26
|
+
No LLM, no API key. Sources `scripts/lib/react-detect.sh`.
|
|
27
|
+
- `scripts/ux-ds-audit.sh` — deterministic design-system occurrence lists (grep/perl, macOS-safe).
|
|
28
|
+
Parameterized: `--primitives <ui-barrel>` `--css <theme.css>` `--css-prefix <p>` — so it runs
|
|
29
|
+
against any design system, nothing hardcoded.
|
|
30
|
+
- `scripts/ux-a11y-scan.sh` — deterministic semantic-HTML / accessibility smell lists (grep/perl,
|
|
31
|
+
macOS-safe). No parameters beyond `--exclude`.
|
|
32
|
+
|
|
33
|
+
There is **no report renderer**. The report is written by hand from `findings.json` following the
|
|
34
|
+
`kit-docs-writer` skill — see `references/report.md`.
|
|
35
|
+
|
|
36
|
+
References — load only when you reach the step that needs one:
|
|
37
|
+
- `references/graph-model.md` — normalized node/edge model; how graphify `graph.json` and the
|
|
38
|
+
fallback scan both map onto it; how to derive click-depth / god-nodes / community bridges /
|
|
39
|
+
edit-surface map.
|
|
40
|
+
- `references/heuristics.md` — the 12 `flows` heuristics: graph signal, default severity, whether
|
|
41
|
+
the finding needs visual confirmation. **This is the flows audit.**
|
|
42
|
+
- `references/consistency.md` — the `consistency` lane: the `ux-ds-audit.sh` sections, the
|
|
43
|
+
LAYOUT / VISUAL / BEHAVIOR classification, sibling-screen comparison, variant proposals.
|
|
44
|
+
- `references/a11y.md` — the `a11y` lane: the `ux-a11y-scan.sh` groups, DEFECT / OK / NEEDS_VISUAL
|
|
45
|
+
triage, and the fix each smell maps to.
|
|
46
|
+
- `references/report.md` — how to **write** the report: the `findings.json` schema, the section
|
|
47
|
+
order (it is `kit-docs-writer`'s page template, filled for an audit), the voice, and the visual
|
|
48
|
+
identity (Datatype display + Open Sans body + IBM Plex Mono for evidence, semantic + accessible HTML).
|
|
49
|
+
|
|
50
|
+
## 0. Orient, pick lane & target
|
|
51
|
+
|
|
52
|
+
1. Read `./.claude/kit.config.json` if present (for `apps`, repo root). Not required.
|
|
53
|
+
2. **Lane:** honor `--lane`. No flag: request about consistency / variants / hand-rolled UI →
|
|
54
|
+
`consistency`; request about accessibility / semantic HTML / ARIA / keyboard → `a11y`;
|
|
55
|
+
otherwise `flows`. If ambiguous, `AskUserQuestion` (flows / consistency / a11y / all).
|
|
56
|
+
3. **Target app:**
|
|
57
|
+
- `--path <dir>` → that directory. Skip enumeration.
|
|
58
|
+
- Else `bash "${CLAUDE_PLUGIN_ROOT}/scripts/ux-graph-scan.sh" --apps <root>` — lists every
|
|
59
|
+
app-like package (has `react`/`next`/`vue` + a `dev` script) with framework + router.
|
|
60
|
+
0 → stop ("No component front-end found under <root>."). 1 → use it, say which. 2+ →
|
|
61
|
+
`AskUserQuestion` which to audit (honor `--app <name>`).
|
|
62
|
+
4. **Consistency-lane inputs:** resolve `--primitives` (the shared UI barrel, e.g.
|
|
63
|
+
`packages/ui/src/index.ts`), `--css` (the app theme/token file, repeatable), `--css-prefix`
|
|
64
|
+
(the project's custom-class prefix, if it has one — no default; the section-8 hunt is skipped
|
|
65
|
+
without it). If the project ships a rules file naming these (`.claude/rules/*ui-convention*`),
|
|
66
|
+
read it first. Missing barrel → run anyway, note the gap.
|
|
67
|
+
5. Record for the report: lane, target path, framework, router, monorepo yes/no.
|
|
68
|
+
6. `--dry-run` → print the resolved lane, target, graph source, and the checks that will run, then
|
|
69
|
+
stop. Touch nothing.
|
|
70
|
+
|
|
71
|
+
## 1. Get the graph (`flows` / `all`)
|
|
72
|
+
|
|
73
|
+
Target dir = `$T`. Prefer an existing rich graph; never rebuild silently.
|
|
74
|
+
|
|
75
|
+
1. `$T/graphify-out/graph.json` **or** `./graphify-out/graph.json` exists and **no**
|
|
76
|
+
`--rebuild-graph` → use it. Report "graph source: graphify".
|
|
77
|
+
2. Else `bash "${CLAUDE_PLUGIN_ROOT}/scripts/ux-graph-scan.sh" --scan "$T"` → writes
|
|
78
|
+
`$T/graphify-out/.ux_graph.json` (normalized model). Report "graph source: deterministic scan
|
|
79
|
+
(approximate)".
|
|
80
|
+
3. Say **once**, without blocking: "For a richer semantic graph, run `/graphify $T` first, then
|
|
81
|
+
re-run." Never wait, never prompt for an API key — the fallback is enough.
|
|
82
|
+
4. `--rebuild-graph` + graphify installed → you MAY run `/graphify "$T" --directed` first (best
|
|
83
|
+
graph for this skill). Only on the explicit flag.
|
|
84
|
+
|
|
85
|
+
Normalize to `references/graph-model.md`, persist to `$T/graphify-out/.ux_model.json`, and derive:
|
|
86
|
+
click-depth per screen from each entry route, god-nodes, community bridges, the edit-surface map.
|
|
87
|
+
Keep it compact — you hand slices to the agent, not the whole graph.
|
|
88
|
+
|
|
89
|
+
## 2. Run the checks
|
|
90
|
+
|
|
91
|
+
### Lane `flows`
|
|
92
|
+
|
|
93
|
+
Spawn the **ux** agent (`templates/agents/ux.md`; in an onboarded project
|
|
94
|
+
`.claude/agents/ux/AGENT.md`). Give it **only** these slices as compact JSON — never source files:
|
|
95
|
+
routes/screens with click-depth · god-nodes (id, fan-in, rendering screens) · community bridges ·
|
|
96
|
+
per `data-entity` its `reads`/`writes`/`mutates` edges + source screen · per `form` its field
|
|
97
|
+
count, required count, multi-step?, host screen(s), any `duplicates` edge.
|
|
98
|
+
|
|
99
|
+
Ask it to apply **every** heuristic in `references/heuristics.md` and return findings in the
|
|
100
|
+
`findings.json` schema (`references/report.md`). Agent rule: **never invent an edge** — if a
|
|
101
|
+
verdict needs something the graph doesn't show, set `needs_visual: true` and say what to check.
|
|
102
|
+
|
|
103
|
+
For a large app, fan classification out to read-only `Explore` sub-agents (one per heuristic
|
|
104
|
+
group), each briefed with `references/heuristics.md`.
|
|
105
|
+
|
|
106
|
+
### Lane `consistency`
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
bash "${CLAUDE_PLUGIN_ROOT}/scripts/ux-ds-audit.sh" "$T/src" \
|
|
110
|
+
[--exclude <re>] --primitives "<ui-barrel>" --css "<theme.css>" [--css-prefix <p>] \
|
|
111
|
+
> "$T/graphify-out/.ux_ds_audit.txt"
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Then follow `references/consistency.md`: classify every primitive-with-className row into
|
|
115
|
+
LAYOUT / VISUAL / BEHAVIOR, run the sibling-screen comparison for a page scope, map hand-rolled
|
|
116
|
+
recipes to the primitive that should own them, judge custom CSS (variant-in-disguise vs layout vs
|
|
117
|
+
dead). Emit the same `findings.json` schema (heuristic ids `C1`…`C6`). Fan out to `Explore`
|
|
118
|
+
sub-agents by section group for a large scope.
|
|
119
|
+
|
|
120
|
+
### Lane `a11y`
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
bash "${CLAUDE_PLUGIN_ROOT}/scripts/ux-a11y-scan.sh" "$T/src" [--exclude <re>] \
|
|
124
|
+
> "$T/graphify-out/.ux_a11y_scan.txt"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Then follow `references/a11y.md`: triage every row DEFECT / OK / NEEDS_VISUAL, map each DEFECT to
|
|
128
|
+
its fix (the native element, the text alternative, the label wiring, the heading/landmark
|
|
129
|
+
structure, the focus/keyboard fix), and cite the project's own `.claude/rules/*` slug where one
|
|
130
|
+
applies. Emit the same `findings.json` schema (heuristic ids `A1`…`A5`). Fan out to `Explore`
|
|
131
|
+
sub-agents by group for a large scope. This is a source check — say in the report that a
|
|
132
|
+
rendered-app axe / Lighthouse run still belongs on the list.
|
|
133
|
+
|
|
134
|
+
## 3. Optional visual verification (`--visual` only)
|
|
135
|
+
|
|
136
|
+
Without `--visual`: skip. The report still lists every `needs_visual` finding under "Candidates for
|
|
137
|
+
visual review" (screen + what to look at), ranked by severity.
|
|
138
|
+
|
|
139
|
+
With `--visual`:
|
|
140
|
+
1. Find a base URL: a `dev`/`start` script + conventional port, or ask the user. No server → skip
|
|
141
|
+
captures, keep the candidate list, say so in the report.
|
|
142
|
+
2. For each `needs_visual` finding of severity `crit`/`p1`, up to a cap (default 8): navigate with
|
|
143
|
+
Playwright or the Chrome MCP, screenshot the screen, save under
|
|
144
|
+
`$T/graphify-out/ux-audit/shots/`. **Never trigger a native browser dialog.**
|
|
145
|
+
3. Record each shot's filename on its finding (`"shot": "<id>.png"`) so it renders inline.
|
|
146
|
+
|
|
147
|
+
## 4. Write the report
|
|
148
|
+
|
|
149
|
+
There is **no renderer**. Load the **`kit-docs-writer`** skill and write
|
|
150
|
+
`$T/UX_FLOW_REPORT.html` from `findings.json`, following `references/report.md`:
|
|
151
|
+
|
|
152
|
+
- the section order there **is** `kit-docs-writer`'s page template, filled for an audit (title →
|
|
153
|
+
one-line description → run facts → one diagram if it earns its place → findings grouped by
|
|
154
|
+
severity → flow map → edit-surface table → still-to-check → what to do next);
|
|
155
|
+
- its voice rules apply — zero analogies, define each heuristic term once, front-load, lists over
|
|
156
|
+
prose, callouts sparingly;
|
|
157
|
+
- the visual identity is fixed: **Datatype** (Google Fonts) as the protagonist display face for
|
|
158
|
+
the title, headings, finding lead lines and severity counts; **Open Sans** for body;
|
|
159
|
+
**IBM Plex Mono** for evidence/ids/paths; antialiased; one embedded `<style>`, screenshots as
|
|
160
|
+
`data:` URIs;
|
|
161
|
+
- the HTML is a full, semantic, accessible, theme-aware document (landmarks, one `<h1>`, ordered
|
|
162
|
+
headings, `<dl>`/`<table>`/`<ul>` for the right content, skip link, `:focus-visible`), readable
|
|
163
|
+
with no JavaScript.
|
|
164
|
+
|
|
165
|
+
**Not an artifact.** It is a file in the target repo. Do not publish it with the Artifact tool.
|
|
166
|
+
Run the `kit-docs-writer` checklist and the accessibility list in `references/report.md` before
|
|
167
|
+
calling it done.
|
|
168
|
+
|
|
169
|
+
## 5. Open the report, then report back (TOON, terse)
|
|
170
|
+
|
|
171
|
+
**Open the report and hand the user a direct link to it — this is the last action, always.**
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
REPORT="$T/UX_FLOW_REPORT.html"
|
|
175
|
+
case "$(uname)" in
|
|
176
|
+
Darwin) open "$REPORT" 2>/dev/null || true ;;
|
|
177
|
+
Linux) xdg-open "$REPORT" >/dev/null 2>&1 || true ;;
|
|
178
|
+
esac
|
|
179
|
+
printf 'Report: file://%s\n' "$(cd "$(dirname "$REPORT")" && pwd)/$(basename "$REPORT")"
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Print that **bare `file://` URL as the final line of the reply** (no markdown link — terminals
|
|
183
|
+
don't render OSC 8). If `open`/`xdg-open` is unavailable or headless, still print the URL and say
|
|
184
|
+
the file is ready to open.
|
|
185
|
+
|
|
186
|
+
Then print the top findings by severity as a small TOON table (heuristic · entity/scope · screens ·
|
|
187
|
+
severity). Then offer one trace:
|
|
188
|
+
|
|
189
|
+
> "The most tangled flow this graph shows: **<entity>** is edited from <n> screens (<list>). Want me
|
|
190
|
+
> to trace how they diverge?"
|
|
191
|
+
|
|
192
|
+
Yes + graphify source → `/graphify path "<screenA>" "<entity>"`. Otherwise walk the `writes`/
|
|
193
|
+
`mutates` edges for that entity from the graph JSON and show where the forms differ.
|
|
194
|
+
|
|
195
|
+
Then `AskUserQuestion` for every open call (effort split, which of two competing treatments wins,
|
|
196
|
+
widths/paddings, anything with a visual value). Label assumed vs decided.
|
|
197
|
+
|
|
198
|
+
## 6. Route + hand off
|
|
199
|
+
|
|
200
|
+
- Findings are analysis, not tickets — this skill does not file GitHub issues. Whole app / many
|
|
201
|
+
files → `/kit-effort-new` (in the consistency lane: a foundation sub first, sweeps parallel, a
|
|
202
|
+
variant-adoption sweep last). One screen/component → the quick lane, still in a worktree.
|
|
203
|
+
- **Consistency lane:** design DECISIONS (a new visual value, which of two treatments wins, a new
|
|
204
|
+
variant's look) → the **designer** agent. IMPLEMENTATION with existing tokens → the **frontend**
|
|
205
|
+
agent. Every new shared primitive/variant lands with its inventory row in the project's UI
|
|
206
|
+
conventions rule + its barrel export in the same PR.
|
|
207
|
+
- **Verification of a consistency pass** = re-run `ux-ds-audit.sh` on the same scope and
|
|
208
|
+
re-classify: none may classify VISUAL; hand-rolled recipe sections are zero outside the UI
|
|
209
|
+
package.
|
|
210
|
+
|
|
211
|
+
## Rules
|
|
212
|
+
|
|
213
|
+
- **Graph / script first, files last.** Never read component source screen-by-screen. Open a file
|
|
214
|
+
only to confirm a specific flagged finding, capped at 12 files, and report the count.
|
|
215
|
+
- **Never rebuild graphify implicitly.** `--rebuild-graph` is the only regenerating path.
|
|
216
|
+
- **No API key, ever.** The fallback scan is deterministic.
|
|
217
|
+
- **`--visual` is the only image-token cost and it is opt-in.** Default runs are text-only.
|
|
218
|
+
- **The agent never invents an edge.** Ambiguous → `needs_visual: true`, not an assertion.
|
|
219
|
+
- **The report is written, not rendered, and never an artifact.** Author it from `findings.json`
|
|
220
|
+
via `kit-docs-writer` per `references/report.md` — one self-contained HTML file in the target
|
|
221
|
+
repo. Datatype is the protagonist face; Open Sans is the body; IBM Plex Mono is the evidence.
|
|
222
|
+
The document itself must pass the same
|
|
223
|
+
bar the `a11y` lane checks for: full doctype + `lang`, landmarks, one `<h1>`, ordered headings,
|
|
224
|
+
`<dl>`/`<table>`/`<ul>` for the right content, a skip link, `:focus-visible`, readable with no
|
|
225
|
+
JavaScript.
|
|
226
|
+
- **Lane boundary:** `flows` H8/H9 flag *structural* pattern divergence and shared-component
|
|
227
|
+
overload only; the *visual/token* judgment (className diff, variant proposals) is the
|
|
228
|
+
`consistency` lane; *semantic-element and accessibility* defects are the `a11y` lane. Don't
|
|
229
|
+
double-report the same node in more than one lane — cross-link instead.
|
|
230
|
+
- **Project-agnostic.** This skill hardcodes no framework token names, no primitive library, no
|
|
231
|
+
path conventions beyond the common ones it probes for. Everything project-specific arrives as a
|
|
232
|
+
flag or is read from the project's own `.claude/` rules at run time.
|
|
233
|
+
|
|
234
|
+
## Optional: seed a graphify graph at install time
|
|
235
|
+
|
|
236
|
+
Seeding the graph once makes every later run richer and cheaper. Opt-in, outside the default flow:
|
|
237
|
+
1. `graphify detect` on the app → report corpus size + a token estimate.
|
|
238
|
+
2. Recommend by cost: `--directed` always (this skill wants edge direction); `--mode deep` only if
|
|
239
|
+
the app carries many docs/specs; `--no-viz` if > 5000 nodes; `--neo4j-push` only if the project
|
|
240
|
+
already runs Neo4j. Default otherwise.
|
|
241
|
+
3. Build only on explicit confirmation. Never as a side effect of onboarding.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# kit-ux-audit — a11y lane
|
|
2
|
+
|
|
3
|
+
Semantic-HTML and accessibility pass over a chosen scope. **Detection is `scripts/ux-a11y-scan.sh`**
|
|
4
|
+
(grep/perl, `$0`, macOS-safe) — **judgment is the model** (confirm the smell is a real defect,
|
|
5
|
+
map it to the correct element/pattern, prioritize). The scan flags *candidates* from static regex;
|
|
6
|
+
many need a one-line look at the file to confirm.
|
|
7
|
+
|
|
8
|
+
This is not a substitute for an axe / Lighthouse run against the rendered app — it catches the
|
|
9
|
+
structural mistakes that live in the source (wrong element, missing name, broken focus) before the
|
|
10
|
+
app is even running, which is exactly where they are cheapest to fix.
|
|
11
|
+
|
|
12
|
+
## 1 · Scope
|
|
13
|
+
|
|
14
|
+
Same options as the other lanes (whole app · route group · page · component · dir). Pass
|
|
15
|
+
`--exclude <regex>` to skip a second surface. For a page scope, include sibling screens so
|
|
16
|
+
heading-order and landmark checks compare like with like.
|
|
17
|
+
|
|
18
|
+
## 2 · Detect
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
scripts/ux-a11y-scan.sh <path> [--exclude <re>] > /tmp/ux-a11y.txt
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Five groups, each `(N hits)` + `file:line` rows:
|
|
25
|
+
|
|
26
|
+
| § | Group | Looks for |
|
|
27
|
+
| --- | --- | --- |
|
|
28
|
+
| A1 | NON_SEMANTIC_INTERACTIVE | `onClick`/key handlers on `<div>`/`<span>`/`<li>`/`<tr>`; `role="button\|link\|tab…"` on a non-native element; redundant `role` on a native one |
|
|
29
|
+
| A2 | MISSING_TEXT_ALT | `<img>` with no `alt`; `<img alt="">` to confirm as decorative; icon-only `<svg>` with no name and no `aria-hidden` |
|
|
30
|
+
| A3 | UNLABELED_CONTROL | `<input>`/`<select>`/`<textarea>` with no `id` / `aria-label` / `aria-labelledby`; `<label>` with no `htmlFor`; icon-only `<button>` with no accessible name |
|
|
31
|
+
| A4 | HEADING_LANDMARK | `<h3+>` with no `<h1>`/`<h2>` in the file; multiple `<main>`; a landmark built as a styled `<div>`; `<section>`/`<article>` with no accessible name |
|
|
32
|
+
| A5 | FOCUS_KEYBOARD | positive `tabIndex`; `onMouseOver` with no `onFocus` twin; focus outline removed with no `:focus-visible`; `aria-hidden="true"` on something focusable; `autoFocus` |
|
|
33
|
+
|
|
34
|
+
For a large scope, fan classification out to read-only `Explore` sub-agents (one per group), each
|
|
35
|
+
briefed with this file.
|
|
36
|
+
|
|
37
|
+
## 3 · Judge
|
|
38
|
+
|
|
39
|
+
For each row decide: **DEFECT** (fix), **OK** (a false positive — say why in one clause), or
|
|
40
|
+
**NEEDS_VISUAL** (can't tell from source — e.g. is that `<div onClick>` also reachable another
|
|
41
|
+
way?). Map every DEFECT to the fix:
|
|
42
|
+
|
|
43
|
+
- **A1** → the native element. A thing that navigates is an `<a href>`; a thing that acts in place
|
|
44
|
+
is a `<button type="button">`. A custom widget that must stay a `<div>` needs `role` **and**
|
|
45
|
+
`tabIndex={0}` **and** an `onKeyDown` for Enter/Space **and** a visible focus style — all four,
|
|
46
|
+
or it's a defect. Redundant `role` on a native element → delete the `role`.
|
|
47
|
+
- **A2** → `<img alt="…">` describing purpose, not appearance; truly decorative → `alt=""` **and**
|
|
48
|
+
confirm it carries no information. Icon-only `<svg>` that conveys meaning → `role="img"` +
|
|
49
|
+
`aria-label`; purely decorative → `aria-hidden="true"` and let the adjacent text carry it.
|
|
50
|
+
- **A3** → a programmatically associated `<label htmlFor={id}>` (visible label preferred over
|
|
51
|
+
`aria-label`). Icon-only control → `aria-label` naming the action ("Delete row", not "trash").
|
|
52
|
+
- **A4** → one `<h1>` per page, no skipped levels (an `<h2>` may not jump to `<h4>`); real
|
|
53
|
+
landmark elements (`<nav>`, `<header>`, `<main>` once, `<footer>`, `<aside>`); every `<section>`
|
|
54
|
+
used as a region gets an `aria-labelledby` pointing at its heading (or an `aria-label`).
|
|
55
|
+
- **A5** → remove positive `tabIndex` (use `0` or `-1` and DOM order); pair pointer handlers with
|
|
56
|
+
keyboard equivalents (`onFocus`/`onBlur`, `onKeyDown`); never suppress the focus ring without a
|
|
57
|
+
`:focus-visible` replacement; `aria-hidden` never wraps a focusable node; drop `autoFocus`
|
|
58
|
+
unless the screen exists only to take that one input.
|
|
59
|
+
|
|
60
|
+
**Cross-check the project's own rules** (`.claude/rules/*`) if present — many projects already
|
|
61
|
+
mandate "4 states", `focus-visible`, semantic landmarks, an icon set with `aria-hidden`. Cite the
|
|
62
|
+
slug in the finding when one applies.
|
|
63
|
+
|
|
64
|
+
## 4 · Findings
|
|
65
|
+
|
|
66
|
+
Emit the `findings.json` schema (`report.md`) with these heuristic ids:
|
|
67
|
+
|
|
68
|
+
| id | finding |
|
|
69
|
+
| --- | --- |
|
|
70
|
+
| `A1` | Non-semantic interactive element — what it is now → the element it should be |
|
|
71
|
+
| `A2` | Missing / wrong text alternative — element · what's missing |
|
|
72
|
+
| `A3` | Unlabeled form control or icon-only button — control · proposed label wiring |
|
|
73
|
+
| `A4` | Heading-order or landmark gap — file · the jump / the div-landmark / the unnamed region |
|
|
74
|
+
| `A5` | Focus / keyboard problem — the specific smell + the fix |
|
|
75
|
+
|
|
76
|
+
`severity`: `crit` a core action is keyboard-unreachable or a form control has no name ·
|
|
77
|
+
`p1` non-semantic interactive on a common path, missing `alt` on meaningful images, focus ring
|
|
78
|
+
removed · `p2` landmark/heading structure, decorative-alt confirmations · `p3` single-site polish.
|
|
79
|
+
`needs_visual: true` whenever the row can't be confirmed a defect from source alone.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# kit-ux-audit — consistency lane
|
|
2
|
+
|
|
3
|
+
Design-system consistency pass over a chosen scope (an app, a route group, a page, a component, a
|
|
4
|
+
directory). **Detection is `scripts/ux-ds-audit.sh`** (grep/perl, `$0`, macOS-safe) — **judgment
|
|
5
|
+
is the model** (classify, compare siblings, propose variants, route decisions). Never eyeball code
|
|
6
|
+
for a pattern the script already finds.
|
|
7
|
+
|
|
8
|
+
Nothing here is project-specific: the shared-UI barrel, the custom-class prefix and the theme file
|
|
9
|
+
are all parameters (`--primitives` / `--css-prefix` / `--css`). Read the project's own
|
|
10
|
+
`.claude/rules/*ui-convention*` (if any) at run time for the values and the rule-slugs findings
|
|
11
|
+
should cite.
|
|
12
|
+
|
|
13
|
+
## 1 · Pick the scope (ask, don't guess)
|
|
14
|
+
|
|
15
|
+
`AskUserQuestion` with these options unless the request already names one:
|
|
16
|
+
|
|
17
|
+
| Scope | `<path>` example | Extra |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| whole app | `apps/web/src` | `--exclude '<regex>'` when a second surface lives in the app |
|
|
20
|
+
| route group / page | `apps/web/src/app/sign-in` | also pass its **sibling** screens for §3 |
|
|
21
|
+
| component | `src/components/course-card.tsx` | plus every file that renders it |
|
|
22
|
+
| package | `packages/ui/src/components` | flips the question: are the variants the apps need present? |
|
|
23
|
+
|
|
24
|
+
Always pass `--css <theme.css>` for the app's token/theme file, and `--css-prefix <p>` if the
|
|
25
|
+
project uses a prefix for its custom classes (without it, section 8's TSX custom-class hunt is
|
|
26
|
+
skipped).
|
|
27
|
+
|
|
28
|
+
## 2 · Detect (deterministic)
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
scripts/ux-ds-audit.sh <path> [--exclude <re>] --primitives <ui-barrel> --css <theme.css> [--css-prefix <p>] > /tmp/ux-ds.txt
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Ten sections, each `(N hits)` + `file:line` rows:
|
|
35
|
+
|
|
36
|
+
1. **PRIMITIVE_CLASSNAME** — shared-UI primitives rendered with a `className` (the variant-candidate pool)
|
|
37
|
+
2. **HEADINGS** — `<h1-3>` carrying a display/`type-*` role outside a heading primitive
|
|
38
|
+
3. **CARD_SURFACES** — `rounded` + border + surface bg typed by hand on a non-Card element
|
|
39
|
+
4. **SKELETONS** — `animate-pulse` outside the UI package + fill-token drift
|
|
40
|
+
5. **STATUS_LINES** — `role=status|alert` / `aria-live` typed by hand
|
|
41
|
+
6. **RAW_CONTROLS** — raw `<button|input|select|textarea>` + underline-link recipes
|
|
42
|
+
7. **CARD_GRIDS** — `grid grid-cols-*` recipes (page ↔ `loading.tsx` drift shows here)
|
|
43
|
+
8. **CUSTOM_CSS** — `<prefix>-*` classes + `data-*` styling hooks in TSX; dead classes; rules that
|
|
44
|
+
reach into a primitive's `data-slot`
|
|
45
|
+
9. **ICON_PROPS** — repeated `<XxxIcon size={N} strokeWidth={S}>` tuples
|
|
46
|
+
10. **REPEATED_CLASSNAMES** — identical multi-utility `className` literals appearing 3+ times
|
|
47
|
+
|
|
48
|
+
For a large scope, fan classification out to read-only `Explore` sub-agents (one per section
|
|
49
|
+
group), each briefed with this file.
|
|
50
|
+
|
|
51
|
+
## 3 · Judge (the model's half)
|
|
52
|
+
|
|
53
|
+
**Classify every §1 row** into exactly one bucket:
|
|
54
|
+
|
|
55
|
+
- **LAYOUT** — placement only (`mt-*`, `w-full`, `mx-auto`, `max-w-*`, `shrink-0`, `self-*`, grid/
|
|
56
|
+
flex placement). Fine. No action.
|
|
57
|
+
- **VISUAL** — color, bg, border, radius, shadow, font/`type-*`, size (`h-*`, `p-*`, `px-*`),
|
|
58
|
+
`rounded-*`, hover/active state, or a custom CSS class on the primitive. **Variant candidate.**
|
|
59
|
+
Group by (component, override string); 2+ hits or a clear re-skin → propose
|
|
60
|
+
`variant`/`size`/`shape`/`tone` on the primitive's variant map. Explicit variants, never
|
|
61
|
+
booleans.
|
|
62
|
+
- **BEHAVIOR** — `hidden md:flex`, `print:hidden`, `sr-only`, `data-*` hooks. Legitimate call-site
|
|
63
|
+
concern. Keep.
|
|
64
|
+
|
|
65
|
+
**Sibling-screen comparison** (page scope): diff the screens that should look the same (sign-in vs
|
|
66
|
+
register vs verify; list pages under one route group; page vs its `loading.tsx`). One row per
|
|
67
|
+
property, one column per screen: width, padding, header shape, back-link treatment, card nesting (a
|
|
68
|
+
Card inside a Card is a bug), icon variant, skeleton shape.
|
|
69
|
+
|
|
70
|
+
**Hand-rolled → foundation** (§2–§7, §9, §10): map each recipe to the primitive that should own it
|
|
71
|
+
(a heading/PageHeader, Card, Skeleton, StatusText, CardGrid, EmptyState, Button, TextLink …).
|
|
72
|
+
Missing primitive → check the component registry the project uses (e.g.
|
|
73
|
+
`npx shadcn@latest search <term>`), record "used <x>" or "no fit because …".
|
|
74
|
+
|
|
75
|
+
**Custom CSS** (§8): a theme rule restyling `[data-slot='…']` / `[role='…']` from outside is a
|
|
76
|
+
**variant in disguise** → propose the prop, delete the rule. One-off page decoration (covers,
|
|
77
|
+
parallax, art direction) stays. Zero-reference classes are dead → delete.
|
|
78
|
+
|
|
79
|
+
## 4 · Findings
|
|
80
|
+
|
|
81
|
+
Emit the `findings.json` schema (`report.md`) with heuristic ids `C1`…`C6`:
|
|
82
|
+
|
|
83
|
+
| id | finding |
|
|
84
|
+
| --- | --- |
|
|
85
|
+
| `C1` | Variant candidate — component · override string · hits · proposed prop |
|
|
86
|
+
| `C2` | Hand-rolled recipe → primitive that should own it (+ registry check) |
|
|
87
|
+
| `C3` | Sibling-screen drift — property · per-screen values · diagnosis |
|
|
88
|
+
| `C4` | Custom CSS verdict — variant-in-disguise / layout-keep / dead-delete |
|
|
89
|
+
| `C5` | Repeated className literal → component or variant, with locations |
|
|
90
|
+
| `C6` | Card-in-Card / structural nesting bug |
|
|
91
|
+
|
|
92
|
+
`severity`: `crit` never (consistency is not a blocker) · `p1` core component or ≥ 2 screens
|
|
93
|
+
diverge · `p2` localized · `p3` single-site polish. `needs_visual: true` when the verdict depends
|
|
94
|
+
on how it *looks* rendered (re-skin vs coincidence).
|
|
95
|
+
|
|
96
|
+
## 5 · Route
|
|
97
|
+
|
|
98
|
+
- Design DECISIONS (a new visual value, which of two treatments wins) → **designer** agent.
|
|
99
|
+
IMPLEMENTATION with existing tokens → **frontend** agent.
|
|
100
|
+
- Whole app → `/kit-effort-new`: a foundation sub first, sweeps parallel, a variant-adoption sweep
|
|
101
|
+
last. One component/page → the quick lane, still in a worktree.
|
|
102
|
+
- Every new shared primitive/variant lands with its inventory row in the project's UI-conventions
|
|
103
|
+
rule + its barrel export, same PR.
|
|
104
|
+
- **Verification** = re-run `ux-ds-audit.sh` on the same scope and re-classify the refreshed §1
|
|
105
|
+
rows: none may classify VISUAL; §4/§7 are zero outside the UI package; §8 shows no rule reaching
|
|
106
|
+
into a `data-slot`.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# kit-ux-audit — normalized graph model
|
|
2
|
+
|
|
3
|
+
Both graph sources (graphify `graph.json`, and the fallback `ux-graph-scan.sh`) are read into one
|
|
4
|
+
model before the heuristics run. Keep it as compact JSON; you hand **slices** to the agent, never
|
|
5
|
+
the whole graph and never source files.
|
|
6
|
+
|
|
7
|
+
## Nodes
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
{ "id": "screen:OrderDetail",
|
|
11
|
+
"kind": "screen", // route | screen | container | component | data-entity | form | field | mutation | store
|
|
12
|
+
"label": "Order detail",
|
|
13
|
+
"file": "app/orders/[id]/page.tsx", // best-effort; may be absent from a semantic graph
|
|
14
|
+
"meta": { "entry": false, "frequent": false, "steps": 1 } }
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
- `route` — a URL a user can land on. `meta.entry: true` for app entry points (`/`, `/dashboard`,
|
|
18
|
+
post-login landing, anything with no inbound app nav).
|
|
19
|
+
- `screen` — the view a route renders. A route and its screen are often 1:1; keep both when the
|
|
20
|
+
same screen backs several routes (H5).
|
|
21
|
+
- `container` — layout/nav wrapper that renders screens (root layout, route-group layout, tab
|
|
22
|
+
shell). Carries the back/nav affordance for H4/H12.
|
|
23
|
+
- `component` — reusable UI unit. Fan-in matters (H9).
|
|
24
|
+
- `data-entity` — a domain object the UI reads or writes (`Order`, `Customer`, `Plan`). From a
|
|
25
|
+
semantic graph, these exist directly; from the scan, they're inferred from query/mutation
|
|
26
|
+
identifiers and table names.
|
|
27
|
+
- `form` — a form instance on a screen. `meta`: `fields`, `required`, `steps`, `hasDraft`,
|
|
28
|
+
`hasStepper`.
|
|
29
|
+
- `field` — optional; only model individually when a cross-field rule (H6) or a create/edit diff
|
|
30
|
+
(H7) needs it.
|
|
31
|
+
- `mutation` — a write operation (`createOrder`, `deleteCustomer`, server action, `useMutation`).
|
|
32
|
+
`meta.verb`: `create|update|delete|archive|other`; `meta.guarded`: has a confirm step.
|
|
33
|
+
- `store` — shared client state (context/zustand/redux slice) when it's an editing surface.
|
|
34
|
+
|
|
35
|
+
## Edges
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
{ "from": "screen:Orders", "to": "data-entity:Order", "type": "writes",
|
|
39
|
+
"meta": { "via": "form:OrderQuickEdit" } }
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
| type | meaning | main heuristics |
|
|
43
|
+
| --- | --- | --- |
|
|
44
|
+
| `imports` | module A imports module B | graph plumbing |
|
|
45
|
+
| `renders` | screen/container renders component/screen/form | H4, H5, H9, H10 |
|
|
46
|
+
| `navigates-to` | code path that changes route (`<Link>`, `router.push`, `redirect`, `navigate`, `<a href>` internal) | H3, H4, H5, H12 |
|
|
47
|
+
| `reads` | screen/component reads an entity (query, loader, `useX`, `select`) | H2, H10 |
|
|
48
|
+
| `writes` | screen/form persists an entity (non-destructive) | H1, H2, H10 |
|
|
49
|
+
| `mutates` | destructive write (delete/archive) | H1, H11 |
|
|
50
|
+
| `validates` | form ↔ field / field ↔ field validation rule | H6, H7 |
|
|
51
|
+
| `duplicates` | two forms / two routes judged equivalent (same entity + overlapping fields, or same screen under two parents) | H5, H7 |
|
|
52
|
+
|
|
53
|
+
`duplicates` from the scan is heuristic (name + entity + field-overlap ≥ 0.6). From graphify, use
|
|
54
|
+
`INFERRED` edges plus community co-membership.
|
|
55
|
+
|
|
56
|
+
## Derived metrics (compute before slicing)
|
|
57
|
+
|
|
58
|
+
- **click-depth**: BFS over `navigates-to` from every `meta.entry` route to each screen; store the
|
|
59
|
+
minimum. Screens unreachable by `navigates-to` → depth `∞` → orphan candidates (H4).
|
|
60
|
+
- **god-nodes**: `component` (and `screen`) nodes ranked by inbound `renders` count. Top decile or
|
|
61
|
+
fan-in ≥ 10 → H9 pool.
|
|
62
|
+
- **community bridges**: if the graph carries communities (graphify does; for the scan, run a quick
|
|
63
|
+
label-propagation on the `renders`+`navigates-to` subgraph), collect edges whose endpoints are in
|
|
64
|
+
different communities. These cross-feature edges are where "confusing" flows concentrate — feed
|
|
65
|
+
them to the agent verbatim.
|
|
66
|
+
- **edit-surface map**: per `data-entity`, the set of `screen`s with a `writes`/`mutates` edge
|
|
67
|
+
(directly or `via` a form). This is the H1 input and a report section on its own.
|
|
68
|
+
|
|
69
|
+
## Mapping graphify `graph.json` → this model
|
|
70
|
+
|
|
71
|
+
graphify nodes carry `type`/`kind` and `source_location`; edges carry a `relation` and an
|
|
72
|
+
`EXTRACTED|INFERRED|AMBIGUOUS` provenance.
|
|
73
|
+
|
|
74
|
+
- node `kind`: map `file`/`module` whose path matches a route convention (`app/**/page.*`,
|
|
75
|
+
`pages/**`, `src/pages/**`, `src/routes/**`, a `*.route.*`) → `route`+`screen`; `layout.*` /
|
|
76
|
+
`*Layout` → `container`; a component export rendered by screens → `component`; a symbol matching
|
|
77
|
+
`/^use[A-Z]/` returning data or a Prisma/SQL/`.from(` call → fold into a `data-entity` +
|
|
78
|
+
`reads`/`writes`; a `*Form`/`useForm` symbol → `form`.
|
|
79
|
+
- edges: graphify `imports`/`calls`/`renders` → `imports`/`renders`; a call into a router API →
|
|
80
|
+
`navigates-to`; a call into a data client → `reads`/`writes`/`mutates` by verb.
|
|
81
|
+
- keep graphify `community` / `community_name` on nodes — reuse directly for bridges.
|
|
82
|
+
- provenance: treat `AMBIGUOUS` edges as `needs_visual` fuel, never as hard evidence.
|
|
83
|
+
|
|
84
|
+
Do the mapping in memory (or a tiny throwaway script). Persist the normalized graph to
|
|
85
|
+
`<target>/graphify-out/.ux_model.json` so a re-run can reuse it.
|
|
86
|
+
|
|
87
|
+
## Mapping the fallback scan → this model
|
|
88
|
+
|
|
89
|
+
`ux-graph-scan.sh --scan <dir>` already emits this shape at
|
|
90
|
+
`<dir>/graphify-out/.ux_graph.json` (`{ "nodes": [...], "edges": [...], "meta": {...} }`). It is
|
|
91
|
+
**approximate** — regex over TSX/Vue, not an AST. Mark the report "graph source: deterministic
|
|
92
|
+
scan" so findings are read with that caveat, and lean harder on `needs_visual`.
|