agentleFS
nurmdrafinurmdrafi/pi-native/skills/refactoring-ui/SKILL.md

refactoring-ui

Skill4 starsChanged 5 days agoMITView on GitHub

Audit and fix existing web UIs — hierarchy, spacing, color, depth. Use when the UI "looks off", needs polish, a design system, or dark mode, or small UI defects need fixing (links to missing routes, invalid media queries, shared spinner states). FIXING/POLISHING existing UI only — NOT for building new UI → frontend-design.

19 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use prototype.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • GoogleSkill

    prototype

    Build a throwaway prototype to answer a design question. Use when the user wants to sanity-check whether a state model or logic feels right, or explore what a UI should look like.

    Also in 4 projects that use this

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 3 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 18 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Verify real data keys before using them (localStorage.getItem('x') — confirm key against code that WRITES it, not a copy-pasted page).

    line 19
  2. Distinctive:

    No production build to verify style-only changes in dev-server project — HMR shows live.

    line 20
  3. Very specific:

    After ANY scripted/regex edit to JSX: parse every touched file (esbuild --loader:.jsx) before declaring success.

    line 21
  4. Distinctive:

    Start with too much whitespace, then remove — you'll almost never remove enough.

    line 44
  5. Distinctive:

    Never convey meaning by color alone — always pair text/icon.

    line 59

“Common” is measured: kept by at least 6 in 10 of the 18 edited versions of this file we could read. “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
SKILL.md

Refactoring UI (slim)

Audit-first system for fixing existing UIs. Sibling of frontend-design (greenfield). Apply when reviewing/polishing frontend code.

Core: design in grayscale first, color last. Great UI = systems, not talent — constrained scales for spacing, type, color, shadows. Start with too much whitespace, then remove.

0. House style wins over this skill (hard rules from real failures)

  • Before redesigning ANY page: audit 2-3 sibling pages in same app section, copy their EXACT layout idiom — wrapper padding, page width (full vs constrained), heading size/tag, card style object. App's established pattern beats this skill's generic advice every time. "Better" design breaking app consistency = bug, not improvement.
  • Verify real data keys before using them (localStorage.getItem('x') — confirm key against code that WRITES it, not a copy-pasted page).
  • No production build to verify style-only changes in dev-server project — HMR shows live. Build only when imports/deps changed.
  • After ANY scripted/regex edit to JSX: parse every touched file (esbuild --loader:.jsx) before declaring success. Regex count check ≠ verification. Prefer edit tool over ad-hoc python replace for JSX blocks — string replace on JSX nests/duplicates tags silently.

0b. Logic-in-UI hard rules

Apply when "polish" touches data flow, not just styles:

  • Fetch-on-selection: staleness guard (cancelled flag / compare requested id) AND .catch clearing previous entity's data — late/failed response must never leave old data savable against new selection.
  • Clearing/resetting state: enumerate every derived field (rg its consumers). Common survivors: derived data field alive after its "Clear" action; dependent list alive after parent selection changes.
  • Form pre-filled from row 1 + values.x ?? o.x fallback = dead fallback; bulk saves apply row 1's value to every row. Open fields empty or track touched fields.
  • Lazy tab panes drop setFieldsValue made before mount (rc-tabs) — forceRender: true or prefill on tab activation.
  • AntD edit forms: initialValues bind only at Form mount — fetch-then-fill needs remount gate (loading spinner) or form.setFieldsValue; display-only defaultValue inside Form.Item leaves store empty, submits placeholder garbage (moment(undefined) formats as today).
  • List-row state keyed by index or load-time snapshot goes stale when row removed or list re-orders: delete-by-index removes wrong row, default-switch keys land one row off, failed save + retry can submit stale snapshot (or empty list). Read id from live form row at action time; rebuild list payloads from current form values at submit — never toggle-time snapshot.
  • Conditional columns/panels: verify DEFAULT state of every span/collapse condition (panel hidden at span=0 unless nav expanded ships invisible).

