agentleFS
lastxuanainlastxuanain/ainward-skills/skills/frontend-craft/SKILL.md

frontend-craft

Skill5 starsChanged 9 days agoMITView on GitHub

Web UI consistency, anti-AI-slop, 5-state UX & CJK form rules when building, rebuilding, or editing UI (NOT read-only reviews, git syncs, or non-UI logic). Triggers: /frontend-craft, "frontend craft", "ui spec", "前端规范", "UI 规范", "去 AI 味".

11 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 9 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

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

    No magic values: no hardcoded hex/rgb colors, and no spacing, radius, or size literals that are off the token scale (e.g.

    line 85

“Common” is measured: kept by at least 6 in 10 of the 9 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

Frontend Craft

Build cohesive, production-grade web interfaces across React, Next.js, Vue, Nuxt, Svelte, Astro, and vanilla HTML/CSS/TypeScript—matching repository conventions, eliminating AI-slop visuals, and enforcing complete async UX states, CJK-safe forms, clean state boundaries, and modern native web primitives.

0. Precedence

Explicit user instructions > repository rules and established conventions (tokens, lint config, shared component APIs, existing copy) > this skill. The rules and bans below are defaults for new or rebuilt code. When the repo deliberately does otherwise (e.g. renders N/A, uses a different breakpoint scale), match the repo, do not "fix" it in passing, and mention the deviation once in your summary if it matters.

1. Proportional Scope & Recon

Skip this skill on read-only code reviews, git syncs, pure non-UI state/TS logic, backend/CLI/infra code, or build-only config edits. Scale recon to task scope:

  • Localized tweak (a line or a few lines): match surrounding tokens and conventions in-file; skip multi-file repo scans and the rest of this checklist except the bans that the edited lines would directly violate. Never rewrite, split, or refactor untouched legacy code in the file.
  • New or rebuilt component/page: inspect repo tokens (tailwind.config.*, CSS @theme / :root), layout shells (AppLayout, PageShell), shared components/ui/ + package.json UI/icon libraries, and 1 canonical sibling route first. Reuse or cleanly extend shared primitives—never fork raw <div class="p-6 flex ..."> page chrome or install rival UI/icon libraries.
  • 0-to-1 greenfield: scaffold semantic tokens + layout/primitives proportional to app scope (tokens + PageShell + core primitives first on multi-route apps; no unused admin table/badge scaffolding on a landing page or single-screen prototype).

2. Density & Layout Contracts

  • Product density modes:
    • B2B compact: body text at the 13px or 14px step of the type scale, high-density neutral surfaces, crisp hairline borders, 150ms transitions; no tall hero metric cards pushing tables below the fold (use compact inline summary/filter strips).
    • 100dvh split workbench: viewport-locked height: 100dvh; overflow: hidden outer shell (no outer-body double scrollbars) with independently scrolling master, canvas (flex: 1; min-width: 0), and inspector panes.
    • Brand editorial: intentional focal hierarchy, generous whitespace, real imagery/bespoke SVG, and prefers-reduced-motion-safe reveals.
  • Form width & grid containment: cap single-column forms at 640px–800px (max-w-2xl/max-w-3xl) in 3–7 field sections with consistent Cancel + Save/Submit footers. Asymmetric CSS grids must bound tracks with minmax(0, ...) (e.g. minmax(0, 2fr) minmax(280px, 1fr)) and min-w-0 so wide <pre>, URLs, or tables cannot blow out the viewport.
  • Single composite contracts:
    • DataTable: render null/undefined/"" cells as a muted — (not "null", "N/A", "-", or blank); right-align (<th> and <td>) money, counts, percentages, and timestamps with tabular-nums; pin wide-table actions to sticky right (inset-inline-end: 0) and fold more than 3 actions into a More (⋯) menu.
    • Dialog vs. Drawer: centered Dialog for confirmations and up to 5 fields; Drawer/Sheet (100dvh) for previews, logs, or more than 5 fields.
    • EmptyState & StatusBadge: a single monochrome SVG EmptyState; map status enums through one centralized semantic tone map (neutral | info | success | warning | danger) repo-wide.

3. Tokens & Anti-AI-Slop

  • 3-tier tokens & @layer: wire Primitive -> Semantic -> Component one way (features consume Semantic tokens only; themes swap Tier 2 only). Govern specificity via @layer; no !important outside a11y/print.
  • No magic values: no hardcoded hex/rgb colors, and no spacing, radius, or size literals that are off the token scale (e.g. padding: 13px, gap: 27px). Font sizes come from the type scale—a 13px body step defined there is a token, not a magic number.
  • Visual dictionary: lock 1 UI sans (+ optional brand display font), 1 monospace font, 3 macro spacing tokens (--space-page, --space-section, --space-card), and 1 neutral ramp on a 90 / 8 / 2 ratio (~90% neutral surfaces/text, ~8% hairline borders/muted text, ≤2% accent for primary CTA and active state).
  • Anti-AI-slop bans: indigo-purple-pink neon gradients, glowing or 3-level nested cards, muddy static drop shadows, more than 1 pill per row/card (format secondary metadata as ·-separated muted text), and emojis (🚀✨) as UI icons (use one uniform 1.5px–1.75px stroke vector set with currentColor).

4. 5-State Async UX & CJK-Safe Forms

  • Every async view handles all 5 states:
    • Loading: geometry-matched initial skeleton; keep rows visible (keepPreviousData / toolbar indicator) on filter/page changes—never block routine reads with a full-screen spinner.
    • Empty: separate first-use empty (context + primary CTA) from zero filter matches (message + 1-click Clear Filters).
    • Error: inline error boundary + Retry preserving filters/drafts. Never catch { return []; }—that disguises errors as empty.
    • Overflow: min-width: 0 (min-w-0) on flex/grid text children, truncate / line-clamp-*, and tag flex-wrap / +N collapse.
    • Pending: lock submit/mutation buttons (disabled / aria-busy) on first click without width jitter; roll back failed optimistic updates cleanly.
  • Forms, CJK IME & semantic DOM: delay validation errors until blur or first submit (:user-invalid—never red on blank mount), clear eagerly on input, and focus the first aria-invalid="true" field on failed submit. Guard every Enter-to-submit keydown handler against IME composition: if ((e.nativeEvent?.isComposing ?? e.isComposing) || e.keyCode === 229) return;. Confirm before closing dirty forms (beforeunload, route leave, backdrop/Esc); pair inputs with <label>; use <button type="button"> vs. <a href> (no <div onClick>); require aria-label on icon-only buttons.

5. Component/State Boundaries & Native Baseline

  • Boundaries & state: one-way pages -> features -> ui imports (~250-line split target on new/rebuilt components only); no stateful child components defined inside a parent's render. Keep API data in a server cache (Query / SWR / RSC / useAsyncData—never mirrored into Zustand/Pinia/Redux); sync list filters, sort, tabs, and page to URL search params; compute derived/filtered state synchronously during render (computed / $derived, not useEffect / watch → setState mirroring); pass AbortSignal on filter races; no bare any (map raw DTOs at the API boundary).
  • Native baseline: a native <dialog> must use ref.showModal() / ref.close() (never <dialog open={isOpen}>); prefer popover or headless primitives over z-index / body.style.overflow hacks (scrollbar-gutter: stable). Use @container on widgets, 100dvh (+ safe-area-inset-bottom), :has(), text-wrap: balance/pretty, bounded field-sizing: content as progressive enhancement, color-mix(in oklab), explicit media aspect-ratio (fetchpriority="high" hero, loading="lazy" below the fold), and 150ms–250ms transform/opacity transitions (no transition: all) honoring prefers-reduced-motion.

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.