optimize-performance
Skill7 starsChanged 15 days agoMITView on GitHub
Use when tuning frontend performance — enables the React Compiler, splits code by route and lazy-loads heavy chunks, adds bundle analysis with a size budget, measures Core Web Vitals (LCP/INP/CLS) with web-vitals, and applies image/CLS best practices. Measure first, then optimize.
- Installs packages
7 other projects use a version of this.
Adopted by
Most recently taken up by
- wollemiahq/skillstheir own version, first seen Nov 1, 2026
- textura-agency/next16-claude-startertheir own version, first seen Oct 14, 2026
- VelimirMueller/claude-skillsword for word, first seen Oct 11, 2026
- maksimzayats/diwiretheir own version, first seen Oct 8, 2026
- emaraschio/cursor-commandstheir own version, first seen Aug 7, 2026
- igmarin/rails-agent-skillstheir own version, first seen Jul 30, 2026
Other versions7 projects use a version of this.
Word for word · 1
- VelimirMueller/claude-skills★ 7100% same
Edited · 0
None found.
Wrote their own version · 6
- maksimzayats/diwire★ 254same name
- textura-agency/next16-claude-starter★ 141same name
- igmarin/rails-agent-skills★ 26same name
- emaraschio/cursor-commands★ 9same name
- wollemiahq/skills★ 2same name
- gologo13/agent-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository156 other files it gives its agents.
- skills/swift/swiftui-design-principles/AGENTS.mdAGENTS.md
- skills/swift/ios-code-audit/CLAUDE.mdCLAUDE.md
- skills/swift/swift-focusengine-pro/llms.txtllms.txt
- build-llm-seamSkill
- build-mcp-serverSkill
- build-rag-pipelineSkill
- secure-llm-featuresSkill
- set-up-llm-evalsSkill
- build-nextjs-backendSkill
- build-supabase-edge-functionSkill
- configure-backend-testsSkill
- design-http-apiSkill
- harden-backendSkill
- scaffold-fastapi-serviceSkill
- scaffold-go-serviceSkill
- scaffold-hono-serviceSkill
- secure-supabase-rlsSkill
- set-up-backend-authSkill
- set-up-background-jobsSkill
- set-up-databaseSkill
- set-up-nextjs-supabase-authSkill
- set-up-observabilitySkill
- set-up-supabaseSkill
- build-cliSkill
- release-cliSkill
- set-up-dev-toolchainSkill
- audit-securitySkill
- audit-toolchainSkill
- extend-skillsetSkill
- promote-releaseSkill
- set-up-stack-profileSkill
- write-commit-messagesSkill
- write-pull-requestsSkill
- analyze-complexitySkill
- apply-algorithmsSkill
- apply-design-patternsSkill
- apply-design-principlesSkill
- apply-solidSkill
- choose-data-structureSkill
- debug-systematicallySkill
- enforce-dependency-ruleSkill
- refactor-safelySkill
- slice-and-estimateSkill
- write-clean-testsSkill
- write-readable-codeSkill
- clean-frontend-scaffoldingSkill
- configure-accessibilitySkill
- configure-analyticsSkill
- configure-ciSkill
- configure-error-trackingSkill
- configure-lintingSkill
- configure-test-stackSkill
- configure-typescriptSkill
- create-moduleSkill
- scaffold-frontend-projectSkill
- set-up-authSkill
- set-up-design-systemSkill
- set-up-document-headSkill
- set-up-error-boundariesSkill
- set-up-feature-flagsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 6 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 100
Always set width/height (or aspect-ratio) so images don't shift layout (CLS).
“Common” is measured: kept by at least 6 in 10 of the 6 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.
Files
Optimize Performance
1. Audit current state
cat .claude/stack-profile.md 2>/dev/null || cat ~/.claude/stack-profile.md 2>/dev/null # frontend.framework, frontend.meta, package_manager
grep -E '"(babel-plugin-react-compiler|rollup-plugin-visualizer|web-vitals)"' package.json 2>/dev/null
grep -rn "React.lazy\|defineAsyncComponent\|loading=\"lazy\"" src/ 2>/dev/null | headRead frontend.framework (step 3) and frontend.meta: next / nuxt have their own image, font and compiler options — use theirs, and treat steps 6–7 as the shared part. Commands use pnpm; translate for package_manager. Prerequisites: scaffold-frontend-project (Vite) and ideally set-up-routing (route-level splitting). Rule zero: measure before optimizing — wire the analyzer + vitals (steps 6–7) before hand-tuning anything.
2. Decide what to do
- Greenfield → enable Compiler + splitting + measurement (steps 4–8).
- Slow app → measure first (6–7), then attack the biggest chunk / worst vital.
3. Detect framework
React → React Compiler + React.lazy. Vue → the SFC compiler is already optimal; lazy via defineAsyncComponent, and v-memo/v-once for proven hotspots only.
4. Enable the React Compiler (React)
The compiler auto-memoizes — new code needs no useMemo/useCallback/memo. Compiler 1.0 is stable; React 19 needs no runtime shim.
A new project can start from pnpm create vite@latest <name> --template react-compiler-ts. Existing project, @vitejs/plugin-react ≥ 6 (Vite 8):
pnpm add -D -E babel-plugin-react-compiler
pnpm add -D @rolldown/plugin-babel// vite.config.ts
import babel from '@rolldown/plugin-babel';
import react, { reactCompilerPreset } from '@vitejs/plugin-react';
export default defineConfig({
plugins: [
// if set-up-routing ran, tanstackRouter() goes FIRST
react(),
babel({ presets: [reactCompilerPreset()] }), // order as in the React docs; the preset runs on source
// then tailwindcss()
],
});plugin-react 6 removed the inline react({ babel: … }) option — a config using it fails silently on the compiler. Next.js 16: reactCompiler: true in next.config.ts (plus the same Babel plugin).
Pin the compiler exact (-E): its output can change between versions. In existing code, leave manual memoization in place — removing it can change what the compiler emits; new code just doesn't add it. Keep Zustand selectors (a subscription, not memoization; see set-up-state-management). The compiler's lint rules live in eslint-plugin-react-hooks, not Biome — see configure-linting/lint-and-format.md for when to add it.
5. Split code by route, lazy-load the heavy stuff
- Routes: already split if
set-up-routingran (TanStackautoCodeSplitting/ Vue dynamicimport()). - Heavy non-route components (charts, editors, modals below the fold):
const Chart = lazy(() => import('@/components/organisms/Chart')); // React
// Vue: const Chart = defineAsyncComponent(() => import('@/components/organisms/Chart.vue'))Wrap in <Suspense>. Let Vite handle vendor splitting; only configure chunking for a measured win, under build.rolldownOptions (Vite 8 deprecated build.rollupOptions as an alias of it).
6. Bundle analysis + a budget
pnpm add -D rollup-plugin-visualizer// vite.config.ts (dev-only-ish; gate behind an env flag)
import { visualizer } from 'rollup-plugin-visualizer';
// plugins: [..., visualizer({ filename: 'dist/stats.html', gzipSize: true })]pnpm build then open dist/stats.html. Set a budget (e.g. initial JS < 200 KB gzipped) and enforce it with size-limit so regressions fail the build, not just the eyeball:
pnpm add -D size-limit @size-limit/file// .size-limit.json — globs cover the files dist/index.html loads (entry + its static vendor chunks); lazy route chunks stay out
[{ "name": "initial JS", "path": "dist/assets/index-*.js", "limit": "200 kB", "gzip": true }]pnpm exec size-limit exits non-zero over the limit (run it after pnpm build, as configure-ci does). @size-limit/file measures built files only; preset-app adds a Chrome-based timing plugin that is slow and flaky in CI. Without gzip: true it measures brotli, so say which one the budget means.
7. Measure Core Web Vitals
pnpm add web-vitals// src/libs/reportWebVitals.ts
import { onCLS, onINP, onLCP } from 'web-vitals';
export function reportWebVitals(report: (m: { name: string; value: number }) => void) {
onCLS(report);
onINP(report); // INP replaced FID in 2024
onLCP(report);
}Call it once from the app entry; send to analytics (or the captureError-style seam) in prod, console.log in dev. Browser coverage: onINP and onLCP report in Chromium, Firefox and Safari; onCLS only in Chromium, so field CLS is a Chromium sample. Sending the values to an analytics vendor is analytics: it follows that skill's consent rule (configure-analytics).
8. Images & layout stability
- Always set
width/height(oraspect-ratio) so images don't shift layout (CLS). loading="lazy"+decoding="async"for below-the-fold images. The LCP image is the exception: noloading="lazy", addfetchpriority="high".- Serve AVIF/WebP;
vite-imagetoolsgenerates responsivesrcsetat build time. - Preload the LCP image/font;
font-display: swap.
9. Verify
pnpm build # inspect dist/stats.html against the budget
pnpm preview # run Lighthouse / read web-vitals in consoleTargets, judged at the 75th percentile of real page loads (the "good" thresholds): LCP ≤ 2.5 s, INP ≤ 200 ms, CLS ≤ 0.1. Lighthouse on a mid-tier mobile profile is the lab proxy.
References
- ./performance-rules.md — measure-first, the Compiler's effect, splitting strategy, CWV targets, image/CLS rules, when manual memo still matters.
- ../_shared/conventions.md —
@/alias,libs/seam. - ../_shared/stack-versions.md — tooling versions.
- ../../landing/build-landing-page/SKILL.md — the hero LCP/CLS budget on public pages, where CWV are ranking + revenue (the priority inversion:
../../landing/_shared/page-types.md).
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.

