skills/performance-optimization/SKILL.md
Use when performance requirements exist in a spec, when Core Web Vitals scores are below thresholds, when profiling reveals bottlenecks, or when users or monitoring report slow behaviour. Do not use before measuring — optimisation without data is guessing.
npx skillsauth add paulund/ai performance-optimizationInstall 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.
1. MEASURE → Establish baseline with real data
2. IDENTIFY → Find the actual bottleneck (not assumed)
3. FIX → Address the specific bottleneck
4. VERIFY → Measure again, confirm improvement
5. GUARD → Add a CI budget check or monitoring alert to prevent regression
Never skip Step 1. Optimisation without measurement adds complexity without improving what matters.
Core Web Vitals thresholds:
| Metric | Good | Poor | |---|---|---| | LCP (Largest Contentful Paint) | ≤ 2.5s | > 4.0s | | INP (Interaction to Next Paint) | ≤ 200ms | > 500ms | | CLS (Cumulative Layout Shift) | ≤ 0.1 | > 0.25 |
Use the symptom to decide where to look first:
include/eager loading; fetch related data in one querytake/limit; never findMany() without a limitwidth and height, loading="lazy" on below-fold images, fetchpriority="high" on the LCP imageReact.memo only for demonstrably expensive componentslazy(), dynamic imports for heavy rarely-used featuresCache-Control: immutable for content-hashed static assets| Rationalization | Reality |
|---|---|
| "We'll optimise later" | Performance debt compounds. Fix obvious anti-patterns now; defer micro-optimisations. |
| "It's fast on my machine" | Your machine isn't the user's. Profile on representative hardware and slow networks. |
| "This optimisation is obvious" | If you didn't measure, you don't know. Profile first. |
| "The framework handles performance" | Frameworks prevent some issues but can't fix N+1 queries or oversized bundles. |
| "React.memo everywhere makes it faster" | Overusing memo adds overhead. Only apply where profiling shows it helps. |
loading="lazy"React.memo and useMemo applied speculativelyAfter any performance change:
React.memo or useMemo speculatively (not backed by profiling).loading="lazy" on below-fold images.fetchpriority="high" on the LCP image.| Topic | Reference | Load When | |-------|-----------|----------| | Performance Checklist | references/performance-checklist.md | Auditing Core Web Vitals, frontend assets, backend queries, or network optimisations |
development
Use when implementing any logic, fixing any bug, or changing any behaviour. Use when you need to prove code works, when a bug report arrives, or when modifying existing functionality. Do NOT use for config changes, data migrations, or dependency updates.
development
Use when starting a new feature, when requirements are unclear, when asked to write code without a clear spec, or before any non-trivial implementation. Do NOT use for trivial bug fixes or one-line changes.
development
Use when you want authoritative, source-cited code free from outdated patterns. Use when building with any framework or library where correctness matters. Detects the stack from dependency files, fetches official documentation, implements following documented patterns, and cites sources for every framework-specific decision.
development
Use when preparing to ship a feature, release, or deployment. Use before merging to main, creating a release, or deploying to production. Do NOT use for CI-only changes or internal refactors that don't reach production.