Web Interface Guidelines skill

Review UI code for Web Interface Guidelines compliance.

by CloudAI-X·MIT license·★ 1,416 Stars on the repo·GitHub ↗

Use now

Files of Web Interface Guidelines

CloudAI-X/main1 file shown
SKILL.md
Show the full text195 lines

Web Interface Guidelines

When to Load
  • Trigger: UI audit, accessibility checks, responsive design review, UX best practices evaluation
  • Skip: Backend-only work with no UI components

Self-contained guidelines for reviewing web interfaces. Apply these rules when auditing UI code.

Output Format

Report findings as: file:line — [RULE_ID] description

Example: src/Button.tsx:12 — [A11Y-01] Missing aria-label on icon button

1. Accessibility (A11Y)

A11Y-01: Semantic HTML
  • Use <button> for actions, <a> for navigation, <input> for data entry
  • Never use <div onClick> or <span onClick> for interactive elements
  • Use <nav>, <main>, <aside>, <header>, <footer> for landmarks
A11Y-02: ARIA Labels
  • All interactive elements need accessible names
  • Icon-only buttons MUST have aria-label
  • Form inputs MUST have associated <label> or aria-label
  • Images need alt text (decorative images: alt="")
A11Y-03: Keyboard Navigation
  • All interactive elements must be reachable via Tab
  • Custom components need proper role, tabIndex, and key handlers
  • Focus must be visible (never outline: none without replacement)
  • Modal/dialog must trap focus and return focus on close
A11Y-04: Color & Contrast
  • Text contrast ratio: 4.5:1 minimum (3:1 for large text)
  • Never use color alone to convey meaning (add icons, text, patterns)
  • Ensure UI is usable at 200% zoom
A11Y-05: Screen Readers
  • Dynamic content changes need aria-live regions
  • Loading states need aria-busy="true"
  • Error messages linked to inputs via aria-describedby

2. Performance (PERF)

PERF-01: Image Optimization
  • Use next/image or responsive images with srcset
  • Specify width and height to prevent layout shift
  • Lazy load below-fold images: loading="lazy"
  • Use WebP/AVIF with fallback
PERF-02: Bundle Size
  • No barrel imports: import Button from 'lib/Button' not import { Button } from 'lib' (or enable optimizePackageImports)
  • Tree-shake CSS: use CSS modules or Tailwind content config (v3) / automatic detection (v4)
  • Lazy load routes and heavy components: React.lazy() or dynamic imports
PERF-03: Rendering
  • Avoid layout thrashing: don't read then write DOM in loops
  • Use will-change sparingly (only for known animations)
  • Prefer CSS animations over JS animations
  • Use transform and opacity for 60fps animations (compositor-only)
PERF-04: Core Web Vitals
  • LCP < 2.5s: Optimize largest image/text, preload critical resources
  • INP < 200ms: No long tasks on main thread, defer non-critical JS
  • CLS < 0.1: Set dimensions on images/embeds, no injected content above fold

3. Responsive Design (RD)

RD-01: Mobile First
  • Base styles for mobile, then @media (min-width) for larger screens
  • Touch targets minimum 44x44px
  • No horizontal scroll on any viewport
RD-02: Fluid Layout
  • Use rem/em for typography, not px
  • Use clamp() for fluid typography: font-size: clamp(1rem, 2.5vw, 2rem)
  • Flex/Grid over fixed widths
  • Max content width: max-width: 65ch for readability
RD-03: Breakpoints
  • Don't target devices, target content breakpoints
  • Common: 640px (sm), 768px (md), 1024px (lg), 1280px (xl)
  • Test at 320px, 375px, 768px, 1024px, 1440px, 1920px

4. Component Patterns (CP)

