agentleFS
Aarvion-AIAarvion-AI/stackwise-skills/skills/react-expert/SKILL.md

react-expert

Skill5 starsChanged 3 months agoMITView on GitHub

Use when working in a React 19 / Next.js 15 codebase - .tsx/.jsx files, next.config.ts, app/ router directories, "use client"/"use server" directives, package.json with react or next dependencies. Builds and refactors Server/Client Components, server actions and forms, Suspense/streaming UIs, and TanStack Query or Zustand data layers; debugs hydration and boundary errors. Invoke for adding routes or components, wiring mutations with useActionState, choosing state management, fixing "Cannot use hooks in Server Component" class errors, memoization cleanup under React Compiler, and testing RSC apps.

11 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use fullstack-guardian, monitoring-expert and 7 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • JeffallanSkill

    fullstack-guardian

    Builds security-focused full-stack web applications by implementing integrated frontend and backend components with layered security at every level. Covers the complete stack from database to UI, enforcing auth, input validation, output encoding, and parameterized queries across all layers. Use when implementing features across frontend and backend, building REST APIs with corresponding UI, connecting frontend components to backend endpoints, creating end-to-end data flows from database to UI, or implementing CRUD operations with UI forms. Distinct from frontend-only, backend-only, or API-only skills in that it simultaneously addresses all three perspectives—Frontend, Backend, and Security—within a single implementation workflow. Invoke for full-stack feature work, web app development, authenticated API routes with views, microservices, real-time features, monorepo architecture, or technology selection decisions.

    Also in 6 projects that use this

  • JeffallanSkill

    monitoring-expert

    Configures monitoring systems, implements structured logging pipelines, creates Prometheus/Grafana dashboards, defines alerting rules, and instruments distributed tracing. Implements Prometheus/Grafana stacks, conducts load testing, performs application profiling, and plans infrastructure capacity. Use when setting up application monitoring, adding observability to services, debugging production issues with logs/metrics/traces, running load tests with k6 or Artillery, profiling CPU/memory bottlenecks, or forecasting capacity needs.

    Also in 4 projects that use this

  • +7 more from Jeffallan

The file

We split this skill into the rules it gives an agent

