react-optimizer
Skill1 starsChanged 8 days agoMITView on GitHub
Audit and optimize React apps and component libraries (Vite, CRA, Remix, Parcel, Expo web, plain SPAs; React 17-19) for render performance, bundle size, load speed, Core Web Vitals, state and data-fetching design, accessibility basics, and code safety, with real before/after measurement. Always produces a written findings report and a fix plan for approval before touching any code. Use this whenever the user mentions a slow or laggy React app, too many re-renders, large bundle, slow first load, memo/useMemo/useCallback questions, React Profiler, context or Redux performance, list virtualization, useEffect bugs or fetch waterfalls, React Compiler adoption, or "optimize my React code" -- even if they don't say "audit". For Next.js projects prefer the nextjs-optimizer skill.
In this repository44 other files it gives its agents.
- AGENTS.mdAGENTS.md
- architecture-optimizerSkill
- csharp-optimizerSkill
- cpp-optimizerSkill
- c-optimizerSkill
- go-optimizerSkill
- node-service-optimizerSkill
- ruby-optimizerSkill
- rust-optimizerSkill
- docker-optimizerSkill
- kubernetes-optimizerSkill
- terraform-optimizerSkill
- animate-cssSkill
- animejsSkill
- auto-animateSkill
- gsapSkill
- lenisSkill
- magicuiSkill
- motionSkill
- react-moveSkill
- react-springSkill
- react-three-fiberSkill
- theatrejsSkill
- threejsSkill
- optimizer-routerSkill
- bootstrap-optimizerSkill
- pandacss-optimizerSkill
- sass-scss-optimizerSkill
- stylex-optimizerSkill
- tailwindcss-optimizerSkill
- twind-optimizerSkill
- unocss-optimizerSkill
- vanilla-extract-optimizerSkill
- angular-optimizerSkill
- astro-optimizerSkill
- ui-components-optimizerSkill
- nextjsSkill
- node-optimizerSkill
- nuxt-optimizerSkill
- remix-optimizerSkill
- solid-optimizerSkill
- svelte-optimizerSkill
- tanstack-start-optimizerSkill
- vue-optimizerSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
Read package.json: React version, bundler (Vite/webpack/Parcel/CRA), router, state/data libs (Redux, Zustand, React Query, SWR, Apollo), UI …
- Very specific: line 15
Run python <skill-dir>/scripts/audit.py <project-root> -- static scan of package.json and .js/.jsx/.ts/.tsx (index keys, inline …
- Very specific: line 17
Read references/tooling.md once: what can actually be measured here (React DevTools Profiler, Lighthouse, bundle analyzer, …
- Very specific: line 42
Use plan mode: EnterPlanMode (load with ToolSearch if deferred), write the plan, present with ExitPlanMode.
- Distinctive: line 63
Don't break correctness for speed: Keep keys, cleanups, a11y and error boundaries.
- Very specific: line 64
Docs move: Check react.dev and the version in package.json, not memory (19 changed ref, use, Actions, Compiler).
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
React Optimizer
Audit a React codebase, report what is slow or fragile and why, agree a plan with the user, then fix it. Order: evidence, approval, edits. React "optimizations" (memoization, state moves, effect removal) can change behavior and hide bugs, so nothing is edited before the user approves.
Workflow
1. Scope (quick)
- Read
package.json: React version, bundler (Vite/webpack/Parcel/CRA), router, state/data libs (Redux, Zustand, React Query, SWR, Apollo), UI kit, TypeScript, test runner, whether React Compiler orStrictModeis on. Ifnextis a dependency, say so and hand off to nextjs-optimizer. - Run
python <skill-dir>/scripts/audit.py <project-root>-- static scan ofpackage.jsonand.js/.jsx/.ts/.tsx(index keys, inline objects/functions in JSX props, effects that fetch or set state, missing cleanup, giant components, heavy imports,dangerouslySetInnerHTML, context value churn, no code splitting) with file:line evidence.--jsonfor post-processing. - Classify the pain: slow interactions (re-renders), slow load (bundle/network), memory growth (leaks), or code health. Ask which hurts if unclear.
- Read
references/tooling.mdonce: what can actually be measured here (React DevTools Profiler, Lighthouse, bundle analyzer,why-did-you-render).
2. Audit
The script gives cheap leads; you find the rest by reading hot components. Read the app entry, router/layout, the 3-5 screens the user cares about, and any shared provider. Load only what applies:
| Area | Reference |
| Re-renders, memo, keys, lists, transitions, React Compiler | references/rendering.md |
| State placement, context, stores, derived state | references/state.md |
| Effects, data fetching, waterfalls, Suspense, caching | references/effects-data.md |
| Bundle size, code splitting, images, CWV, build config | references/bundle-loading.md |
| Accessibility, XSS, types, tests, deps, library authoring | references/safety-quality.md |
| Profiler, analyzers, honest measurement | references/tooling.md |
Measure, never guess. Profile the interaction that is slow (React Profiler commit times, why each component rendered) and analyze the production bundle before editing. If the app can't be run or a tool is missing, say measurement wasn't possible instead of inventing numbers. Dev-mode timings are not representative; use a production build.
Mark each finding Confirmed (profile/code evidence) or Suspected (needs measuring).
3. Report
Fill assets/report-template.md, save as REACT_OPTIMIZATION_REPORT.md in the project root, and show the user. 5-line summary, findings table by impact/effort, then per-finding detail (evidence, why it hurts, fix, risk, behavior impact). Group related findings.
4. Plan -- then stop for approval
Use plan mode: EnterPlanMode (load with ToolSearch if deferred), write the plan, present with ExitPlanMode; if unavailable show it in chat and wait for an explicit "go". Structure:
- Quick wins -- stable keys, route-level
lazy, removing barrel/whole-library imports, lazy images, fixing effect cleanups. Low risk. - Structural -- moving state down, splitting contexts, replacing fetch-in-effect with a data library, virtualizing long lists, deleting derived-state effects. Name each behavior change.
- Heavy -- React Compiler adoption, library swaps (moment, lodash, Redux), React/router major upgrades, SSR migration. Separately approved. Each step: files touched, expected effect, how to verify, how to roll back.
5. Fix
Only approved items, small groups. After each: typecheck (tsc --noEmit), lint, tests, build. A break must trace to one change. Don't mix a React version upgrade with optimization edits. Add memo/useMemo/useCallback only where a profile shows the render matters. If something turns out riskier than planned (changed behavior, public component API), stop and ask.
6. Verify and wrap up
Re-measure with the same scenario: Profiler commit duration and render counts for the interaction, bundle size (raw/gzip) per chunk, Lighthouse/Web Vitals on a production build. State plainly what could not be measured. End with deferred items and one suggested next step.
Principles
- Fix the structure before memoizing. Moving state down or lifting content up (
children) removes renders for free;memois a patch. - Memoization needs a profile and stable props. One unstable prop defeats
memo;useMemoon cheap work costs more than it saves. - Effects are for syncing with external systems. Derived data, event reactions and fetching mostly don't belong there.
- Ship less JavaScript. Bundle size beats micro-optimizing renders for load time.
- Don't break correctness for speed. Keep keys, cleanups, a11y and error boundaries.
- Docs move. Check react.dev and the version in
package.json, not memory (19 changedref,use, Actions, Compiler).
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
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.

