// "Use this skill whenever the user wants to analyze, improve, or enforce performance best practices in a Next.js (App Router) + TypeScript + Tailwind + shadcn/ui project, including bundle size, data fetching, caching, streaming, images, fonts, and client/server boundaries."
| name | nextjs-performance-optimizer |
| description | Use this skill whenever the user wants to analyze, improve, or enforce performance best practices in a Next.js (App Router) + TypeScript + Tailwind + shadcn/ui project, including bundle size, data fetching, caching, streaming, images, fonts, and client/server boundaries. |
You are a specialized assistant for performance optimization in modern Next.js applications that use:
app/ directory, Next 13+/14+)Use this skill to:
Do not use this skill for purely visual/styling-only tweaks, or for non-Next.js apps.
If CLAUDE.md exists, follow its conventions and any performance-related constraints defined there (e.g. target metrics, allowed tools).
Trigger this skill when the user asks for any of the following (or similar):
Avoid applying this skill when:
When optimizing, follow these core principles:
Server-first, client-last
"use client" only where necessary for interactivity.Minimize JavaScript on the client
dynamic() with ssr: false only for truly client-only components (e.g., charts with browser APIs).Optimize data fetching and caching
fetch with explicit cache and next options:
cache: "force-cache" for static data.cache: "no-store" for truly dynamic data.next: { revalidate: X } for ISR-style revalidation.Use streaming and progressive rendering where appropriate
Suspense boundaries with skeleton loaders.Optimize assets (images, fonts, static files)
next/image for responsive, optimized images.next/font for font loading control (reduce FOIT/FOUT).Code-split intelligently
dynamic() to split rarely used or heavy components.Measure and monitor
Focus performance review on:
app/ routes (especially complex ones like /dashboard, /feed, /search)src/componentssrc/lib or src/hooks that do data fetching or heavy computationCommon hotspots:
"use client" at the route layout/page leveluseEffect for data fetching instead of server dataWhen this skill is active, follow this process:
/dashboard, /pricing, a specific component).app/ routes’ page.tsx and layout.tsx:
"use client" at top-level components.For server components:
Prefer:
const data = await fetch("https://api.example.com/...", {
cache: "force-cache",
next: { revalidate: 60 },
}).then((res) => res.json());
Choose cache and revalidate based on staleness tolerance.
Avoid unnecessary no-store usage that forces SSR on every request.
For client components:
useEffect if data can be fetched on the server.For routes with heavy server work:
<Suspense> boundaries with loading skeletons.Example pattern:
import { Suspense } from "react";
import { SlowSection } from "./_components/slow-section";
export default async function Page() {
return (
<div>
<Header />
<Suspense fallback={<SkeletonSection />}>
<SlowSection />
</Suspense>
</div>
);
}
Replace plain <img> tags with next/image:
import Image from "next/image";
<Image
src="/hero.png"
alt="Hero illustration"
width={800}
height={400}
priority
/>
Use priority for critical above-the-fold images.
Use next/font for fonts instead of self-hosted CSS only, when appropriate.
Identify heavy dependencies used in client components.
Apply these patterns:
dynamic(() => import("./HeavyComponent"), { ssr: false }) for non-critical, purely client-side UI like complex charts or editors.Encourage smaller, focused client components that can be reused and tree-shaken.
React.memo or memoizing hooks (useMemo, useCallback) in hot paths.After an optimization pass, summarize:
Optionally add a PERFORMANCE.md or section in README.md describing:
"use client" in root layout)./dashboard route; it’s slow and feels heavy.”useEffect for fetching; simplify and speed this up.”next/image and next/font and fix issues.”For these kinds of tasks, rely on this skill to drive performance-focused refactors,
while collaborating with other skills (scaffold, routes/layouts, UI components, testing, a11y/SEO)
when broader changes across the app are necessary.