/nextjs-performance
Expert Next.js performance optimization skill covering Core Web Vitals, image/font optimization, caching strategies, streaming, bundle optimization, and Server Components best practices. Use when optimizing Next.js applications for Core Web Vitals (LCP, INP, CLS), implementing
$ npx -y skills add giuseppe-trisciuoglio/developer-kit --skill nextjs-performance --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.
- You can call itInvoke it directly when you want it.
- Slash command
/nextjs-performance
Context preview
The summary Claude sees to decide when to auto-load this skill.
Expert Next.js performance optimization skill covering Core Web Vitals, image/font optimization, caching strategies, streaming, bundle optimization, and Server Components best practices. Use when optimizing Next.js applications for Core Web Vitals (LCP, INP, CLS), implementing
SKILL.md
nextjs-performance.SKILL.mdname: nextjs-performance
description: Expert Next.js performance optimization skill covering Core Web Vitals, image/font optimization, caching strategies, streaming, bundle optimization, and Server Components best practices. Use when optimizing Next.js applications for Core Web Vitals (LCP, INP, CLS), implementing next/image and next/font, configuring caching with unstable_cache and revalidateTag, converting Client Components to Server Components, implementing Suspense streaming, or analyzing and reducing bundle size. Supports Next.js 16 + React 19 patterns.
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
Next.js Performance Optimization
Expert guidance for optimizing Next.js applications with focus on Core Web Vitals, modern patterns, and best practices.
Overview
This skill provides comprehensive guidance for optimizing Next.js applications. It covers Core Web Vitals optimization (LCP, INP, CLS), modern React patterns, Server Components, caching strategies, and bundle optimization techniques. Designed for developers already familiar with React/Next.js who want to implement production-grade optimizations.
When to Use
Use this skill when working on Next.js applications and need to:
- Optimize Core Web Vitals (LCP, INP, CLS) for better performance and SEO
- Implement image optimization with `next/image` for faster loading
- Configure font optimization with `next/font` to eliminate layout shift
- Set up caching strategies using `unstable_cache`, `revalidateTag`, or ISR
- Convert Client Components to Server Components for reduced bundle size
- Implement Suspense streaming for progressive page loading
- Analyze and reduce bundle size with code splitting and dynamic imports
- Configure metadata and SEO for better search engine visibility
- Optimize API route handlers for better performance
- Apply Next.js 16 and React 19 modern patterns
Coverage Areas
- **Core Web Vitals optimization** (LCP, INP, CLS)
- **Image optimization** with `next/image`
- **Font optimization** with `next/font`
- **Caching strategies** (`unstable_cache`, `revalidateTag`, ISR)
- **Server Components** patterns and Client-to-Server conversion
- **Streaming and Suspense** for progressive loading
- **Bundle optimization** and code splitting
- **Metadata and SEO** configuration
- **Route handlers** optimization
- **Next.js 16 + React 19** patterns
Instructions
Before Starting
1. **Analyze current performance** with Lighthouse 2. **Identify bottlenecks** - check Core Web Vitals in Chrome DevTools or PageSpeed Insights 3. **Determine optimization priority**:
- LCP issues → Focus on images, fonts
- INP issues → Reduce JS, use Server Components
- CLS issues → Add dimensions, use next/font
How to Use This Skill
1. **Load relevant reference files** based on the area you're optimizing:
- Image issues → `references/image-optimization.md`
- Font/layout shift → `references/font-optimization.md`
- Caching → `references/caching-strategies.md`
- Component architecture → `references/server-components.md`
2. **Follow the quick patterns** for common optimizations 3. **Apply before/after conversions** to improve existing code 4. **Verify improvements** with Lighthouse after changes
Core Principles
1. **Prefer Server Components** - Only use 'use client' when necessary (browser APIs, interactivity) 2. **Load components as low as possible** - Keep Client Components at leaf nodes 3. **Use Suspense boundaries** - Enable streaming and progressive loading 4. **Cache appropriately** - Use tags for granular revalidation 5. **Measure before/after** - Always verify improvements with real metrics
Examples
Example 1: Convert Client Component to Server Component
**BEFORE (Client Component with useEffect):**
'use client'
import { useEffect, useState } from 'react'
export default function ProductList() {
const [products, setProducts] = useState([])
useEffect(() => {
fetch('/api/products').then(r => r.json()).then(setProducts)
}, [])
return <ul>{products.map(p => <li key={p.id}>{p.name}</li>)}</ul>
}**AFTER (Server Component with direct data access):**
import { db } from '@/lib/db'
export default async function ProductList() {
const products = await db.product.findMany()
return <ul>{products.map(p => <li key={p.id}>{p.name}</li>)}</ul>
}Example 2: Optimize Images for LCP
import Image from 'next/image'
export function Hero() {
return (
<div className="relative w-full h-[600px]">
<Image
src="/hero.jpg"
alt="Hero"
fill
priority // Disable lazy loading for LCP
sizes="100vw"
className="object-cover"
/>
</div>
)
}Example 3: Implement Caching Strategy
import { unstable_cache, revalidateTag } from 'next/cache'
// Cached data function
const getProducts = unstable_cache(
async () => db.product.findMany(),
['products'],
{ revalidate: 3600, tags: ['products'] }
)
// Revalidate on mutation
export async function createProduct(data: FormData) {
'use server'
await db.product.create({ data })
revalidateTag('products')
}Example 4: Setup Optimized Fonts
import { Inter } from 'next/font/google'
const inter = Inter({
subsets: ['latin'],
display: 'swap',
variable: '--font-inter',
})
export default function RootLayout({ children }) {
return (
<html lang="en" className={inter.variable}>
<body className={`${inter.className} antialiased`}>
{children}
</body>
</html>
)
}Example 5: Implement Suspense Streaming
import { Suspense } from 'react'
export default function Page() {
return (
<>
<header>Static content (immediate)</header>
<Suspense fallback={<ProductSkeleton />}>
<ProductList /> {/* Streamed when ready */}
</Suspense>
<Suspense fallback={<ReviewsSkeleton />}>
<Reviews /> {/* Independent streaming *Read more
name: nextjs-performance description: Expert Next.js performance optimization skill covering Core Web Vitals, image/font optimization, caching strategies, streaming, bundle optimization, and Server Components best practices. Use when optimizing Next.js applications for Core Web Vitals (LCP, INP, CLS), implementing next/image and next/font, configuring caching with unstable_cache and revalidateTag, converting Client Components to Server Components, implementing Suspense streaming, or analyzing and reducing bundle size. Supports Next.js 16 + React 19 patterns. allowed-tools: Read, Write, Edit, Bash, Glob, Grep
Next.js Performance Optimization
Expert guidance for optimizing Next.js applications with focus on Core Web Vitals, modern patterns, and best practices.
Overview
This skill provides comprehensive guidance for optimizing Next.js applications. It covers Core Web Vitals optimization (LCP, INP, CLS), modern React patterns, Server Components, caching strategies, and bundle optimization techniques. Designed for developers already familiar with React/Next.js who want to implement production-grade optimizations.
When to Use
Use this skill when working on Next.js applications and need to:
- Optimize Core Web Vitals (LCP, INP, CLS) for better performance and SEO
- Implement image optimization with `next/image` for faster loading
- Configure font optimization with `next/font` to eliminate layout shift
- Set up caching strategies using `unstable_cache`, `revalidateTag`, or ISR
- Convert Client Components to Server Components for reduced bundle size
- Implement Suspense streaming for progressive page loading
- Analyze and reduce bundle size with code splitting and dynamic imports
- Configure metadata and SEO for better search engine visibility
- Optimize API route handlers for better performance
- Apply Next.js 16 and React 19 modern patterns
Coverage Areas
- **Core Web Vitals optimization** (LCP, INP, CLS)
- **Image optimization** with `next/image`
- **Font optimization** with `next/font`
- **Caching strategies** (`unstable_cache`, `revalidateTag`, ISR)
- **Server Components** patterns and Client-to-Server conversion
- **Streaming and Suspense** for progressive loading
- **Bundle optimization** and code splitting
- **Metadata and SEO** configuration
- **Route handlers** optimization
- **Next.js 16 + React 19** patterns
Instructions
Before Starting
1. **Analyze current performance** with Lighthouse 2. **Identify bottlenecks** - check Core Web Vitals in Chrome DevTools or PageSpeed Insights 3. **Determine optimization priority**:
- LCP issues → Focus on images, fonts
- INP issues → Reduce JS, use Server Components
- CLS issues → Add dimensions, use next/font
How to Use This Skill
1. **Load relevant reference files** based on the area you're optimizing:
- Image issues → `references/image-optimization.md`
- Font/layout shift → `references/font-optimization.md`
- Caching → `references/caching-strategies.md`
- Component architecture → `references/server-components.md`
2. **Follow the quick patterns** for common optimizations 3. **Apply before/after conversions** to improve existing code 4. **Verify improvements** with Lighthouse after changes
Core Principles
1. **Prefer Server Components** - Only use 'use client' when necessary (browser APIs, interactivity) 2. **Load components as low as possible** - Keep Client Components at leaf nodes 3. **Use Suspense boundaries** - Enable streaming and progressive loading 4. **Cache appropriately** - Use tags for granular revalidation 5. **Measure before/after** - Always verify improvements with real metrics
Examples
Example 1: Convert Client Component to Server Component
**BEFORE (Client Component with useEffect):**
'use client'
import { useEffect, useState } from 'react'
export default function ProductList() {
const [products, setProducts] = useState([])
useEffect(() => {
fetch('/api/products').then(r => r.json()).then(setProducts)
}, [])
return <ul>{products.map(p => <li key={p.id}>{p.name}</li>)}</ul>
}**AFTER (Server Component with direct data access):**
import { db } from '@/lib/db'
export default async function ProductList() {
const products = await db.product.findMany()
return <ul>{products.map(p => <li key={p.id}>{p.name}</li>)}</ul>
}Example 2: Optimize Images for LCP
import Image from 'next/image'
export function Hero() {
return (
<div className="relative w-full h-[600px]">
<Image
src="/hero.jpg"
alt="Hero"
fill
priority // Disable lazy loading for LCP
sizes="100vw"
className="object-cover"
/>
</div>
)
}Example 3: Implement Caching Strategy
import { unstable_cache, revalidateTag } from 'next/cache'
// Cached data function
const getProducts = unstable_cache(
async () => db.product.findMany(),
['products'],
{ revalidate: 3600, tags: ['products'] }
)
// Revalidate on mutation
export async function createProduct(data: FormData) {
'use server'
await db.product.create({ data })
revalidateTag('products')
}Example 4: Setup Optimized Fonts
import { Inter } from 'next/font/google'
const inter = Inter({
subsets: ['latin'],
display: 'swap',
variable: '--font-inter',
})
export default function RootLayout({ children }) {
return (
<html lang="en" className={inter.variable}>
<body className={`${inter.className} antialiased`}>
{children}
</body>
</html>
)
}Example 5: Implement Suspense Streaming
import { Suspense } from 'react'
export default function Page() {
return (
<>
<header>Static content (immediate)</header>
<Suspense fallback={<ProductSkeleton />}>
<ProductList /> {/* Streamed when ready */}
</Suspense>
<Suspense fallback={<ReviewsSkeleton />}>
<Reviews /> {/* Independent streaming *Showing the first part of this file.
Modular plugin marketplace for Claude Code and agentic CLIs, with validated, spec-driven skills, agents, commands, and workflows for Java, TypeScript, Python, PHP, AWS, and AI.
Repo: giuseppe-trisciuoglio/developer-kit
Other skills on developer-kit.
- /chunking-strategy
Provides chunking strategies for RAG systems. Generates chunk size recommendations (256-1024 tokens), overlap percentages (10-20%), and semantic boundary detection methods. Validates semantic coherence and evaluates retrieval precision/recall metrics. Use when building
Open skill - /prompt-engineering
Provides workflows to write, debug, and optimize prompts for LLMs, including few-shot example selection, chain-of-thought structuring, system prompt design, and template composition. Use when the user asks to write or improve a prompt, wants help with few-shot examples,
Open skill - /rag
Implements document chunking, embedding generation, vector storage, and retrieval pipelines for Retrieval-Augmented Generation systems. Use when building RAG applications, creating document Q&A systems, or integrating AI with knowledge bases.
Open skill - /aws-cloudformation-auto-scaling
Provides AWS CloudFormation patterns for Auto Scaling including EC2, ECS, and Lambda. Use when creating Auto Scaling groups, launch configurations, launch templates, scaling policies, lifecycle hooks, and predictive scaling. Covers template structure with Parameters, Outputs,
Open skill - /aws-cloudformation-bedrock
Provides AWS CloudFormation patterns for Amazon Bedrock resources including agents, knowledge bases, data sources, guardrails, prompts, flows, and inference profiles. Use when creating Bedrock agents with action groups, implementing RAG with knowledge bases, configuring vector
Open skill - /aws-cloudformation-cloudfront
Provides AWS CloudFormation patterns for CloudFront distributions, origins (ALB, S3, Lambda@Edge, VPC Origins), CacheBehaviors, Functions, SecurityHeaders, parameters, Outputs and cross-stack references. Use when creating CloudFront distributions with CloudFormation, configuring
Open skill

