plugin/skills/react-nextjs-patterns/SKILL.md
Use this skill when the agent is implementing frontend code in Next.js projects, reviewing React or Next.js pull requests, onboarding to App Router conventions, or designing a frontend architecture that needs canonical React/Next.js patterns — for canonical React and Next.js conventions covering Next.js App Router routing and rendering, React Server Components vs Client Components boundary, TypeScript strict-mode discipline, Tailwind CSS and shadcn/ui styling, React Query and Server Actions data fetching, Core Web Vitals performance optimization, WCAG 2.2 accessibility, Next.js metadata API and structured data for SEO, unit testing with Vitest and React Testing Library, and end-to-end testing with Playwright.
npx skillsauth add avav25/ai-assets react-nextjs-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Knowledge layer for the frontend-engineer agent and any other agent or skill that needs canonical React and Next.js conventions. Auto-loaded via the skills: frontmatter on frontend-engineer. Read this when authoring, reviewing, or onboarding to Next.js App Router code — it codifies routing, RSC vs Client Component boundaries, TypeScript discipline, styling, data fetching, performance, accessibility, SEO, and testing patterns used across the project.
app/ directory with file-based routing: page.tsx, layout.tsx, loading.tsx, error.tsx, not-found.tsx(group) folders — no URL impact, clean organizationroute.ts for API endpoints (GET, POST, PUT, DELETE, PATCH handlers)[param] for single, [...param] for catch-all, [[...param]] for optional catch-all@slot) and intercepting routes ((.), (..)) for modals and complex layoutsmiddleware.ts at project root for auth guards, redirects, headers, i18nDecision tree — Server Component by default; switch to Client Component only when one of the following is required:
useState, useReducer, or any other React state hookuseEffect or other browser-lifecycle hooksonClick, onChange, etc.)window, document, localStorage, IntersectionObserver)Rendering rules:
'use client' directive at the narrowest boundary — push it down to leaf components, never wrap entire pagesloading.tsx and <Suspense> to progressively render UI. Wrap slow data-dependent sections in Suspense boundaries'use server' for form mutations and data writes. Validate all inputs with Zod. Use revalidatePath() / revalidateTag() after mutationsdynamic = 'force-dynamic' or revalidate only when data must be freshstrict: true, noUncheckedIndexedAccess: true in tsconfig.jsonany — use unknown, strict generics, or explicit typesinterface for object shapes, type for unions and intersectionssatisfies operator for type-safe configuration objectsreact → next → third-party → @/ local → relativeforwardRef when wrapping native elements or building design-system componentschildren, render props, or slots instead of complex prop APIsState management:
useState for simple values, useReducer for complex state logicuseSearchParams, usePathname, useRouter from next/navigation@tanstack/react-query) with useQuery, useMutation, useInfiniteQueryuseActionState for simple formsHooks:
use, single responsibility, return typed valuesuseEffect when subscribing to external resourcesuseMemo/useCallback only when profiling shows a measurable benefit — do not optimize prematurelycn() helper (from clsx + tailwind-merge) for conditional classes. No inline styles.sm:, md:, lg:, xl:, 2xl:)class strategy with next-themes. Design for both light and dark from the starttailwind.config.ts or CSS variablestailwindcss-animate. Use Framer Motion only for complex choreographyfetch() with built-in Next.js caching and revalidation, or direct DB/ORM callsapp/api/**/route.ts — use for webhook endpoints, third-party integrations, client-side API callsQueryClientProvider. Place query hooks in hooks/ directory. Use query key factories: ['entity', params]revalidatePath / revalidateTag to invalidate cacheerror.tsx boundaries. Return structured errors from API routes ({ error: string, code: number })loading.tsx for route-level, <Suspense fallback={...}> for component-levelnext/image priority prop. Preload critical fonts via next/fontnext/dynamic + ssr: falsenext/image with width/height or fillOptimization checklist:
'use client' surface — push it down to leaf componentsnext/dynamic for heavy components not needed on initial renderReact.lazy + Suspense for code splitting within Client Componentsnext/image with responsive sizes, WebP/AVIF formats, placeholder="blur"@next/bundle-analyzer to identify large dependencies<Link> prefetches by default in viewport. Disable with prefetch={false} for low-priority links<main>, <nav>, <section>, <article>, <header>, <footer>, <button>, <a>alt=""<label> with inputs. Use aria-describedby for error messagesgenerateMetadata() in page.tsx and layout.tsx for dynamic metadatasitemap.ts and robots.ts at app rooth1 → h2 → h3, no skipping levels)<script type="application/ld+json">server-only package to prevent server code from leaking to client bundlesroute.ts, Server Actions, middlewaredangerouslySetInnerHTMLnext.config.js or middlewaremiddleware.ts, not in componentsscreen.getByRole over getByTestId. Prefer userEvent over fireEvent| Workflow | Apply this knowledge |
|---|---|
| Agent(frontend-engineer) invocation | Auto-loaded via skills: frontmatter |
| /develop with frontend work package | Spawned frontend-engineer agent loads this |
| /code-review on React/Next.js PRs | Reviewer references these patterns |
| /architecture-design (frontend service) | Architect references rendering boundaries, data flow |
| /seo-review on pages | SEO engineer references metadata + Core Web Vitals sections |
| /bugfix on UI defects | Developer references RSC boundary, hydration, a11y |
frontend-engineer agent (primary), ui-ux-designer (when reviewing implementation), seo-engineer (when auditing pages), qa-engineer (when writing component/E2E tests)context-engineering skill (for AI-feature frontends), owasp-coverage skill (client/server boundary security)development
Use this skill when running the recurring (daily) knowledge-base rescan for a repo that already has knowledge/.knowledge-sync.yml — the main-thread dispatcher that reads the config, computes the git delta since last_scanned_sha, maps changed paths to affected doc areas, early-exits cheaply when nothing changed, then fans out one Agent(content-writer) per affected area, applies the propose/direct update policy, advances the baseline only on success, and writes an L4 run log — all with the G1 untrusted-content choke-point, secret-scan, deny-list, and budget controls woven in. For first-time setup use /knowledge-sync-init.
development
Use this skill when bootstrapping scheduled knowledge-base sync for a repo that has no knowledge/.knowledge-sync.yml yet — to run one-time setup that detects the knowledge_root from CLAUDE.md/AGENTS.md, maps doc areas to source globs, records opt-in external sources (Linear/Notion/WebFetch, all disabled by default), captures a baseline last_scanned_sha, sets the per-area update policy, generates or seeds knowledge/CONVENTIONS.md, provisions the L4 memory dir, and offers to register the daily routine. Routes ongoing recurring sync operations to /knowledge-sync.
tools
Use this skill when bootstrapping a target repository to be ai-skills-aware — on the first run of any ai-skills workflow in a fresh repo, when adopting the ai-skills plugin in an existing repo, or after upgrading to a plugin version that adds new memory paths or templates, including when the user does not say "init" but asks to "set up" or "onboard" the repo — to detect codebase type, create CLAUDE.md + AGENTS.md scaffolding, initialize the .ai-skills-memory/ directory tree from L1 templates, and configure .gitignore. Idempotent — safe to re-run. Accepts `--codebase-type <type>` and `--overwrite`. Not for re-initializing only memory — use `/memory-init` instead.
tools
Use this skill when extending, repairing, or improving plugin assets, when ingesting a `/feedback` report as a fix-cycle backlog, or when you do not remember which lower-level command is right for the job — the umbrella workflow for ai-skills plugin-asset authoring and maintenance: creating, auditing, fixing, improving, refactoring, and migrating skills, agents, rules, hooks, prompts, schemas, and rubrics inside the plugin. Auto-classifies the request, loads the right knowledge skills (`@prompt-engineering`, `@context-engineering`, `@team-protocols`), and spawns the right subagents (`prompt-engineer`, `system-architect`, `python-engineer`, `software-engineer`, `qa-engineer`, `eval-judge`) via the `Agent` tool.