Scoring

Rate UI 0–10 on principles below. State score + specific fixes to reach 10. Deliver in chat only — do NOT write an audit-reports/ file for this skill.

1. Hierarchy — not everything can be important

  • Three levers: size, weight, color. Combine, don't stack — primary = large OR bold OR dark, not all three.
  • "All three" reserved for single most important element on page.
  • De-emphasize labels (form labels, table headers, metadata): smaller / lighter / uppercase-small. Values win over labels.
  • Semantic color ≠ visual weight — muted danger button beats screaming one for routine actions.

2. Spacing & sizing — relationships, not arbitrary values

  • Scale: 4, 8, 16, 24, 32, 48, 64 (p-1 p-2 p-4 p-6 p-8 p-12 p-16).
  • Start with too much whitespace, then remove — you'll almost never remove enough.
  • Space between groups > within groups.
  • Text constrained to 45–75 chars (max-w-prose ~65ch); forms 300–500px (max-w-md). Full-width almost never right.

3. Typography — modular scale, two families max

  • Scale (1.25 ratio): 12, 14, 16, 20, 24, 30, 36 (text-xs/sm/base/lg/xl).
  • Headings tight (leading 1.0–1.25), body relaxed (1.5–1.75). Wider text → more leading.
  • Emphasis via 600–700, not everywhere. Body weight ≥ 400.
  • Two fonts max — or one family with weight variation.

4. Color — system first, grayscale first

  • 5–9 shades per color (50–900). Darkest = 900-gray (#111827), never pure black.
  • Pure grays look dead — subtle tint (cool → blue #64748b, warm → #78716c).
  • Body text ≥ 4.5:1 contrast; large (18px+) ≥ 3:1. #374151 (gray-700) on white.
  • HSL variants: lighter = +lightness / −saturation / hue→60; darker = −lightness / +saturation / hue→0 or 240.
  • Never convey meaning by color alone — always pair text/icon.

5. Depth & shadows — elevation scale

  • Small = raised (buttons/cards shadow-sm/md); large = floating (dropdowns/modals shadow-lg/xl).
  • Two-part shadow: tight dark (crispness) + large soft (atmosphere). Color = transparent dark, not opaque gray.
  • Depth without shadow: lighter top border + darker bottom border, subtle gradient, offset overlap.
  • Everything floats → nothing has depth.

6. Images & icons — design elements

  • Icons sized to context, consistent stroke/style (w-4 h-4 inline, w-6 h-6 nav, w-8 h-8 feature).
  • Images: object-fit: cover + fixed aspect-ratio — never distort.
  • Text on images needs overlay (bg-gradient-to-t from-black/60 to-transparent).
  • Empty states: illustration + clear CTA, not bare text.

7. Layout — don't center everything

  • Left-align text default; center only short headlines, heroes, single CTAs, empty states.
  • Images bleed past card bounds; overlap containers; vary emphasis between list items.
  • Sidebars 240–320px on lighter bg. Page container max-w-4xl mx-auto.

Quick diagnostic

CheckIf it fails →
Squint/blur test: hierarchy reads?boost primary vs secondary contrast
Works in grayscale?strengthen size/weight/spacing (don't lean on color)
Enough whitespace?add more, especially between groups
Labels quieter than values?smaller / lighter / uppercase labels
Spacing on scale?kill arbitrary px (13/17/23)
Text width constrained?max-w-prose on text blocks
Contrast ≥ 4.5:1?gray-700+ on white
Shadow matches elevation?align to sm/md/lg/xl by purpose

Common fixes

SymptomFix
"Looks amateur"more whitespace, constrain widths
"Feels flat"depth differentiation (shadow / border-bottom)
"Hard to read"+line-height, constrain width, +contrast
"All looks the same"vary size/weight/color — primary vs secondary
"Cluttered"group related items, grow inter-group spacing
"Colors clash"desaturate, more grays, stick to system palette
"Buttons don't pop"+contrast vs surroundings, +shadow

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.