agentleFS
FranRomFranRom/pupila/.agents/skills/react-best-practices/SKILL.md

vercel-react-best-practices

Skill37 starsChanged 7 months agoMITView on GitHub

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

177 other projects use a version of this, 173 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use dep-refs, feature-boundary-planner and 9 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.
  • axiom-desuSkill

    dep-refs

    Use when needs to inspect TypeScript export references in the z-code workspace, list exports from a file, verify whether an export is unused before deletion, investigate who imports a symbol during refactors, or combine pnpm knip unused-export results with pnpm dep:refs symbol-level reference tracing.

    Also in 6 projects that use this

  • axiom-desuSkill

    feature-boundary-planner

    Map a ZCode behavior change to current UI surfaces, state owners, protocol commands, persistence, and validation. Use for impact analysis, product-boundary planning, or an implementation handoff grounded in the checked-out source.

    Also in 6 projects that use this

  • VercelSkill

    next-upgrade

    Upgrade Next.js to the latest version following official migration guides and codemods

    Also in 13 projects that use this

  • VercelSkill

    next-cache-components

    Next.js 16 Cache Components - PPR, use cache directive, cacheLife, cacheTag, updateTag

    Also in 18 projects that use this

  • Cartograf666Skill

    architecture-governance

    Bootstrap, document, enforce, and review a project's architecture through layer responsibilities, dependency direction, architecture manifests, legacy baselines, Change Envelopes, cross-layer approval policy, and deterministic architecture checks. Use when starting a project, auditing an existing codebase, planning cross-layer work, preventing architecture erosion, reviewing structural changes, or deciding whether implementation may expand into another layer.

    Also in 6 projects that use this

  • SentrySkill

    next-best-practices

    Next.js best practices - file conventions, RSC boundaries, data patterns, async APIs, metadata, error handling, route handlers, image/font optimization, bundling

    Also in 38 projects that use this

  • +3 more from vercel-labs

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 174 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read rule files for details + examples:

    line 134

“Common” is measured: kept by at least 6 in 10 of the 174 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

Vercel React Best Practices

Perf optimization guide for React/Next.js, by Vercel. 70 rules across 8 categories, prioritized by impact.

When to Apply

Reference when:

  • Writing new React components / Next.js pages
  • Implementing data fetching (client or server)
  • Reviewing code for perf issues
  • Refactoring React/Next.js code
  • Optimizing bundle size / load times

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Eliminating WaterfallsCRITICALasync-
2Bundle Size OptimizationCRITICALbundle-
3Server-Side PerformanceHIGHserver-
4Client-Side Data FetchingMEDIUM-HIGHclient-
5Re-render OptimizationMEDIUMrerender-
6Rendering PerformanceMEDIUMrendering-
7JavaScript PerformanceLOW-MEDIUMjs-
8Advanced PatternsLOWadvanced-

Quick Reference

1. Eliminating Waterfalls (CRITICAL)

  • async-cheap-condition-before-await - Check cheap sync conditions before awaiting flags/remote values
  • async-defer-await - Move await into branches where used
  • async-parallel - Promise.all() for independent ops
  • async-dependencies - better-all for partial deps
  • async-api-routes - Start promises early, await late in API routes
  • async-suspense-boundaries - Suspense to stream content

2. Bundle Size Optimization (CRITICAL)

  • bundle-barrel-imports - Import directly, avoid barrel files
  • bundle-analyzable-paths - Statically analyzable import/FS paths — avoid broad bundles/traces
  • bundle-dynamic-imports - next/dynamic for heavy components
  • bundle-defer-third-party - Load analytics/logging post-hydration
  • bundle-conditional - Load modules only when feature activates
  • bundle-preload - Preload on hover/focus for perceived speed