9 rules. 0 are common, 2 are distinctive, and 7 are very specific to this project.

  • 0

    Common

    Most of the 11 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Add or modify routes, layouts, and components in a Next.js 15 App Router project

    line 19
  2. Distinctive:

    Add Suspense boundaries and streaming to slow pages.

    line 24
  3. Distinctive:

    Write or fix tests for components, hooks, and server actions in an RSC codebase

    line 25
  4. Very specific:

    Analyze: - Read package.json (confirm React 19 / Next 15, check for babel-plugin-react-compiler, @tanstack/react-query, zustand), …

    line 29
  5. Very specific:

    Design the boundary: - Default to Server Components.

    line 30
  6. Very specific:

    Verify types/lint: - run npx tsc --noEmit and npx next lint (or npx eslint .

    line 32
  7. Very specific:

    Test: - run the project's test command (npx vitest run or npx jest).

    line 33
  8. Very specific:

    Prove it works: - run npx next build (catches server/client boundary violations, missing Suspense around useSearchParams, and dynamic API …

    line 34
  9. Very specific:

    Treating server actions as private functions: Every exported "use server" function is a public POST endpoint.

    line 143

“Common” is measured: kept by at least 6 in 10 of the 11 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

React Expert

Turns Claude into a senior React 19 + Next.js 15 App Router engineer who defaults to Server Components, keeps client boundaries minimal, and never ships legacy patterns.

When to Use This Skill

  • Add or modify routes, layouts, and components in a Next.js 15 App Router project
  • Implement mutations with server actions, useActionState, and progressive-enhancement forms
  • Decide where the Server/Client Component boundary goes and fix boundary/hydration errors
  • Wire client-side data fetching with TanStack Query v5 (including SSR hydration)
  • Choose and implement state management (server state vs Zustand vs Context vs URL state)
  • Add Suspense boundaries and streaming to slow pages; fix waterfalls
  • Write or fix tests for components, hooks, and server actions in an RSC codebase

Core Workflow

  1. Analyze - Read package.json (confirm React 19 / Next 15, check for babel-plugin-react-compiler, @tanstack/react-query, zustand), next.config.ts, and the nearest layout.tsx/existing components to learn conventions. Identify whether the code you will touch runs on the server, the client, or both - this decides every pattern below.
  2. Design the boundary - Default to Server Components. Push "use client" to the smallest leaf that needs interactivity; pass Server Component output through as children/props rather than importing server code into client files. Fetch data on the server where possible; mutations go through server actions.
  3. Implement - TypeScript only, function components only, current APIs only: use() for promises/context in render, useActionState for action state, ref as a normal prop (no forwardRef), no manual useMemo/useCallback/memo when React Compiler is enabled. Load the matching reference file (table below) before writing unfamiliar patterns.
  4. Verify types/lint - run npx tsc --noEmit and npx next lint (or npx eslint . if the project migrated to the ESLint CLI); fix all reported issues and re-run until clean before proceeding.
  5. Test - run the project's test command (npx vitest run or npx jest); write or update tests for the change following references/testing.md; fix all failures and re-run until clean.
  6. Prove it works - run npx next build (catches server/client boundary violations, missing Suspense around useSearchParams, and dynamic API misuse that dev mode tolerates); fix all reported issues and re-run until clean. For behavior changes, start npx next dev and exercise the route.

Reference Guide

Load detailed guidance only when the task needs it:

TopicReferenceLoad When
Server vs Client Components, composition, async APIs, cachingreferences/server-components.mdCreating/moving components, "use client" decisions, boundary or hydration errors, params/cookies usage
TanStack Query v5, Zustand vs Context, use() hookreferences/state-and-data-fetching.mdClient-side fetching, choosing state management, migrating Query v4→v5, sharing state across components
Server actions, useActionState, useOptimistic, validationreferences/forms-and-actions.mdBuilding forms, mutations, "use server" files, optimistic UI, revalidation after writes
React Compiler, memoization, Suspense/streaming, bundle sizereferences/performance.mdPerf work, deciding whether to memoize, adding loading.tsx/Suspense, fixing waterfalls or large bundles
Testing Library 16 with RSC, async components, action testingreferences/testing.mdWriting/fixing tests, testing async Server Components, mocking server actions or next/navigation

Key Patterns

Server Component page fetching data, client leaf for interactivity:

// app/products/[id]/page.tsx - Server Component (no directive)
import { AddToCart } from "./add-to-cart";

export default async function ProductPage({
  params,
}: {
  params: Promise<{ id: string }>; // params is a Promise in Next 15
}) {
  const { id } = await params;
  const product = await getProduct(id); // direct server fetch, no API route
  return (
    <article>
      <h1>{product.name}</h1>
      <AddToCart productId={product.id} /> {/* only this ships JS */}
    </article>
  );
}

Server action + useActionState (React 19 form pattern):

// app/products/actions.ts
"use server";
import { revalidatePath } from "next/cache";

export async function addToCart(prev: { error?: string }, formData: FormData) {
  const parsed = cartSchema.safeParse(Object.fromEntries(formData));
  if (!parsed.success) return { error: "Invalid quantity" };
  await db.cart.add(parsed.data); // re-check auth here: actions are public endpoints
  revalidatePath("/cart");
  return {};
}

// add-to-cart.tsx
"use client";
import { useActionState } from "react"; // from react, NOT react-dom
import { addToCart } from "./actions";

export function AddToCart({ productId }: { productId: string }) {
  const [state, formAction, isPending] = useActionState(addToCart, {});
  return (
    <form action={formAction}>
      <input type="hidden" name="productId" value={productId} />
      <input name="quantity" type="number" defaultValue={1} />
      <button disabled={isPending}>{isPending ? "Adding…" : "Add to cart"}</button>
      {state.error && <p role="alert">{state.error}</p>}
    </form>
  );
}

use() to unwrap a server-started promise in a client component (no awaited waterfall):

// page.tsx (server): start the fetch, don't await it
export default function Page() {
  const reviewsPromise = getReviews(); // NOT awaited
  return (
    <Suspense fallback={<ReviewsSkeleton />}>
      <Reviews reviewsPromise={reviewsPromise} />
    </Suspense>
  );
}

// reviews.tsx
"use client";
import { use } from "react";

export function Reviews({ reviewsPromise }: { reviewsPromise: Promise<Review[]> }) {
  const reviews = use(reviewsPromise); // suspends until resolved
  return <ul>{reviews.map((r) => <li key={r.id}>{r.body}</li>)}</ul>;
}

Ref as a prop - forwardRef is legacy in React 19:

function TextInput({ ref, ...props }: React.ComponentProps<"input">) {
  return <input ref={ref} {...props} />;
}

Common Mistakes

  • Marking whole pages "use client" to use one hook. The directive marks a boundary, not a single file's needs - everything it imports becomes client code. Extract the interactive part into a leaf component instead, and pass server-rendered content through children.
  • Awaiting params/searchParams/cookies()/headers() incorrectly in Next 15. These are now async (params: Promise<...>). Synchronous access is a deprecation error; type them as promises and await them (or use() them in client components).
  • Assuming fetch is cached by default. Next 15 reversed this: fetch is uncached and route handlers/client navigations are dynamic unless you opt in with cache: "force-cache", revalidate, or "use cache". Don't add cache-busting hacks; add explicit caching.
  • Sprinkling useMemo/useCallback/memo when React Compiler is enabled. The compiler memoizes automatically; manual wrappers are dead weight and can defeat compiler analysis. Only keep them for genuinely expensive computations the compiler cannot prove, and verify with the React DevTools "Memo ✨" badge.
  • Using TanStack Query v4 idioms in v5. isLoading (initial) is now isPending; callbacks (onSuccess/onError) were removed from useQuery; only the object signature useQuery({ queryKey, queryFn }) exists; cacheTime is gcTime. Handle side effects in useEffect on the returned data or in mutation callbacks.
  • Treating server actions as private functions. Every exported "use server" function is a public POST endpoint. Validate input with a schema and re-check authentication/authorization inside the action, even if the UI already gated it.
  • Testing async Server Components with plain render(). render(<AsyncComp />) throws on a promise-returning component. Await the component first: render(await AsyncComp({ params })), or cover it with Playwright; unit-test the data functions separately.
  • Reaching for Context to share client state. Context re-renders every consumer on any change (React Compiler does not fix this - it cannot memoize past a changed context value). Use Zustand with selectors for shared mutable state; keep Context for dependency-injection-style rarely-changing values (theme, session).

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.