Agent skill
Next.js Optimization
Image, Font, Script, and Metadata optimization strategies.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/optimization
Metadata
Additional technical details for this skill
- labels
-
nextjs optimization seo performance
- triggers
-
{ "files": [ "**/layout.tsx", "**/page.tsx" ], "keywords": [ "next/image", "next/font", "metadata", "generateMetadata" ] }
SKILL.md
Optimization
Priority: P1 (HIGH)
Core optimization primitives provided by Next.js. Monitor First, Optimize Later.
Monitoring (Core Web Vitals)
Before applying optimizations, identify bottlenecks using:
- LCP (Largest Contentful Paint): Initial load speed. Target < 2.5s.
- CLS (Cumulative Layout Shift): Visual stability. Target < 0.1.
- INP (Interaction to Next Paint): Responsiveness. Target < 200ms.
- Tools: Chrome DevTools "Performance" tab,
next/speed-insights, orReact Profiler.
Images (next/image)
- Pattern: Always use
next/imageto prevent CLS. Usepriorityfor LCP images. - Responsive: Use
sizes(e.g.,(max-width: 768px) 100vw, 33vw) to avoid downloading oversized images. - Constraints:
- Remote domains must be in
next.config.jsremotePatterns. - Use
placeholder="blur"for local images (automatic) or remote (manualblurDataURL). - Use
fillwithobject-fitfor parent-relative sizing.
- Remote domains must be in
Fonts (next/font)
- Strategy: Self-host Google Fonts or local files via
next/font. - Optimization: Zero layout shift, no network requests for font files at runtime. Apply classes to
<body>or specific elements.
Metadata (SEO)
-
Static: Export
metadataobject fromlayout.tsxorpage.tsx.tsxexport const metadata: Metadata = { title: 'Dashboard', description: '...', }; -
Dynamic: Export
generateMetadata({ params })function.tsxexport async function generateMetadata({ params }) { const product = await getProduct(params.id); return { title: product.name }; } -
Open Graph: Use
openGraphkey for social cards.
Scripts (next/script)
- Loading Strategy: Control when 3rd party scripts load.
strategy="afterInteractive"(Default): Google Analytics.strategy="lazyOnload": Chat widgets, low priority.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?