Token导航 LogoToken导航

Agent Skill · 研究检索

nextjs-optimization(Next.js optimization 搜索)

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

nextjs-optimization 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为操作浏览器;许可证信息还不明确,第三方扫描有提醒项,按安装量在研究检索类的 73,675 个 Skill 里排第 37,859。

总安装 1,656周安装 67GitHub Stars 6下载 520核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:nextjs-optimization(Next.js optimization 搜索)
来源仓库:https://github.com/atman36/ai-vibe-prompts
仓库路径:skills/nextjs-optimization
安装命令:
npx skills add https://github.com/atman36/ai-vibe-prompts --skill nextjs-optimization
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/atman36/ai-vibe-prompts --skill nextjs-optimization

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

用于分析和提升 Next.js 应用的性能指标。包括包体积精简、图像优化与渲染策略调整。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。提供 Lighthouse 评分改进建议与监控方案。优化措施可能影响功能,建议灰度发布验证效果。

nextjs-optimization 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/nextjs-optimization

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/atman36/ai-vibe-prompts --skill nextjs-optimiz…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要操作浏览器,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

nextjs-optimization 怎么安装?

在终端执行 npx skills add https://github.com/atman36/ai-vibe-prompts --skill nextjs-optimization。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

nextjs-optimization 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

nextjs-optimization 需要什么权限?

权限级别是操作浏览器。该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

nextjs-optimization 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

nextjs-optimization 用的人多吗?

公开数据是累计安装 1,656 次,近一周安装 67 次,下载 520 次,GitHub 6 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

nextjs-optimization 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
nextjs-optimization

Next.js optimization 搜索 · 本页

1,6566操作浏览器未明确有提醒

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Next.js 15 Optimization Skill

Objective

Optimize Next.js applications to achieve:

  • Perfect Core Web Vitals scores (LCP < 2.5s, FID < 100ms, CLS < 0.1)
  • Fast page load times and optimal rendering strategies
  • Efficient data fetching and caching
  • Production-ready build configuration
  • SEO and accessibility excellence

When to Use This Skill

Auto-invoke when:

  • Project uses Next.js (detected by next in dependencies)
  • User mentions "optimize", "performance", "slow", or "Core Web Vitals"
  • Before production deployment
  • After adding new features or pages
  • User requests Next.js-specific improvements

Prerequisites Check

Tools: Read, Grep

  1. Verify Next.js version: # Read package.json # Check for "next": "^15.0.0" or higher
  2. Detect App Router (Next.js 13+):

- Check for app/ directory - Check for layout.tsx, page.tsx files

  1. Detect Pages Router (Legacy):

- Check for pages/ directory - Suggest migration to App Router

Optimization Categories

1. Rendering Strategy Optimization

Goal: Choose optimal rendering for each page/component

Tools: Read, Grep, Edit

1.1 Server Components (Default in App Router)

When to use:

  • Data fetching from APIs/databases
  • Heavy computation
  • Access to backend resources

Pattern:

// app/dashboard/page.tsx
export default async function DashboardPage() {
  const data = await fetchData(); // Runs on server
  return <Dashboard data={data} />;
}

Check for violations:

# Search for "use client" in components that don't need it
grep -r "use client" app/ | grep -v "onClick\|useState\|useEffect"
1.2 Client Components

When to use:

  • Interactive UI (onClick, forms)
  • Browser APIs (window, localStorage)
  • React hooks (useState, useEffect)

Pattern:

// app/components/Counter.tsx
'use client';

export default function Counter() {
  const [count, setCount] = useState(0);
  return <button onClick={() => setCount(count + 1)}>{count}</button>;
}

Optimization: Keep client components small and leaf nodes

1.3 Static Generation (SSG)

When to use:

  • Content that rarely changes
  • Marketing pages, blogs, documentation

Pattern:

export const revalidate = 3600; // Revalidate every hour

export default async function BlogPost({ params }) {
  const post = await getPost(params.slug);
  return <Article post={post} />;
}
1.4 Dynamic Rendering with ISR

When to use:

  • Content that changes periodically
  • E-commerce products, user profiles

Pattern:

export const revalidate = 60; // Revalidate every minute

export async function generateStaticParams() {
  const products = await getProducts();
  return products.map((p) => ({ slug: p.slug }));
}

2. Image Optimization

Goal: Optimize images for performance and Core Web Vitals

Tools: Grep, Read, Edit

2.1 Use Next.js Image Component

Find unoptimized images:

grep -rn "<img " app/ src/

Replace with:

import Image from 'next/image';

<Image
  src="/hero.jpg"
  alt="Hero image"
  width={1200}
  height={600}
  priority // For above-the-fold images
  placeholder="blur" // Optional blur-up effect
/>
2.2 Configure Image Domains

Read next.config.js:

