senior-frontend
You MUST use this whenever you build, change or review user interface code, including small UI tweaks and when the user is in a hurry: pages, components, forms, lists, tables, modals, navigation, layout or styling in React, Next.js, Vue, Svelte, Astro or plain HTML/CSS/Tailwind. Reuse the project's own components and tokens, design every state (loading, empty, error, long content), make it work with a keyboard and a screen reader and at phone width, then open it in a real browser and check it before saying it is done.
- License 许可
- MIT
- 最近更新
- 2026-11-12
- Stars
- ★ 3.3w
- Forks
- 3.9k
01 前言 Front Matter
- name
- senior-frontend
- license
- MIT
- metadata
- { "author": "claude-code-templates", "sources": "Vercel Web Interface Guidelines and agent-skills (MIT), Addy Osmani web-quality-skills (MIT), React docs; see references/", "version": "2.0.0" }
- description
- You MUST use this whenever you build, change or review user interface code, including small UI tweaks and when the user is in a hurry: pages, components, forms, lists, tables, modals, navigation, layout or styling in React, Next.js, Vue, Svelte, Astro or plain HTML/CSS/Tailwind. Reuse the project's own components and tokens, design every state (loading, empty, error, long content), make it work with a keyboard and a screen reader and at phone width, then open it in a real browser and check it before saying it is done.
02 资源文件 5
- 参考文档references/NOTICE.md2.1 KB
- 参考文档references/react-patterns.md4.3 KB
- 参考文档references/ui-checklist.md5.9 KB
- 脚本scripts/check_ui.mjs4.5 KB
- 脚本scripts/page-audit.mjs4.7 KB
03 SKILL.md 正文
Senior Frontend
A senior frontend engineer is not faster at typing JSX. They read the codebase before writing, they think about the states nobody asked for, they use the keyboard to try what they built, and they look at it in a browser before they say it works. This skill is that habit, written down.
Core rule: the UI is not done until you have seen it work in a browser, including the unhappy paths. A passing typecheck says nothing about whether the button can be reached with Tab or whether a long name breaks the layout on a phone.
1. Read the project before you write
Spend the first minutes reading, not writing. Find and use:
- The stack and its versions: framework, router, React version (18 vs 19
changes
forwardRef,use, actions), TypeScript strictness. - The existing components: if the project has a
Button,Input,Dialogor design-system package, use it. Never hand-roll a second button. - The tokens: colors, spacing, radius and type scale already defined (CSS variables, Tailwind theme, theme object). New hex values or magic pixel numbers in a project that has tokens are a bug.
- The data layer: the API helpers, query library (TanStack Query, SWR, server components, loaders) and how errors are already handled.
- The scripts:
typecheck,lint,test,build,dev. You will run them. - A sibling page or component that does something similar. Match its structure and naming.
Ask the user before you add a dependency (UI kit, icon set, state library, date library). The platform and the project usually already have what you need.
2. List the states before you build
Every piece of UI that shows data or takes input has more states than the happy path. Write them down for the feature, then build each one:
| State | What the user must see |
|---|---|
| Loading | A placeholder or "Loading…" with aria-busy or role="status"; no layout jump when data arrives |
| Empty | A sentence that says why it is empty and what to do ("No members match "zz". Clear the search.") |
| Error | What failed, in plain words, and a way out (Retry, or a link). Never a blank area or a console-only error |
| Success / done | Confirmation that the action happened, announced to screen readers |
| Pending action | The control shows progress and is disabled only while the request runs; no double submit |
| Long and odd content | Very long names, emails and words wrap or truncate; 0, 1 and 500 items all look right |
| Partial failure | One row's action failing does not break the rest of the list |
If the API helper can fail (it always can), the UI must handle the rejection. Look for a way the project lets you force failures (a mock flag, a query parameter, a dev toggle) so you can see the error state yourself.
3. Build with the platform first
Semantic HTML gives you keyboard support, focus, and screen-reader names for free. Reach for ARIA only when no element does the job.
<button>for actions,<a href>/ the router'sLinkfor navigation. Never<div onClick>.- Every input has a visible
<label>(or at minimumaria-label), the righttype(email,tel,url,search),nameandautocomplete. - Inputs that submit live inside a
<form>withonSubmit, so Enter works. - Icon-only buttons need an accessible name that says what and which:
aria-label="Remove Ada Lovelace", not"Delete"repeated twelve times. The icon itself getsaria-hidden="true". - One
<h1>per page, headings in order, lists as<ul>/<ol>, tables as<table>with<th scope>. - Async results (saved, removed, failed) go in an
aria-live="polite"region orrole="status"; blocking errors inrole="alert". - Visible focus on everything interactive (
:focus-visible); never remove an outline without a replacement. - Images have
alt(empty for decorative ones) and explicitwidth/height. - Destructive actions need a confirmation or an undo window, never an
immediate irreversible delete. After a removal, move focus somewhere sensible
(the next row or the list heading), not to
<body>.
The full checklist, with forms, motion, typography, i18n and touch rules, is in
references/ui-checklist.md. Use it when reviewing UI code.
4. State and data: keep it boring
- Derive, do not sync. A filtered list is
items.filter(...)during render, not a seconduseStateupdated by an effect. - Effects are for talking to the outside world (fetching, subscriptions, timers), not for reacting to your own state. Event logic goes in the event handler.
- Fetching in an effect needs cleanup: ignore stale responses (an
ignoreflag orAbortController) and handle React 18 Strict Mode's double mount. If the project has a query library or server components, use those instead. - Never define a component inside another component. It remounts on every render and loses state and focus.
- Composition over boolean props. If a component grows
isCompact,showHeader,withFooter, split it into explicit variants or compound components. - Keep URL state in the URL when users expect to share or reload it (search query, tab, page, filters).
- Do not optimize blind. Memoize, virtualize or code-split when a measurement or an obvious size (hundreds of rows, a heavy chart library) calls for it.
Details and examples: references/react-patterns.md.
5. Layout that survives real content
- Design at 375 px wide first, then widen. The page must never scroll horizontally.
- Flex children that hold text need
min-width: 0; long strings needoverflow-wrap: anywhereor a deliberate truncate with the full value available (title, tooltip, detail view). - Touch targets at least 24×24 CSS px (WCAG 2.2), 44 px for primary mobile actions.
- Respect
prefers-reduced-motion; animatetransformandopacity; nevertransition: all.
6. Verify like you mean it
Run, in this order, and read the output:
-
The project's
typecheck,lintandtestscripts, thenbuild. -
Open the page in a real browser. Start the dev or preview server and run the bundled checker against the page you built:
node .claude/skills/senior-frontend/scripts/check_ui.mjs "http://localhost:5173/#/team" --out .ui-checkPoint it only at your own dev or preview server. It loads the page at 375 px and 1280 px, saves screenshots, reports console errors, horizontal overflow, unlabeled controls, images without size or alt, and walks the page with Tab to show the focus order and any stop with no visible focus. It uses Playwright from the project or a global install; if neither exists, say so instead of skipping silently. (Adjust the path if the skill is installed under
~/.claude/skills/.) -
Look at the screenshots. Read them; do not just confirm they exist.
-
Exercise the unhappy paths: force the error state, search for nothing, remove the last item, submit an invalid value, use only the keyboard.
-
Delete the screenshots and output folder when done (or keep them out of git).
If you cannot run a browser in this environment, say exactly what you could not verify. "It builds" is not "it works".
7. Report what you did
End with a short report:
- What you built and which existing components and tokens you reused.
- The states you handled (loading, empty, error, …).
- What you verified and how (commands run, checker output, screenshots looked at), and anything you could not verify.
- Follow-ups you deliberately left out.
Red flags: stop and fix
- You wrote a new
<button>style in a project that has aButtoncomponent. - The error from the API only reaches
console.error. - An icon button has no accessible name, or every row's button has the same one.
- A
<div>or<li>has anonClick. - A
useEffectcopies props or state into other state. - Remove deletes on the first click with no confirm or undo.
- You are about to say "done" and have not opened the page.
References
references/ui-checklist.md: interface review checklist (accessibility, focus, forms, motion, content, images, navigation, touch, theming, i18n, hydration), adapted from Vercel's Web Interface Guidelines (MIT).references/react-patterns.md: state, effects, data fetching, composition and performance rules with short examples, drawing on the React docs and Vercel's agent-skills (MIT).scripts/check_ui.mjs(withscripts/page-audit.mjs): the browser checker used in step 6 (Node 18+).references/NOTICE.md: copyright and license of the adapted sources.
04 同仓库更多 Skills
wealthville-pool-scoring
Score DeFi liquidity pools before providing liquidity. Returns a 0-100 pool score and an Enter/Hold/Exit/Reduce/Avoid verdict with calibrated confidence for ~68,800 Solana pools and 575 EVM pools, plus a public miss-inclusive track record. Use when asked whether a pool is worth LPing into, which pools look best right now, or how accurate the scores have actually been.
technical-debt-auditor
Scans a codebase and produces a quantified technical debt report with a prioritized remediation plan. Analyzes dead code, TODO/FIXME/HACK markers, dependency staleness, complexity hotspots, code duplication signals, test coverage gaps, unused exports, and outdated patterns. Use this skill when the user asks to audit their codebase for tech debt, wants a health check of their code quality, says things like "where should I focus refactoring", "find code smells", "audit my codebase", "what technical debt do we have", "prioritize cleanup work", or asks about code quality metrics. Also trigger when the user mentions "code rot", "legacy cleanup", "refactoring priorities", or wants to understand the overall health of a project before a major effort. Trigger even if the user doesn't say "technical debt" explicitly — any request to systematically assess code quality and identify improvement priorities belongs here.
readonly-sql-guard
Make an agent's database access provably read-only. Use when an agent runs caller-supplied SQL against a production/ERP/analytics database (a "query" MCP tool, text-to-SQL, an admin console), or when reviewing DB-access code for write/DDL/side-effect/transaction-escape risks. Checks what a statement CALLS, not just its shape.
web-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use for complex artifacts requiring state management, routing, or shadcn/ui components - not for simple single-file HTML/JSX artifacts.
webapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
discernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals, or emails, estimates or projections, analysis or interpretation of data, factual claims they may rely on, or a multi-step argument — invoke this skill BEFORE finalizing your reply and then, if it applies, append 2-3 short follow-up questions, each tied to something specific in what you just produced, that help the user check key facts, probe the reasoning or assumptions, and notice missing context. Do this at most once per conversation. Skip it when the user asked a trivial how-to or simple lookup, wants a purely educational explanation, asked you only to format, convert, or assemble a file from content they provided, is writing code they will run, is doing creative writing or casual chat, or already asked you to double-check, cite, or review — the skill file explains these boundaries and the exact output format.