AgentSkillsCN

auditing-web-design

对UI代码进行无障碍性、性能以及用户体验合规性的审计。在审查组件、检查无障碍性,或在产品上线前验证UI时,可使用此功能。

SKILL.md
--- frontmatter
name: auditing-web-design
description: Audits UI code for accessibility, performance, and UX compliance. Use when reviewing components, checking accessibility, or validating UI before shipping.
invocation: user
arguments: "[file-or-directory]"

Auditing Web Design

Systematic UI audit using Vercel's Web Interface Guidelines.

Contents

Quick Audit

Run these checks on any component:

bash
# 1. Accessibility snapshot
browser_snapshot  # Check for missing labels, focus issues

# 2. Console errors
browser_console_messages  # Check for warnings

# 3. Visual inspection
browser_take_screenshot  # Capture current state

Priority Checks

CheckHow
Icon buttons have labelsaria-label on every icon-only button
Form inputs labeled<label> or aria-label on all inputs
Focus visibleTab through - every element visible
Images sizedwidth/height on all <img>
Lists virtualized>50 items? Use virtualization

Accessibility

Required

ElementRequirement
Icon buttonsaria-label="descriptive text"
Form inputs<label> with htmlFor or aria-label
Interactive elementsKeyboard handlers (onKeyDown)
Async updatesaria-live="polite"
HeadingsFollow hierarchy (h1 → h2 → h3)

Focus States

css
/* Good */
.btn:focus-visible {
  @apply ring-2 ring-amber-500 ring-offset-2 ring-offset-zinc-900;
}

/* Bad */
.btn:focus {
  outline: none;  /* Never without replacement */
}

Rules:

  • Never outline-none without visible replacement
  • Prefer :focus-visible over :focus
  • Contrast ratio ≥ 3:1 for focus indicators

Forms

InputRequirements
Emailtype="email", autocomplete="email"
Passwordtype="password", autocomplete="current-password"
Nameautocomplete="name"
Searchtype="search", disable spellcheck

Validation Pattern

tsx
// Inline errors, focus first error
<input aria-invalid={!!error} aria-describedby={error ? `${id}-error` : undefined} />
{error && <span id={`${id}-error`} role="alert">{error}</span>}

Rules:

  • Submit button enabled until request starts
  • Errors inline, not toast/modal
  • Focus first error on submission
  • Block autocomplete on non-auth fields: autocomplete="off"

Performance

Images

tsx
// Above fold
<Image src={src} width={800} height={600} priority />

// Below fold
<Image src={src} width={800} height={600} loading="lazy" />

Rules:

  • Always explicit width/height
  • priority for above-fold, loading="lazy" below
  • Use Next.js <Image> for automatic optimization

Lists

tsx
// Bad: rendering 1000 items
{items.map(item => <Item key={item.id} {...item} />)}

// Good: virtualized
<VirtualList items={items} itemHeight={48} />

Rule: Virtualize lists > 50 items

Preloading

tsx
// In <head>
<link rel="preconnect" href="https://cdn.example.com" />
<link rel="preload" href="/fonts/custom.woff2" as="font" crossOrigin="" />

Animation

Required

css
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

Rules

DoDon't
Animate transform, opacityAnimate width, height, top
Use specific propertiestransition: all
Make interruptibleLock user during animation

Typography

PatternImplementation
EllipsisUse character, not ...
QuotesCurly "" not straight ""
Numbersfont-variant-numeric: tabular-nums
Headingstext-wrap: balance
Non-breaking&nbsp; between number and unit

Anti-Patterns

Flag these immediately:

PatternProblemFix
outline: none aloneBreaks keyboard navigationAdd ring-* replacement
transition: allPerformance, unintended effectsSpecify properties
onPaste preventDefaultBreaks password managersRemove handler
Zoom-disabling viewportAccessibility violationuser-scalable=yes
Click handler on non-buttonNot keyboard accessibleUse <button>
Hardcoded date formatsi18n issuesUse Intl.DateTimeFormat

Verification

After audit:

  1. Tab test - Every interactive element reachable and visible
  2. Screen reader - VoiceOver/NVDA announces correctly
  3. Console - No warnings or errors
  4. Lighthouse - Accessibility score ≥ 90