module.exports = {
  images: {
    remotePatterns: [
      {
        protocol: 'https',
        hostname: 'example.com',
      },
    ],
    formats: ['image/avif', 'image/webp'], // Modern formats
  },
};
2.3 Lazy Loading Strategy
  • priority: Above-the-fold images (LCP candidates)
  • loading="lazy": Below-the-fold images (default)

3. Font Optimization

Goal: Eliminate FOUT/FOIT and improve font loading

Tools: Read, Edit

3.1 Use next/font

Pattern:

// app/layout.tsx
import { Inter } from 'next/font/google';

const inter = Inter({
  subsets: ['latin'],
  display: 'swap', // Prevent FOIT
  variable: '--font-inter',
});

export default function RootLayout({ children }) {
  return (
    <html lang="en" className={inter.variable}>
      <body>{children}</body>
    </html>
  );
}
3.2 Self-Hosted Fonts
import localFont from 'next/font/local';

const customFont = localFont({
  src: './fonts/CustomFont.woff2',
  display: 'swap',
  variable: '--font-custom',
});

4. Data Fetching Optimization

Goal: Minimize waterfalls and optimize cache

Tools: Read, Grep, Edit

4.1 Parallel Data Fetching

Anti-pattern (Sequential):

const user = await getUser();
const posts = await getPosts(user.id); // Waits for user

Optimized (Parallel):

const [user, posts] = await Promise.all([
  getUser(),
  getPosts(),
]);
4.2 Streaming with Suspense

Pattern:

import { Suspense } from 'react';

export default function Page() {
  return (
    <>
      <Header />
      <Suspense fallback={<Skeleton />}>
        <SlowComponent />
      </Suspense>
      <Footer />
    </>
  );
}
4.3 Cache Configuration
// Aggressive caching
fetch('https://api.example.com/data', {
  next: { revalidate: 3600 }, // Cache for 1 hour
});

// No caching
fetch('https://api.example.com/data', {
  cache: 'no-store', // Always fresh
});

// Opt out of caching
export const dynamic = 'force-dynamic';

5. Bundle Optimization

Goal: Reduce JavaScript bundle size

Tools: Bash, Read, Edit

5.1 Analyze Bundle
# Add to package.json scripts
npm run build
npx @next/bundle-analyzer
5.2 Dynamic Imports

Find large components:

find app -name "*.tsx" -exec wc -l {} \; | sort -rn | head -10

Split with dynamic imports:

import dynamic from 'next/dynamic';

const HeavyComponent = dynamic(() => import('./HeavyComponent'), {
  loading: () => <Skeleton />,
  ssr: false, // Skip SSR if not needed
});
5.3 Tree Shaking

Check for barrel exports:

grep -rn "export \* from" app/

Replace with specific imports:

// Anti-pattern
import { Button, Card, Modal } from '@/components';

// Optimized
import { Button } from '@/components/Button';

6. Metadata & SEO

Goal: Perfect SEO and social sharing

Tools: Read, Edit

6.1 Static Metadata
// app/layout.tsx
export const metadata = {
  title: {
    default: 'My App',
    template: '%s | My App',
  },
  description: 'Description for SEO',
  openGraph: {
    title: 'My App',
    description: 'Description for social sharing',
    images: ['/og-image.jpg'],
  },
  twitter: {
    card: 'summary_large_image',
  },
};
6.2 Dynamic Metadata
export async function generateMetadata({ params }) {
  const post = await getPost(params.slug);
  return {
    title: post.title,
    description: post.excerpt,
    openGraph: {
      images: [post.ogImage],
    },
  };
}

7. Production Configuration

Goal: Optimize next.config.js for production

Tools: Read, Edit

7.1 Essential Config
// next.config.js
module.exports = {
  reactStrictMode: true,
  poweredByHeader: false, // Security
  compress: true, // Gzip compression

  // Compiler optimizations
  compiler: {
    removeConsole: process.env.NODE_ENV === 'production',
  },

  // Image optimization
  images: {
    formats: ['image/avif', 'image/webp'],
    deviceSizes: [640, 750, 828, 1080, 1200, 1920],
  },

  // React Compiler (Next.js 15)
  experimental: {
    reactCompiler: true,
  },
};
7.2 Turbopack (Development)
// package.json
{
  "scripts": {
    "dev": "next dev --turbo"
  }
}

8. Core Web Vitals Optimization

Goal: Achieve perfect Lighthouse scores

Tools: Bash, Grep, Edit

8.1 LCP (Largest Contentful Paint) < 2.5s

Optimize:

  • Use priority on hero images
  • Preload critical resources
  • Server-side render above-the-fold content
// Preload critical resources
<link rel="preload" href="/hero.jpg" as="image" />
8.2 FID (First Input Delay) < 100ms

Optimize:

  • Minimize JavaScript execution
  • Use dynamic imports for non-critical code
  • Defer third-party scripts
