AgentKit
DocsKitsCLI ReferenceDesktop App
BetaYou are reading docs for the beta channel (2.13.0-beta.20). Features may change before the next stable release.Switch to stable →

Skills

Improve React performance with ak:react-best-practices

Audit and refine React or Next.js code with version-aware rules, measured baselines, focused tests, and an explicit mutation boundary.

Use ak:react-best-practices to review or improve React and Next.js performance. Its bundled January 2026 rule set contains 45 patterns across async waterfalls, bundle size, server work, client fetching, re-renders, rendering, JavaScript hot paths, and advanced callback patterns.

Choose ak:react-best-practices for measured optimization

Use ak:react-best-practices when

  • A React component, Next.js route, server function, or bundle has a defined performance problem or budget.
  • You want a focused performance audit with ranked findings before mutation.
  • You need to remove waterfalls, reduce shipped code, narrow re-renders, or improve a measured hot path.
  • You want implementation guidance tied to the project’s actual React, Next.js, browser, and deployment versions.

Choose another workflow when

  • You need general React feature implementation rather than performance work. Use ak:frontend-development.
  • The visual or interaction design is unresolved. Use ak:frontend-design.
  • You are diagnosing an unexplained failure. Use ak:debug or ak:fix before optimizing.
  • You only want independent verification of an existing patch. Use ak:code-review or ak:test.

Prepare a baseline and compatibility map

Before you start:

  • Complete Onboarding, and confirm Engineer Kit is installed for the current runtime and scope.
  • Read the installed React, Next.js, bundler, server runtime, browser target, package manager, data library, and deployment model from the project.
  • Provide the affected route/component, user-visible symptom, performance budget, representative workload, and current measurements.
  • Identify generated files, server/client boundaries, caching semantics, CSP, hydration policy, analytics, and test requirements.
  • State whether dependency installation, config changes, bundle analysis, browser profiling, local servers, remote telemetry, or deployment is allowed.
PriorityRule areaApply when evidence shows
CriticalAsync waterfalls and bundle sizeAvoidable serial latency or unnecessary initial code
HighServer performanceDuplicate work, oversized RSC payloads, or server-side fetch serialization
Medium-highClient data fetchingRepeated requests or duplicated global subscriptions
MediumRe-renders and renderingExcess computation, layout work, hydration issues, or jank
Low-mediumJavaScript hot pathsProfiling shows repeated lookup, allocation, storage, or iteration cost
LowAdvanced callback patternsStable subscriptions are needed and the framework supports the pattern
RuntimeInvocationAvailability boundary
Claude Code/ak:react-best-practices ...Can inspect and edit with available project/browser tools; measurements depend on the session.
Cursor/ak:react-best-practices ...Uses the user-verified slash spelling; broader Agent, Hook, browser, and profiling parity is not established.
Codex$ak:react-best-practices ...Uses native Skill discovery; projected Hooks are partial and browser/profiling tools depend on the session.

See Runtime adapters for component-level differences.

Run the Skill

The declared argument shape is [component or pattern]. Ask for an audit-only pass when you do not want code changes; otherwise state the allowed files and required measurements.

/ak:react-best-practices "Audit the existing Next.js product route for server waterfalls and client bundle cost. Use the installed versions and current profiler/build output, propose ranked changes first, implement only the top approved change, preserve behavior, add focused tests, and do not install packages or deploy."
InputInclude
OutcomeWhich user interaction, route, render, request, or build should improve
BaselineTiming, bundle, request waterfall, render count, memory, CPU, Web Vital, or profiler evidence
CompatibilityReact/Next.js versions, server host, browser range, CSP, caching, and data libraries
Mutation boundaryAudit only or allowed components, config, imports, dependencies, generated files, and deployment
AcceptanceBehavioral tests plus the measurement and regression threshold that defines success

Observe an evidence-led optimization

  1. The run establishes the baseline. It reproduces the target workload and records the current performance and behavior before editing.
  2. The run maps compatibility. It checks whether referenced APIs such as Activity, useEffectEvent, Next.js after, next/dynamic, optimizePackageImports, React cache, or toSorted exist in the project’s supported versions.
  3. The run ranks findings by impact and confidence. Critical network and bundle issues come before speculative micro-optimizations.
  4. The run implements a bounded change. It preserves data dependencies, error behavior, accessibility, hydration, cache invalidation, and server or client ownership.
  5. The run verifies behavior and performance. Focused tests and the same baseline procedure run again; regressions or inconclusive measurements stay visible.
  6. The run reports the evidence. Changed files, rule applied, before/after results, dependencies, environment limits, and rejected or deferred findings are listed.

Keep optimization side effects explicit

A faster example can change behavior

Parallelizing work, moving code across server/client boundaries, adding caches, deferring side effects, or injecting pre-hydration scripts can change ordering, freshness, error handling, CSP, privacy, and recovery behavior. Approve the semantic change, not only the expected speedup.

  • Use Promise.all only for independent operations. Preserve dependency and failure semantics.
  • Cross-request in-memory caches behave differently on long-lived servers, serverless isolates, and multi-instance deployments. Define keys, TTL, invalidation, tenant isolation, and fallback behavior.
  • Direct imports, dynamic imports, SWR, LRU caches, or partial-dependency helpers may require compatible packages and configuration. Do not install them merely to match a reference example.
  • Inline hydration scripts must comply with CSP, escaping, privacy, and the project’s server-rendering contract.
  • Bundle analysis, profiling, builds, and browser runs can consume substantial CPU, memory, storage, ports, and time. Remote telemetry can send project or user data.
  • Commit, publication, rollout, and deployment remain separate approvals.

Verify the result

A complete result should provide:

  • The baseline method and result, affected user path, environment, and dataset.
  • Ranked findings with rule identity, evidence, compatibility, expected impact, confidence, and behavior risk.
  • Exact changed files, imports, config, dependencies, generated output, and server/client boundary changes.
  • Focused typecheck and behavioral test results plus comparable before/after performance evidence.
  • Cache, hydration, error, accessibility, and fallback behavior where the change touches them.
  • An explicit disposition for inconclusive measurements and deferred findings.

Troubleshoot or continue

SymptomSafe next step
A referenced API does not existPreserve the installed versions and use a supported equivalent, or propose a separate upgrade with its own migration evidence.
The benchmark is noisyFix the dataset, build mode, device, network, cache state, and number of runs before drawing a conclusion.
Parallel work changes errors or orderingRestore the dependency boundary, add failure tests, and parallelize only operations proven independent.
A cache returns stale or cross-user dataDisable the cache, inspect keys and lifetime, add tenant/freshness tests, and reintroduce it only with an explicit invalidation contract.
Bundle size improves but UX regressesRe-check loading, prefetch, error, offline, and interaction behavior; keep the user outcome above a single bundle metric.
The runtime does not recognize the SkillConfirm target and scope, restart the session, then follow Runtime cannot find a Skill or Agent.

Continue with ak:frontend-development for implementation, ak:web-testing for browser evidence, or the Engineer Kit overview for coordinated delivery.

Know the current limits

  • The Skill is a static January 2026 guideline set, not a live React, Next.js, browser, package, or host compatibility database.
  • Impact labels and example metrics prioritize investigation; they do not prove the same gain in your application.
  • The shipped Skill contains rule documents, not a project-specific profiler, benchmark suite, visual-regression harness, or deployment monitor.
  • It does not replace correctness, accessibility, security, privacy, cross-browser, or production load testing.
  • Stable and beta contain identical Skill content and resources for this release pair. Beta Codex Hook diagnostics do not change this workflow.