agentleFS
extra-orgextra-org/extra/.claude/skills/vercel-react-best-practices/SKILL.md

vercel-react-best-practices

Skill119 starsChanged 5 months agoMITView on GitHub

Apply Vercel React performance guidance when implementing, reviewing, or optimizing the React chat widget, including data fetching, rendering, effects, and bundle size.

176 other projects use a version of this, 1 of them edited.

Adopted by

Most recently taken up by

Used with

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

    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 5 projects that use this

  • betacatslingSkill

    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 5 projects that use this

  • VercelSkill

    next-upgrade

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

    Also in 12 projects that use this

  • SentrySkill

    vercel-composition-patterns

    Also in 124 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 5 projects that use this

  • VercelSkill

    next-cache-components

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

    Also in 17 projects that use this

  • +3 more from vercel-labs

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 5 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 172 edited versions we read keep these.

  • 5

    Distinctive

    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
  1. Very specific:

    Do not edit this file directly.

    line 10
  2. Distinctive:

    All paths in this playbook are relative to the repository root, including when reading a generated Codex or Claude adapter.

    line 23
  3. Distinctive:

    Keep request-specific identity and credentials out of shared caches.

    line 61
  4. Distinctive:

    Treat upstream examples as guidance.

    line 62
  5. Distinctive:

    Read the relevant local rule files and existing widget implementation.

    line 68
  6. Very specific:

    Run npm run typecheck:widget and npm run test:widget for widget changes.

    line 70
  7. Very specific:

    Run npm run test:widget:e2e when changing browser interactions such as scrolling, focus, streaming, cancellation, or approvals.

    line 71
  8. Distinctive:

    Use the AGENTS.md report format.

    line 93

“Common” is measured: kept by at least 6 in 10 of the 172 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
<!-- This file is generated by tools/skills. Do not edit this file directly. Edit .ai/skills/vercel-react-best-practices.md and run `make generate-ai`. -->

Skill: Vercel React Best Practices

Purpose

Apply Vercel's performance guidance to Extra's React chat widget. The 70 upstream rules and examples are available locally under .ai/references/vercel-react-best-practices/rules/; read the rules relevant to the change rather than loading the entire collection.

All paths in this playbook are relative to the repository root, including when reading a generated Codex or Claude adapter.

When to Use This Skill

  • Implementing or reviewing components under src/agent_manager/api/static/widget/react/.
  • Changing widget effects, event listeners, state, or data fetching.
  • Investigating slow rendering, unnecessary requests, or bundle growth.

Files to Read First

  • AGENTS.md and .ai/skills/project-architecture.md.
  • docs/WIDGET_ARCHITECTURE.md and docs/WIDGET.md.
  • package.json, the components being changed, and their existing tests.
  • Relevant rules from the local reference directory, using this routing table:
ConcernRule prefixStarting point
Sequential independent requestsasync-async-parallel.md
Unnecessary module loadingbundle-bundle-conditional.md
Duplicate browser subscriptionsclient-client-event-listeners.md
Stale state or unnecessary rendersrerender-rerender-functional-setstate.md, rerender-dependencies.md
Expensive renderingrendering-rendering-hoist-jsx.md, rendering-content-visibility.md
Repeated JavaScript workjs-js-set-map-lookups.md, js-combine-iterations.md
Callback and initialization patternsadvanced-advanced-event-handler-refs.md
Server rendering, if introduced separatelyserver-server-no-shared-module-state.md

Core Principles

  • The shipped widget is React inside a custom element and Shadow DOM, bundled with esbuild. Select rules that fit that environment; Next.js routing, RSC, SSR caching, and next/dynamic examples do not justify adding Next.js.
  • Prioritize observable request waterfalls, bundle growth, and rendering costs over speculative micro-optimizations. Match APIs to the installed React version and esbuild browser target in package.json.
  • Preserve custom-element attributes/events, Shadow DOM styling, stream ownership, cancellation, and approval behavior while optimizing components.
  • Keep request-specific identity and credentials out of shared caches.
  • Treat upstream examples as guidance. Add dependencies or abstractions only when the concrete change benefits from them.

Process

  1. Identify the affected interaction and its performance or correctness issue.
  2. Read the relevant local rule files and existing widget implementation.
  3. Make a focused change that preserves the widget's public behavior.
  4. Run npm run typecheck:widget and npm run test:widget for widget changes. Run npm run test:widget:e2e when changing browser interactions such as scrolling, focus, streaming, cancellation, or approvals.
  5. Rebuild changed widget sources with npm run build:widget, include the generated src/agent_manager/api/static/widget.js, and run make check.

Checklist Before Finishing

  • Applied rules match Extra's React/custom-element architecture.
  • The change fixes an observed problem or has a clear performance rationale.
  • Effect cleanup, callback state, and active stream behavior remain correct.
  • Relevant widget checks pass and the bundle is rebuilt when sources change.
  • make check passes.

Common Mistakes to Avoid

  • Applying Next.js-specific examples directly to this browser-only widget.
  • Adding blanket memoization or caching without identifying the expensive work.
  • Optimizing rendering by removing lifecycle, ownership, or approval checks.
  • Editing the built bundle directly or changing generated skill adapters by hand.

Expected Final Report

Use the AGENTS.md report format. State the affected interaction, relevant rules, why the change helps, checks run, and any remaining performance limits.

Upstream Source

Adapted from Vercel React Best Practices, by Vercel Engineering, version 1.0.0, at commit 063bee94c3f4df8453406c830b0a7df0f2860278. Upstream declares the MIT license in its SKILL.md. The 70 local rule files are copies from that revision; the entrypoint above supplies Extra's project context and commands.

Eleven rules carry local correctness and security corrections from review: rendering-usetransition-loading (stale responses are ignored, since a transition does not cancel requests), js-cache-function-results (pure, bounded caches only), bundle-conditional and bundle-preload (a typeof window guard does not affect bundling), server-cache-lru (unambiguous scope-complete keys, and authorization before any cached value is returned), rendering-hydration-no-flicker (the class change is still a hydration mismatch), async-api-routes (handled early starts and an authentication exit), advanced-event-handler-refs and advanced-use-latest (Effect Events are not stable), js-cache-storage (cookie caches are reset, and cookie changes raise no event), and server-after-nonblocking (work in after() is awaited, and session cookies are not logged). Trailing whitespace was also removed from the copied rules. Reapply these changes when updating from upstream.

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.