import Script from 'next/script';

<Script
  src="https://analytics.example.com"
  strategy="lazyOnload" // Load after page interactive
/>
8.3 CLS (Cumulative Layout Shift) < 0.1

Optimize:

  • Always specify image dimensions
  • Reserve space for dynamic content
  • Use font-display: swap
/* Reserve space for ads/banners */
.ad-container {
  min-height: 250px;
}

9. Caching Strategy

Goal: Maximize cache hits and minimize server load

Tools: Read, Edit

9.1 Route Segment Config
// app/dashboard/page.tsx
export const revalidate = 3600; // ISR every hour
export const dynamic = 'auto'; // Automatic optimization
export const fetchCache = 'force-cache'; // Aggressive caching
9.2 Data Cache
// Deduplicated and cached automatically
const user = await fetch('https://api.example.com/user');

// Revalidate tag-based
export const revalidate = 60;
export const tags = ['user', 'profile'];

10. Monitoring & Measurement

Goal: Track performance over time

Tools: Bash, WebSearch

10.1 Add Web Vitals Reporting
// app/layout.tsx
import { SpeedInsights } from '@vercel/speed-insights/next';

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        {children}
        <SpeedInsights />
      </body>
    </html>
  );
}
10.2 Lighthouse CI
# Run Lighthouse
npx lighthouse http://localhost:3000 --view

# Check Core Web Vitals
npm run build
npm run start
npx lighthouse http://localhost:3000 --only-categories=performance

Optimization Checklist

Run through this checklist:

  • All images use next/image with proper dimensions
  • Fonts use next/font with display: swap
  • Server Components used by default (no unnecessary 'use client')
  • Client Components are leaf nodes and minimal
  • Data fetching uses parallel requests where possible
  • Slow components wrapped in <Suspense>
  • Large components use dynamic imports
  • Metadata configured for all pages
  • next.config.js has production optimizations
  • React Compiler enabled (Next.js 15)
  • Bundle analyzed and optimized
  • Core Web Vitals meet targets (test with Lighthouse)

Output Format

# Next.js Optimization Report

## Current Status
- **Next.js Version**: 15.0.3
- **Rendering**: App Router
- **React Version**: 19.0.0

## Issues Found

### 🔴 Critical (3)
1. **Unoptimized Images**: 12 `<img>` tags found
   - Files: `app/page.tsx`, `app/about/page.tsx`
   - Fix: Replace with `next/image`

2. **Large Client Bundle**: 342 KB (target: < 200 KB)
   - Cause: Heavy chart library loaded synchronously
   - Fix: Use dynamic import for `Chart` component

3. **Missing Font Optimization**: Using Google Fonts via <link>
   - Fix: Migrate to `next/font/google`

### 🟡 Warnings (2)
1. **Sequential Data Fetching**: Waterfall detected in `app/dashboard/page.tsx`
2. **No Metadata**: Missing OpenGraph tags on 5 pages

## Optimizations Applied

✅ Enabled React Compiler in next.config.js
✅ Added image optimization config
✅ Configured proper cache headers
✅ Added Suspense boundaries to slow routes

## Performance Impact (Estimated)

- **Load Time**: 3.2s → 1.8s (-44%)
- **Bundle Size**: 342 KB → 198 KB (-42%)
- **LCP**: 3.1s → 2.3s (✅ Good)
- **FID**: 85ms → 45ms (✅ Good)
- **CLS**: 0.15 → 0.05 (✅ Good)

## Next Steps

1. Replace 12 `<img>` tags with `next/image`
2. Split Chart component with dynamic import
3. Add metadata to 5 pages
4. Run Lighthouse to verify improvements

Best Practices

  1. Server-First Mindset: Default to Server Components
  2. Progressive Enhancement: Build for slow networks first
  3. Measure, Don't Guess: Use Lighthouse and Web Vitals
  4. Cache Aggressively: But revalidate appropriately
  5. Optimize Incrementally: Fix critical issues first

Integration with Other Skills

  • codebase-analysis - Detect Next.js project and version
  • quality-gates - Run build and verify no regressions
  • react-patterns - Ensure React 19 best practices
  • testing-strategy - Add performance tests

Common Anti-Patterns to Avoid

❌ Using 'use client' at the top level ❌ Not specifying image dimensions ❌ Synchronous data fetching ❌ Loading entire component libraries ❌ No Suspense boundaries ❌ Ignoring Core Web Vitals

Version History

  • 1.0.0 (2025-01-03): Initial skill for Next.js 15 with App Router focus

平台分布

Codex

37.34%
按下载量换算194

Claude

30.88%
按下载量换算161

Cursor

17.24%
按下载量换算90

Gemini CLI

8.53%
按下载量换算44

安全审计

Gen Agent Trust Hub

通过

Socket

可疑

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills