claude/skills/web-frontend/SKILL.md
Neil Bantoc 5201aa9bd5 Add web-frontend, web-project-audit and web-project-scaffold-containerized-python skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 16:26:33 -08:00

128 lines
11 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
name: web-frontend
description: House style and build guidance for any web frontend work, so pages and apps come out with a deliberate, polished look and feel instead of generic AI-generated design. Use whenever writing or restyling frontend code — a landing page, marketing site, web app, dashboard, admin tool, component library, or a single component or page in an existing React/Vue/Svelte/plain-HTML project. Provides a token-based design system (color in OKLCH with light/dark themes, type scale, spacing, radius, motion), font pairings, a default library stack, layout patterns, component recipes, copywriting rules and a pre-ship checklist.
---
# Web Frontend
The aim: frontends that look like a design lead at a small studio made them. That means a specific visual identity grounded in the subject, precise spacing and type, both themes designed, and none of the stock AI-generated looks. The look comes from **process plus a small system**, not a fixed template: the tokens in `assets/tokens.css` are the structure, and each project gets its own hue, fonts and one bold move.
`SKILL_DIR` is the directory holding this file. Reference files, read when the step needs them:
| File | Read when |
|---|---|
| `assets/tokens.css` | Always, before writing styles. Copy it into the project and tune it. |
| `references/libraries.md` | Choosing a stack or adding a dependency. |
| `references/layout.md` | Building page shells, grids, app layouts, dashboards. |
| `references/components.md` | Writing buttons, inputs, cards, tables, nav, toasts, empty states. |
| `references/tailwind.md` | The project uses Tailwind (or you are choosing it). |
## Precedence
1. The user's own words. If they name a look, follow it exactly, even one listed under "Avoid" below.
2. The project's existing design system: a tokens/theme file, Tailwind config, component library, CLAUDE.md. Apply it and fill gaps only. Never re-skin an existing product unasked.
3. This skill.
When the output is a claude.ai Artifact, the `artifact-design` skill's page contract (CSP, skeleton, safe areas) wins over anything here; this skill's taste still applies.
## Process
1. **Read the request and pick a treatment.**
- *Utilitarian* (internal tool, dashboard, admin, docs, settings, a feature inside an app): polished, quiet, dense where useful. No hero. Flourishes kept to near zero.
- *Editorial* (landing page, portfolio, launch page, game, something meant to be shared): an opinionated identity with one real aesthetic risk.
- If unsure, choose utilitarian done well. A well-composed page is always acceptable; an over-designed one sometimes isn't.
2. **Define the subject.** One concrete subject, its audience, and the page's single job. Pull at least one detail only this subject would have (its units, terms of art, document conventions) into the content itself. Use real copy, never lorem ipsum.
3. **Set the tokens.** Copy `assets/tokens.css` and change, at minimum:
- `--hue` (and maybe `--chroma`): the accent's hue, chosen from the subject's world. The neutrals pick up a faint tint of it automatically.
- `--font-display`, `--font-body`, `--font-mono` from the pairing table below.
- A one-line layout-concept comment above `:root` (e.g. `/* Layout: two-pane ledger, filters left, results right */`).
Every color, size and space in the code then comes from a token. No hex literals in components.
4. **Lay out with the patterns** in `references/layout.md`. Get structure right at phone width (~400px) and desktop before adding detail.
5. **Build components** from `references/components.md`, styled only through tokens.
6. **Write the copy** by the rules below.
7. **Run the checklist** at the end of this file. Render it once if you can (dev server plus a screenshot, or Playwright), fix what you see in one pass, and stop.
## The system in brief
Everything below is defined in `assets/tokens.css`.
- **Color:** OKLCH. One accent hue drives `--accent`, `--accent-fg`, `--accent-soft` and a faintly tinted neutral ramp (`--bg`, `--surface`, `--surface-2`, `--border`, `--fg`, `--fg-muted`, `--fg-subtle`). Semantic colors (`--ok`, `--warn`, `--danger`, `--info`) are separate from the accent and never stand in for it.
- **Themes:** light on bare `:root`. Dark redefines the same tokens under `@media (prefers-color-scheme: dark)`, guarded by `:root:not([data-theme="light"])`, and again under `:root[data-theme="dark"]`, so an explicit toggle wins both ways. Dark is designed, not inverted: surfaces get lighter as they rise, the accent gets lighter and a little less saturated, and borders carry more of the separation than shadows do.
- **Type:** a modular scale (ratio 1.2 for UI, 1.25 to 1.333 for editorial) from `--text-xs` to `--text-4xl`. Body copy 16px minimum on the web (15px is fine in dense tools). Measure ~65ch. Headings `text-wrap: balance`, paragraphs `text-wrap: pretty`. Uppercase labels get `letter-spacing: 0.06em`. Digits that line up use `tabular-nums`.
- **Space:** a 4px base, `--space-1` … `--space-16`. Siblings get spacing from `gap` in flex/grid, not margins.
- **Radius:** small and consistent. `--radius-sm` 4px for inputs and chips, `--radius-md` 8px for cards and popovers, `--radius-full` for pills and avatars. Not everything is rounded.
- **Elevation:** three shadows only, used by role: a raised card (rarely), a popover/menu, and a modal.
- **Motion:** 120 to 200ms with `--ease-out` for UI, one orchestrated moment at most on editorial pages, everything wrapped in `prefers-reduced-motion`.
## Font pairings
All on Google Fonts (or self-host with `@fontsource/*`). Always declare a full fallback stack. Pick by the subject's character, not by habit. Avoid the defaults listed under "Avoid".
| Character | Display | Body | Mono / data |
|---|---|---|---|
| Precise, technical, product UI | Geist | Geist | Geist Mono |
| Warm, humane, consumer | Bricolage Grotesque | Figtree | JetBrains Mono |
| Editorial, long-form, cultural | Newsreader | Source Sans 3 | IBM Plex Mono |
| Engineered, industrial, data-heavy | IBM Plex Sans Condensed | IBM Plex Sans | IBM Plex Mono |
| Playful, crafted, games | Fredoka or Gluten (headings only) | Nunito Sans | Martian Mono |
| Luxury, fashion, quiet confidence | Cormorant Garamond | Hanken Grotesk | DM Mono |
| Civic, institutional, trustworthy | Public Sans | Public Sans | Roboto Mono |
Use the display face with restraint: headings and one or two hero moments. For utilitarian work it is fine for display and body to be the same family at different weights.
## Avoid (the stock AI-generated looks)
Unless the user asks for them:
- Warm cream background (#F4F1EA-ish) with serif display and terracotta accent.
- Near-black page with a single acid-green or vermilion pop.
- Purple-to-blue gradient hero on white; gradient text on headlines.
- Inter or Space Grotesk as the unexamined "safe" face.
- Emoji as section icons or bullet markers.
- Everything centered; every block a rounded card with the same shadow; an accent bar down the left of rounded cards.
- `rounded-2xl` + `shadow-lg` on everything; glassmorphism blur panels.
- Numbered `01 / 02 / 03` markers on content that isn't a sequence.
- A `100vh` hero that pushes all real content below the fold.
- Big-number stat tiles as the opener when the numbers aren't the point.
- Fake logos ("Trusted by…") and invented testimonials.
## Principles that make it look deliberate
- **One bold move.** Put the boldness in one place (a type treatment, a color field, an interactive hero, a striking grid) and keep everything around it quiet. If the accent fights the background, desaturate it or shift it to an analogous hue.
- **Hierarchy through type and space first,** then color, and only then borders and shadows. Card styling marks something as a separate object, so use it by role.
- **Consistent repeated elements.** Same padding, baselines and placement across sibling cards, rows and badges. Let content set heights. Pick a column count the items fill evenly.
- **Structure encodes information.** Eyebrows, numbering, dividers and labels must say something true about the content.
- **Complete at rest.** Everything readable is visible on load. Animations start from a visible state, never `opacity: 0` waiting on a scroll observer. Tools open in a realistic working state with sample data clearly marked as examples, not an empty shell.
- **UIs are scanned.** Summary before detail. State shown in form as well as numbers (pill, chip, severity stripe). Interactive things look interactive.
- **Charts to scale,** colored from tokens, labels clear of marks, both themes legible. For anything more than a sparkline, load the `dataviz` skill if available.
## Copy
- Write from the user's side: name things by what people recognize ("Notifications", not "Webhook config").
- Buttons say exactly what happens ("Save changes", "Delete project"), and the confirmation echoes it ("Changes saved").
- Errors say what went wrong and how to fix it. No apologies, no vagueness.
- Short, direct, plain sentences. No em-dash asides, no "not X but Y", no colon-then-reveal, no scare quotes, no stock phrases ("seamless", "unlock", "elevate", "worth noting").
- Sentence case for headings and buttons.
- Page `<title>`: a real name for the page, 2 to 4 words, no "– explainer" tail.
## Accessibility and build hygiene (non-negotiable)
- Semantic HTML first: `button` for actions, `a` for navigation, real `label`s, landmarks (`header`, `nav`, `main`), one `h1`.
- Text contrast at least 4.5:1 (3:1 for large text and UI boundaries) in **both** themes.
- Visible `:focus-visible` ring (`--ring` token) on everything focusable. Never `outline: none` without a replacement.
- Touch targets at least 40px tall on touch layouts.
- `prefers-reduced-motion` respected. No information conveyed by color alone.
- `body` always has an explicit background from a token.
- No horizontal page scroll at 360px. Wide tables, code and diagrams scroll inside their own `overflow-x: auto` container. Flex/grid children holding text or tables get `min-width: 0`.
- Images get `max-width: 100%`, width/height or `aspect-ratio` to avoid layout shift, and real `alt`.
## Pre-ship checklist
- [ ] Every color, size, radius and shadow comes from a token; no stray hex or px literals in components.
- [ ] Light, dark, and explicit `data-theme` toggling all look right; no text is unreadable in either theme.
- [ ] Works at 360px, 768px and 1280px+ with no horizontal scroll.
- [ ] One display face used with restraint, a body face, a mono/data face if needed, all with fallbacks.
- [ ] Nothing from the "Avoid" list crept in by default.
- [ ] Focus states visible, keyboard path works, reduced motion respected.
- [ ] Copy follows the rules above; no placeholder text.
- [ ] Repeated elements share edges, padding and baselines.
- [ ] Empty, loading and error states exist for anything that fetches data.