build-react-component
Skill9 starsChanged 5 months agoApache-2.0View on GitHub
Scaffolds production-grade React/Next.js components with proper props typing, server vs client component boundaries, and composition; used when building or restructuring UI components.
- Reads credentials
1 other project uses a version of this.
Adopted by
Most recently taken up by
- shawn-dumas/claude-code-skillstheir own version, first seen Mar 24, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- shawn-dumas/claude-code-skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository147 other files it gives its agents.
- second-brain/AGENTS.mdAGENTS.md
- second-brain/CLAUDE.mdCLAUDE.md
- agent-tool-mcp-builderSkill
- api-design-reviewSkill
- async-concurrency-correctnessSkill
- audit-accessibility-wcagSkill
- audit-license-complianceSkill
- audit-technical-seoSkill
- auth-jwt-sessionSkill
- author-codemodSkill
- brainstorm-designSkill
- build-audit-loggingSkill
- build-cdc-streaming-pipelineSkill
- build-cli-toolSkill
- build-data-tableSkill
- build-etl-pipelineSkill
- build-form-validationSkill
- build-native-mobile-uiSkill
- build-office-docsSkill
- build-offline-first-syncSkill
- build-realtime-channelSkill
- build-spreadsheetSkill
- build-vector-searchSkill
- caching-strategySkill
- cicd-pipeline-authorSkill
- cloud-cost-optimizeSkill
- code-commentsSkill
- code-reviewSkill
- compose-local-dev-stackSkill
- configure-bundler-buildSkill
- configure-dns-tlsSkill
- configure-reverse-proxy-lbSkill
- configure-security-headers-cspSkill
- contract-testingSkill
- datetime-timezone-correctnessSkill
- db-migration-safetySkill
- debug-ci-pipeline-failureSkill
- debug-flaky-testsSkill
- debug-frontend-browserSkill
- debug-root-causeSkill
- defend-llm-prompt-injectionSkill
- deliver-webhooksSkill
- dependency-upgradeSkill
- deploy-releaseSkill
- design-api-paginationSkill
- design-authorization-modelSkill
- design-backup-dr-recoverySkill
- design-event-sourcing-cqrsSkill
- design-multi-tenancySkill
- design-protobuf-grpc-serviceSkill
- design-relational-schemaSkill
- design-search-index-infraSkill
- design-state-machineSkill
- design-token-systemSkill
- diff-table-paritySkill
- distributed-locks-leasesSkill
- dockerfile-optimizeSkill
- encrypt-sensitive-dataSkill
- error-messageSkill
- estimate-workSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 58
Add loading.tsx/error.tsx only when the route does async work or can fail.
- Very specific: line 60
Compose, don't configure: Prefer children and slot props over a pile of booleans.
- Very specific: line 80
Use useOptimistic to reflect the change in UI before the action resolves.
- Distinctive: line 91
Don't reach for global state (Zustand/Redux) for what is local UI coordination.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
When to Use
Use this skill when creating, scaffolding, or restructuring a React/Next.js component, page, or layout. It is most valuable when you must decide Server vs Client Component boundaries, design a typed props contract, or lay out files. Skip it for trivial edits to an existing component (text/className tweaks, prop renames) — just edit directly.
Assumes Next.js App Router + React 19 + TypeScript. For pages/ router or React ≤18, drop the App Router steps and the useActionState/server-action patterns.
Steps
- Default to a Server Component. Add
'use client'only when the component actually needs the browser. A file is client-only if it uses any of:useState/useReducer,useEffect/useLayoutEffect, event handlers (onClick,onChange, …), refs to DOM nodes, browser APIs (window,localStorage,IntersectionObserver), or a third-party lib that calls these. None of those → leave it a Server Component (no directive).'use client'is a boundary, not a per-file tag: it marks the entry point; every child imported into it becomes client too. So push it down the tree to the smallest interactive leaf. - Keep the boundary thin: pass Server Components into Client Components as
children/props, don't import them. A Client Component can render Server Component output if it arrives via props/children — it just can'timportone. Pattern:
This keeps the data-fetching + heavy markup on the server while the interactive wrapper stays small.// page.tsx (server) — fetches data, composes <ClientShell><ServerHeavyList /></ClientShell> - Write the props contract first, as a named
interface, with defaults.
Rules: nointerface CardProps { title: string; description?: string; variant?: 'default' | 'outline'; // union, not string children?: React.ReactNode; } export function Card({ title, description, variant = 'default', children }: CardProps) { … }React.FC(breaks generics, implies legacychildren). Use string-literal unions overstringfor variants. Default values in the destructure, notdefaultProps. Extend native props when wrapping an element:interface ButtonProps extends React.ComponentProps<'button'> { variant?: … }then spread{...rest}onto the element so consumers keeparia-*,type,onClick, etc. - Fetch data in the Server Component with
async/await— nouseEffectfetching.export default async function Page() { const data = await getData(); // runs on server, no client JS shipped return <View data={data} />; }fetchis auto-deduped/cached per request. Set freshness with{ next: { revalidate: 60 } }orcache: 'no-store'. Never lift this into a Client Component — that ships the fetch + waterfalls it. - Colocate files; reach for App Router special files when the route needs them.
Addcomponents/card/ card.tsx # component card.test.tsx # test card.module.css # styles (or Tailwind inline) app/dashboard/ page.tsx # route UI layout.tsx # shared shell (persists across child routes) loading.tsx # Suspense fallback — auto-wraps page error.tsx # 'use client' error boundary (gets error + reset) not-found.tsxloading.tsx/error.tsxonly when the route does async work or can fail. Barrelindex.tsfiles only at package/public boundaries — not inside feature folders (they bloat bundles and create import cycles). - Compose, don't configure. Prefer
childrenand slot props over a pile of booleans. When a component has tightly-coupled parts, use the compound pattern instead oftabs={[…]}config:
Shared state goes through a Context created inside the parent (see step 8). This beats prop explosions and lets consumers control layout.<Tabs defaultValue="a"> <Tabs.List><Tabs.Trigger value="a">A</Tabs.Trigger></Tabs.List> <Tabs.Panel value="a">…</Tabs.Panel> </Tabs> - For forms/mutations use Server Actions + React 19 hooks, not manual fetch + useState.
// actions.ts 'use server'; export async function save(prev, formData: FormData) { …; return { ok: true }; }
Use'use client'; const [state, action, pending] = useActionState(save, null); return <form action={action}><button disabled={pending}>Save</button></form>;useOptimisticto reflect the change in UI before the action resolves; useuseFormStatus()inside a child to read pending state without prop-passing. - Kill prop drilling by lifting state or scoping a Context — not by threading props 3+ levels. If two siblings need the same state, lift it to their nearest common parent. If many descendants need it, create a typed Context co-located with the feature (provider in the parent, a
useX()hook that throws if used outside the provider):
Don't reach for global state (Zustand/Redux) for what is local UI coordination.const Ctx = React.createContext<T | null>(null); export function useTabs() { const c = React.useContext(Ctx); if (!c) throw new Error('useTabs must be used within <Tabs>'); return c; } - Apply the accessibility baseline, then hand deep a11y to the a11y skill. Use the semantic element (
<button>for actions,<a>/<Link>for navigation,<nav>/<main>/<ul>), associate every input with a<label htmlFor>, give icon-only controls anaria-label, and don't trap keyboard users. Anything beyond this baseline (focus management, ARIA widget roles, live regions) → defer to the dedicated accessibility skill.
Common Errors
useState/event handler in a Server Component → build error: "You're importing a component that needs useState… add 'use client'." Fix: add the directive to that leaf, or move just the interactive bit into a small client child. Don't slap'use client'on the whole page.- Importing a Server Component into a Client Component → it silently becomes a client component (loses server-only access to DB/secrets/
async). Fix: pass it aschildren/prop from a server parent (step 2). - Passing a non-serializable prop (function, Date, class instance) across the server→client boundary → "Only plain objects can be passed to Client Components." Event handlers/functions can't cross it. Fix: serialize, or move the handler into the client side.
React.FC<Props>→ swallows generics and implies an optionalchildrenyou may not want. Use a plain function with a typed param.- Fetching in
useEffectfor first paint → request waterfall + spinner + larger bundle. Fix:awaitit in the Server Component (step 4). asyncClient Component ('use client'+async function) → not supported; only Server Components can be async. Fetch on the server or use a data hook /use().- Reading
process.env.SECRETin client code → it'sundefinedin the browser (onlyNEXT_PUBLIC_*is exposed) and leaks if it weren't. Keep secrets in Server Components/actions. - Barrel
index.tsre-exporting a whole feature folder → defeats tree-shaking, drags client code into server bundles, and risks circular imports. Import from the specific file. error.tsxwithout'use client'→ error boundaries must be Client Components; it won't catch otherwise.- Mutating data then expecting the UI to refresh → call
revalidatePath/revalidateTagin the server action; client state won't update on its own.
Verify
npx tsc --noEmitpasses — props contract is sound, noanyleaking in.next build(ornext devwith no console errors) — confirms no Server/Client boundary violation or serialization error.- Every
'use client'sits on the smallest interactive component; server data-fetching stays server-side (grep the tree: a'use client'file should not containawait fetch/DB calls). - Props use named unions + extend native element props where wrapping; no
React.FC; nodefaultProps. - Interactive controls are real semantic elements with labels/
aria-label; tab order works. - No prop drilled past 2 levels without a lift or Context; no global store for purely local UI state.
- Tests/lint run green if the repo has them (
npm test,npm run lint).
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
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.