CP-01: Forms
  • Show validation errors inline, next to the field
  • Use type="email", type="tel", inputmode="numeric" for mobile keyboards
  • Disable submit button during submission (prevent double-submit)
  • Preserve form state on error (don't clear fields)
CP-02: Loading States
  • Show skeleton screens over spinners for content areas
  • Indicate progress for long operations (progress bar > spinner)
  • Disable interactive elements during loading
  • Set aria-busy="true" on loading containers
CP-03: Error States
  • Always show actionable error messages ("Try again" button, not just "Error")
  • Don't show technical errors to users (log internally, show friendly message)
  • Error boundaries for React component trees
  • Retry logic for network failures
CP-04: Empty States
  • Never show blank pages — provide helpful empty states
  • Include call-to-action: "No items yet. Create your first item."
  • Use illustrations sparingly (they add bundle weight)
CP-05: Modals & Dialogs
  • Use <dialog> element or proper role="dialog"
  • Trap focus within modal
  • Close on Escape key and backdrop click
  • Return focus to trigger element on close
  • Prevent body scroll while open

5. CSS Practices (CSS)

CSS-01: Specificity
  • Prefer class selectors over ID or element selectors
  • Avoid !important (use specificity or cascade layers)
  • Use CSS custom properties for theming
  • One direction for spacing: prefer margin-bottom over margin-top
CSS-02: Layout
  • Use Flexbox for 1D layout, Grid for 2D layout
  • Avoid position: absolute for layout (use for overlays only)
  • Use gap over margins between flex/grid children
  • Use min-height: 100dvh (not 100vh) for full-height layouts
CSS-03: Dark Mode
  • Use prefers-color-scheme media query
  • Define all colors as CSS custom properties
  • Test both modes — check contrast in both
  • Don't just invert colors — design intentionally for dark mode

6. Security (SEC)

SEC-01: Content Security
  • Never use dangerouslySetInnerHTML without sanitization
  • Sanitize user-generated content before rendering
  • Use rel="noopener noreferrer" on external links with target="_blank"
SEC-02: Forms & Input
  • CSRF protection on all forms
  • Rate limit form submissions
  • Validate on both client AND server

7. Internationalization (I18N)

I18N-01: Text
  • Don't hardcode strings — use i18n library or constants
  • Support RTL layouts: use logical properties (margin-inline-start over margin-left)
  • Don't truncate text — designs must accommodate 40% text expansion
  • Use lang attribute on <html> tag

Review Checklist

When auditing a file, check in this order (CRITICAL first):

  1. CRITICAL: A11Y-01, A11Y-02, SEC-01 — Semantic HTML, ARIA, XSS prevention
  2. HIGH: PERF-04, A11Y-03, CP-01 — Core Web Vitals, keyboard, forms
  3. MEDIUM: RD-01, CSS-02, CP-02, CP-03 — Responsive, layout, loading/errors
  4. LOW: CSS-03, I18N-01, CP-04 — Dark mode, i18n, empty states
1---
2name: web-design-guidelines
3description: Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", "check my site against best practices", or "web interface guidelines".
4---
5 
6# Web Interface Guidelines
7 
8### When to Load
9 
10- **Trigger**: UI audit, accessibility checks, responsive design review, UX best practices evaluation
11- **Skip**: Backend-only work with no UI components
12 
13Self-contained guidelines for reviewing web interfaces. Apply these rules when auditing UI code.
14 
15## Output Format
16 
17Report findings as: `file:line — [RULE_ID] description`
18 
19Example: `src/Button.tsx:12 — [A11Y-01] Missing aria-label on icon button`
20 
21## 1. Accessibility (A11Y)
22 
23### A11Y-01: Semantic HTML
24 
25- Use `<button>` for actions, `<a>` for navigation, `<input>` for data entry
26- Never use `<div onClick>` or `<span onClick>` for interactive elements
27- Use `<nav>`, `<main>`, `<aside>`, `<header>`, `<footer>` for landmarks
28 
29### A11Y-02: ARIA Labels
30 
31- All interactive elements need accessible names
32- Icon-only buttons MUST have `aria-label`
33- Form inputs MUST have associated `<label>` or `aria-label`
34- Images need `alt` text (decorative images: `alt=""`)
35 
36### A11Y-03: Keyboard Navigation
37 
38- All interactive elements must be reachable via Tab
39- Custom components need proper `role`, `tabIndex`, and key handlers
40- Focus must be visible (never `outline: none` without replacement)
41- Modal/dialog must trap focus and return focus on close
42 
43### A11Y-04: Color & Contrast
44 
45- Text contrast ratio: 4.5:1 minimum (3:1 for large text)
46- Never use color alone to convey meaning (add icons, text, patterns)
47- Ensure UI is usable at 200% zoom
48 
49### A11Y-05: Screen Readers
50 
51- Dynamic content changes need `aria-live` regions
52- Loading states need `aria-busy="true"`
53- Error messages linked to inputs via `aria-describedby`
54 
55## 2. Performance (PERF)
56 
57### PERF-01: Image Optimization
58 
59- Use `next/image` or responsive images with `srcset`
60- Specify `width` and `height` to prevent layout shift
61- Lazy load below-fold images: `loading="lazy"`
62- Use WebP/AVIF with fallback
63 
64### PERF-02: Bundle Size
65 
66- No barrel imports: `import Button from 'lib/Button'` not `import { Button } from 'lib'` (or enable `optimizePackageImports`)
67- Tree-shake CSS: use CSS modules or Tailwind `content` config (v3) / automatic detection (v4)
68- Lazy load routes and heavy components: `React.lazy()` or dynamic imports
69 
70### PERF-03: Rendering
71 
72- Avoid layout thrashing: don't read then write DOM in loops
73- Use `will-change` sparingly (only for known animations)
74- Prefer CSS animations over JS animations
75- Use `transform` and `opacity` for 60fps animations (compositor-only)
76 
77### PERF-04: Core Web Vitals
78 
79- **LCP** < 2.5s: Optimize largest image/text, preload critical resources
80- **INP** < 200ms: No long tasks on main thread, defer non-critical JS
81- **CLS** < 0.1: Set dimensions on images/embeds, no injected content above fold
82 
83## 3. Responsive Design (RD)
84 
85### RD-01: Mobile First
86 
87- Base styles for mobile, then `@media (min-width)` for larger screens
88- Touch targets minimum 44x44px
89- No horizontal scroll on any viewport
90 
91### RD-02: Fluid Layout
92 
93- Use `rem`/`em` for typography, not `px`
94- Use `clamp()` for fluid typography: `font-size: clamp(1rem, 2.5vw, 2rem)`
95- Flex/Grid over fixed widths
96- Max content width: `max-width: 65ch` for readability
97 
98### RD-03: Breakpoints
99 
100- Don't target devices, target content breakpoints
101- Common: 640px (sm), 768px (md), 1024px (lg), 1280px (xl)
102- Test at 320px, 375px, 768px, 1024px, 1440px, 1920px
103 
104## 4. Component Patterns (CP)
105 
106### CP-01: Forms
107 
108- Show validation errors inline, next to the field
109- Use `type="email"`, `type="tel"`, `inputmode="numeric"` for mobile keyboards
110- Disable submit button during submission (prevent double-submit)
111- Preserve form state on error (don't clear fields)
112 
113### CP-02: Loading States
114 
115- Show skeleton screens over spinners for content areas
116- Indicate progress for long operations (progress bar > spinner)
117- Disable interactive elements during loading
118- Set `aria-busy="true"` on loading containers
119 
120### CP-03: Error States
121 
122- Always show actionable error messages ("Try again" button, not just "Error")
123- Don't show technical errors to users (log internally, show friendly message)
124- Error boundaries for React component trees
125- Retry logic for network failures
126 
127### CP-04: Empty States
128 
129- Never show blank pages — provide helpful empty states
130- Include call-to-action: "No items yet. Create your first item."
131- Use illustrations sparingly (they add bundle weight)
132 
133### CP-05: Modals & Dialogs
134 
135- Use `<dialog>` element or proper `role="dialog"`
136- Trap focus within modal
137- Close on Escape key and backdrop click
138- Return focus to trigger element on close
139- Prevent body scroll while open
140 
141## 5. CSS Practices (CSS)
142 
143### CSS-01: Specificity
144 
145- Prefer class selectors over ID or element selectors
146- Avoid `!important` (use specificity or cascade layers)
147- Use CSS custom properties for theming
148- One direction for spacing: prefer `margin-bottom` over `margin-top`
149 
150### CSS-02: Layout
151 
152- Use Flexbox for 1D layout, Grid for 2D layout
153- Avoid `position: absolute` for layout (use for overlays only)
154- Use `gap` over margins between flex/grid children
155- Use `min-height: 100dvh` (not `100vh`) for full-height layouts
156 
157### CSS-03: Dark Mode
158 
159- Use `prefers-color-scheme` media query
160- Define all colors as CSS custom properties
161- Test both modes — check contrast in both
162- Don't just invert colors — design intentionally for dark mode
163 
164## 6. Security (SEC)
165 
166### SEC-01: Content Security
167 
168- Never use `dangerouslySetInnerHTML` without sanitization
169- Sanitize user-generated content before rendering
170- Use `rel="noopener noreferrer"` on external links with `target="_blank"`
171 
172### SEC-02: Forms & Input
173 
174- CSRF protection on all forms
175- Rate limit form submissions
176- Validate on both client AND server
177 
178## 7. Internationalization (I18N)
179 
180### I18N-01: Text
181 
182- Don't hardcode strings — use i18n library or constants
183- Support RTL layouts: use `logical properties` (`margin-inline-start` over `margin-left`)
184- Don't truncate text — designs must accommodate 40% text expansion
185- Use `lang` attribute on `<html>` tag
186 
187## Review Checklist
188 
189When auditing a file, check in this order (CRITICAL first):
190 
1911. **CRITICAL**: A11Y-01, A11Y-02, SEC-01 — Semantic HTML, ARIA, XSS prevention
1922. **HIGH**: PERF-04, A11Y-03, CP-01 — Core Web Vitals, keyboard, forms
1933. **MEDIUM**: RD-01, CSS-02, CP-02, CP-03 — Responsive, layout, loading/errors
1944. **LOW**: CSS-03, I18N-01, CP-04 — Dark mode, i18n, empty states
195 

Discussion

Alternatives

ImpeccableUse when the user wants to design, redesign, shape, critique, audit, polish, clarify, distill, harden, optimize, adapt, animate, colorize, extract, or otherwise improve a frontend interface. Covers websites, landing pages, dashboards, product UI, app shells, components, forms, settings, onboarding, and empty states. Handles UX review, visual hierarchy, information architecture, cognitive load, accessibility, performance, responsive behavior, theming, anti-patterns, typography, fonts, spacing, layout, alignment, color, motion, micro-interactions, UX copy, error states, edge cases, i18n, and reusable design systems or tokens. Also use for bland designs that need to become bolder or more delightful, loud designs that should become quieter, live browser iteration on UI elements, or ambitious visual effects that should feel technically extraordinary. Not for backend-only or non-UI tasks.Design & UI · Apache-2.0Apple designApple's approach to interface design and fluid, physical motion, translated for the web. Use when building or reviewing gesture-driven UI, spring animations, drag/swipe/sheet interactions, momentum and interruptible transitions, translucent materials and depth, typography (optical sizing, tracking, leading), reduced-motion, or the design foundations (feedback, spatial consistency, restraint) behind Apple-style interfaces.Design & UI · MITBuilding AnimationsBuild an animation from scratch, making the decisions in the order that determines whether it feels right — should it animate at all, what purpose, which tool, which properties, which curve and duration, how it interrupts, how it exits. Writes the implementation. Use when asked to animate something, add motion, make a component feel alive, or build a transition. For critiquing existing motion use review-animations; for auditing a whole codebase use improve-animations.Design & UI · MITBreakRenders a component you choose in every state and scenario on a temporary page and stress tests it.Design & UI · MIT