3. Server-Side Performance (HIGH)

  • server-auth-actions - Authenticate server actions like API routes
  • server-cache-react - React.cache() for per-request dedup
  • server-cache-lru - LRU cache for cross-request caching
  • server-dedup-props - Avoid duplicate serialization in RSC props
  • server-hoist-static-io - Hoist static I/O (fonts, logos) to module level
  • server-no-shared-module-state - Avoid module-level mutable request state in RSC/SSR
  • server-serialization - Minimize data to client components
  • server-parallel-fetching - Restructure components to parallelize fetches
  • server-parallel-nested-fetching - Chain nested fetches per item in Promise.all
  • server-after-nonblocking - after() for non-blocking ops

4. Client-Side Data Fetching (MEDIUM-HIGH)

  • client-swr-dedup - SWR for auto request dedup
  • client-event-listeners - Dedup global event listeners
  • client-passive-event-listeners - Passive listeners for scroll
  • client-localstorage-schema - Version + minimize localStorage data

5. Re-render Optimization (MEDIUM)

  • rerender-defer-reads - Don't subscribe to state only used in callbacks
  • rerender-memo - Extract expensive work into memoized components
  • rerender-memo-with-default-value - Hoist default non-primitive props
  • rerender-dependencies - Primitive deps in effects
  • rerender-derived-state - Subscribe to derived booleans, not raw values
  • rerender-derived-state-no-effect - Derive state during render, not in effects
  • rerender-functional-setstate - Functional setState for stable callbacks
  • rerender-lazy-state-init - Pass function to useState for expensive values
  • rerender-simple-expression-in-memo - No memo for simple primitives
  • rerender-split-combined-hooks - Split hooks with independent deps
  • rerender-move-effect-to-event - Interaction logic in event handlers
  • rerender-transitions - startTransition for non-urgent updates
  • rerender-use-deferred-value - Defer expensive renders to keep input responsive
  • rerender-use-ref-transient-values - Refs for transient frequent values
  • rerender-no-inline-components - No components inside components

6. Rendering Performance (MEDIUM)

  • rendering-animate-svg-wrapper - Animate div wrapper, not SVG element
  • rendering-content-visibility - content-visibility for long lists
  • rendering-hoist-jsx - Extract static JSX outside components
  • rendering-svg-precision - Reduce SVG coord precision
  • rendering-hydration-no-flicker - Inline script for client-only data
  • rendering-hydration-suppress-warning - Suppress expected mismatches
  • rendering-activity - Activity component for show/hide
  • rendering-conditional-render - Ternary, not &&, for conditionals
  • rendering-usetransition-loading - Prefer useTransition for loading state
  • rendering-resource-hints - React DOM resource hints for preload
  • rendering-script-defer-async - defer or async on script tags

7. JavaScript Performance (LOW-MEDIUM)

  • js-batch-dom-css - Group CSS changes via classes or cssText
  • js-index-maps - Build Map for repeated lookups
  • js-cache-property-access - Cache object props in loops
  • js-cache-function-results - Cache function results in module-level Map
  • js-cache-storage - Cache localStorage/sessionStorage reads
  • js-combine-iterations - Combine multiple filter/map into one loop
  • js-length-check-first - Check array length before expensive comparison
  • js-early-exit - Return early
  • js-hoist-regexp - Hoist RegExp creation outside loops
  • js-min-max-loop - Loop for min/max instead of sort
  • js-set-map-lookups - Set/Map for O(1) lookups
  • js-tosorted-immutable - toSorted() for immutability
  • js-flatmap-filter - flatMap to map + filter in one pass
  • js-request-idle-callback - Defer non-critical work to browser idle

8. Advanced Patterns (LOW)

  • advanced-effect-event-deps - Don't put useEffectEvent results in effect deps
  • advanced-event-handler-refs - Store event handlers in refs
  • advanced-init-once - Init app once per app load
  • advanced-use-latest - useLatest for stable callback refs

How to Use

Read rule files for details + examples:

rules/async-parallel.md
rules/bundle-barrel-imports.md

Each rule contains:

  • Why it matters
  • Incorrect example + explanation
  • Correct example + explanation
  • Context + refs

Full Compiled Document

Complete guide with all rules: AGENTS.md

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.