skills/react-vite-best-practices/SKILL.md
Improve React applications built with Vite. Use this whenever the user mentions Vite, `vite.config.*`, bundle size, slow builds, slow dev server startup, broken or slow HMR/Fast Refresh, route or component lazy loading, `React.lazy`, `Suspense`, manual chunks, dependency prebundling, asset loading, tree shaking, or asks for performance/review help on a React + Vite codebase even if they do not explicitly ask for "best practices."
npx skillsauth add cenjie/skills react-vite-best-practicesInstall 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.
Use this skill to make React + Vite changes that are measurably better, not just conventionally tidy. Focus on the user's actual bottleneck first: production bundle size, runtime performance, startup/build speed, or dev-loop friction.
Use it when the request involves any of these:
vite.config.ts, vite.config.js, or plugin setupReact.lazy, Suspense, dynamic imports, or route-level splittingimport.meta.envDo not use this skill for generic React work that does not involve Vite, build tooling, or performance-sensitive frontend delivery.
Classify the task before editing:
perf: core performance issues (barrel files, plugin performance, import resolution, file warmup, native tooling)build: production bundle size, chunking, caching, minification, sourcemapssplit: route/component lazy loading, dynamic imports, chunk boundariesdev: startup time, dependency prebundling, dev server responsivenesshmr: Fast Refresh resets, full reloads, HMR misconfigurationasset: images, fonts, SVG strategy, static assetsenv: import.meta.env, VITE_ usage, mode-specific configbundle: tree shaking, dependency weight, visualizer-driven cleanupIf multiple categories apply, handle them in this order:
Look for the relevant files first:
vite.config.*package.jsonsrc/main.*vite-env.d.tsWhen reviewing, call out the concrete problem you found, such as:
import.meta.env misusePrefer changes that map directly to the symptom:
optimizeDeps tuning, plugin cleanup, fewer unnecessary transformsWhen proposing or applying a change, explain the tradeoff in one sentence:
Do not present an optimization as free if it increases complexity or shifts cost elsewhere.
Use these defaults unless the repo context suggests otherwise:
vite-plugin-svgr only when SVGs need component behaviorimport.meta.env when env vars are part of app logicOpen only the files relevant to the current task.
rules/build-manual-chunks.mdrules/build-chunk-strategy.mdrules/build-code-splitting.mdrules/build-minification.mdrules/build-minify-terser.mdrules/build-target-modern.mdrules/build-sourcemaps.mdrules/build-asset-hashing.mdrules/build-compression.mdrules/build-tree-shaking.mdrules/build-vendor-splitting.mdrules/bundle-tree-shaking.mdrules/split-route-lazy.mdrules/split-lazy-routes.mdrules/split-component-lazy.mdrules/split-dynamic-imports.mdrules/split-suspense-boundaries.mdrules/split-prefetch-hints.mdrules/split-library-chunks.mdrules/dev-dependency-prebundling.mdrules/dev-fast-refresh.mdrules/dev-hmr-config.mdrules/hmr-fast-refresh.mdrules/asset-image-optimization.mdrules/asset-svg-components.mdrules/env-vite-prefix.mdrules/perf-avoid-barrel-files.mdrules/perf-plugin-audit.mdrules/perf-resolve-operations.mdrules/perf-warmup-files.mdrules/perf-native-tooling.mdrules/perf-browser-setup.mdWhen using this skill, structure the output around the current task:
Avoid these common mistakes:
manualChunks without checking actual dependency usagevite.config.ts and make the build output saner?"import.meta.env.MY_API_URL undefined in production?"If you need detailed examples, open the matching rule files in rules/ rather than expanding this file with long embedded code samples.
development
Launch both thermo-nuclear review subagents in parallel, then synthesize their findings. Use for thermos, double thermo review, or combined bug/security and code-quality branch audits.
development
Comprehensive security and correctness audit of a branch's changes. Use for thermo nuclear, thermonuclear, or deep review requests, or branch/PR diff audits focused on bugs, breaking changes, security issues, devex regressions, and feature-gate leaks.
development
Run an extremely strict maintainability review for abstraction quality, giant files, and spaghetti-condition growth. Use for a thermo-nuclear code quality review, thermonuclear review, deep code quality audit, or especially harsh maintainability review.
development
Use for custom storefronts requiring direct GraphQL queries/mutations for data fetching and cart operations. Choose this when you need full control over data fetching and rendering your own UI. NOT for Web Components - if the prompt mentions HTML tags like <shopify-store>, <shopify-cart>, use storefront-web-components instead.