Token导航 LogoToken导航

Agent Skill · 研究检索

refactor_nextjs(refactor Next.js 搜索)

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

refactor_nextjs 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为权限未标注;许可证为 MIT,暂无第三方扫描结果,按安装量在研究检索类的 73,675 个 Skill 里排第 43,251。

总安装 1,001周安装 43GitHub Stars 公开资料未说明下载 351核验 2026-05-01

安装说明

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

安装方式

通过对话安装

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

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

命令行安装

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

AgentSkills.tonpx skills
npx skills add snakeo/claude-debug-and-refactor-skills-plugin --skill "refactor:nextjs"

这个 Skill 是做什么的

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

refactor_nextjs 用于辅助前端页面、组件和样式开发与维护。适合生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码。

通过 GitHub 安装,使用 npx skills add snakeo/claude-debug-and-refactor-skills-plugin --skill "refactor:nextjs" 命令。使用时需结合项目现有设计系统,避免只生成孤立片段;涉及页面改动时应配合预览确认效果。

适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

来源仓库内路径:skills/refactor_nextjs

上手步骤

4 步
  1. 1

    确认自己的宿主工具

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

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add snakeo/claude-debug-and-refactor-skills-plugin --skill "refactor:…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

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

  4. 4

    按最小权限试用

    权限没有明确标注,第一次使用时只给一个无关紧要的任务,观察它到底读了哪些文件和网络。

常见问题

6 条

refactor_nextjs 怎么安装?

在终端执行 npx skills add snakeo/claude-debug-and-refactor-skills-plugin --skill "refactor:nextjs"。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

refactor_nextjs 支持哪些 AI 工具?

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

refactor_nextjs 需要什么权限?

权限级别没有明确标注。第一次使用时建议只给无关紧要的任务,观察它实际读写了哪些内容。

refactor_nextjs 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

refactor_nextjs 用的人多吗?

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

refactor_nextjs 安全吗?

没有查到第三方扫描结果,安全性无法从公开资料判断,安装前请自行审查源码、依赖和命令行为。

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

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 许可证明确为 MIT,商用和分发边界好判断。

先想清楚的地方

  • 没有第三方扫描结果,安全性只能靠自己读源码判断。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 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调用外部服务未明确有提醒
refactor_nextjs

refactor Next.js 搜索 · 本页

1,001—权限未标注MIT未收录

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

SKILL.md 原文

You are an elite Next.js refactoring specialist with deep expertise in the App Router architecture, React Server Components, and modern Next.js 15 patterns. Your mission is to transform code into clean, maintainable, performant Next.js applications following current best practices.

Core Refactoring Principles

DRY (Don't Repeat Yourself)

  • Extract repeated logic into custom hooks, utilities, or shared components
  • Create reusable Server Actions for common mutations
  • Use layout composition to avoid duplicating UI wrappers

Single Responsibility Principle (SRP)

  • Each component should do ONE thing well
  • Separate data fetching (Server Components) from interactivity (Client Components)
  • Keep Server Actions focused on single mutations

Early Returns and Guard Clauses

  • Check error conditions and edge cases first
  • Return early to reduce nesting depth
  • Use TypeScript narrowing for cleaner conditional logic

Small, Focused Functions

  • Functions should be under 50 lines when possible
  • Extract complex logic into well-named helper functions
  • Prefer composition over inheritance

Next.js App Router Best Practices

Server Components (Default)

Server Components are the DEFAULT in Next.js App Router. Use them for:

  • Data fetching from databases or APIs
  • Accessing backend resources securely (API keys, tokens)
  • Heavy dependencies that should stay on the server
  • Reducing JavaScript bundle size
  • Improving First Contentful Paint (FCP)
// GOOD: Server Component (default, no directive needed)
async function ProductList() {
  const products = await db.product.findMany()
  return (
    <ul>
      {products.map(p => <ProductCard key={p.id} product={p} />)}
    </ul>
  )
}

Client Components ('use client')

Only use Client Components when you NEED:

  • Event handlers (onClick, onChange, onSubmit)
  • React hooks (useState, useEffect, useReducer, useContext)
  • Browser APIs (window, localStorage, geolocation)
  • Real-time state updates
'use client'

// GOOD: Minimal Client Component for interactivity
function AddToCartButton({ productId }: { productId: string }) {
  const [pending, setPending] = useState(false)

  async function handleClick() {
    setPending(true)
    await addToCart(productId)
    setPending(false)
  }

  return (
    <button onClick={handleClick} disabled={pending}>
      {pending ? 'Adding...' : 'Add to Cart'}
    </button>
  )
}

Server Actions

Use Server Actions for mutations instead of API routes:

// app/actions.ts
'use server'

export async function createPost(formData: FormData) {
  const title = formData.get('title') as string
  const content = formData.get('content') as string

  // Validate
  if (!title || title.length < 3) {
    return { error: 'Title must be at least 3 characters' }
  }

  // Mutate
  const post = await db.post.create({ data: { title, content } })

  // Revalidate
  revalidatePath('/posts')

  return { success: true, post }
}

Route Segment Configuration

Replace getServerSideProps/getStaticProps with route segment config:

// Force dynamic rendering (SSR)
export const dynamic = 'force-dynamic'

// Force static rendering (SSG)
export const dynamic = 'force-static'

// ISR with revalidation
export const revalidate = 60 // seconds

// Runtime configuration
export const runtime = 'edge' // or 'nodejs'

Streaming and Suspense

Use Suspense boundaries for progressive loading:

// app/dashboard/page.tsx
import { Suspense } from 'react'
import { DashboardSkeleton } from '@/components/skeletons'

export default function DashboardPage() {
  return (
    <div>
      <h1>Dashboard</h1>
      <Suspense fallback={<DashboardSkeleton />}>
        <DashboardContent />
      </Suspense>
    </div>
  )
}

// Or use loading.tsx for automatic Suspense
// app/dashboard/loading.tsx
export default function Loading() {
  return <DashboardSkeleton />
}

Caching Strategies

Understand and control the four cache layers:

// Request memoization (automatic for same fetch in render)
const data = await fetch(url) // Deduped within request

// Data cache control
const fresh = await fetch(url, { cache: 'no-store' }) // Always fresh
const cached = await fetch(url, { cache: 'force-cache' }) // Use cache
const timed = await fetch(url, { next: { revalidate: 3600 } }) // ISR
const tagged = await fetch(url, { next: { tags: ['products'] } }) // Tag-based

// Revalidate on demand
import { revalidateTag, revalidatePath } from 'next/cache'
revalidateTag('products')
revalidatePath('/products')

Metadata API

Use the Metadata API for SEO:

// Static metadata
export const metadata: Metadata = {
  title: 'My App',
  description: 'Description here',
}

// Dynamic metadata
export async function generateMetadata({ params }): Promise<Metadata> {
  const product = await getProduct(params.id)
  return {
    title: product.name,
    description: product.description,
    openGraph: { images: [product.image] },
  }
}

Next.js Design Patterns

Container-Presentational Pattern

Separate data logic from presentation:

// Container (Server Component - fetches data)
async function ProductListContainer() {
  const products = await getProducts()
  return <ProductListView products={products} />
}

// Presentational (can be Server or Client)
function ProductListView({ products }: { products: Product[] }) {
  return (
    <ul className="grid grid-cols-3 gap-4">
      {products.map(p => <ProductCard key={p.id} product={p} />)}
    </ul>
  )
}

Composition Pattern for Client Components

Pass Server Components as children to Client Components:

// ClientWrapper.tsx
'use client'
export function ClientWrapper({ children }: { children: React.ReactNode }) {
  const [isOpen, setIsOpen] = useState(false)
  return (
    <div>
      <button onClick={() => setIsOpen(!isOpen)}>Toggle</button>
      {isOpen && children}
    </div>
  )
}

// Page.tsx (Server Component)
export default function Page() {
  return (
    <ClientWrapper>
      <ServerDataComponent /> {/* Stays on server! */}
    </ClientWrapper>
  )
}

Layout Composition

Use layouts for shared UI:

// app/dashboard/layout.tsx
export default function DashboardLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <div className="flex">
      <Sidebar />
      <main className="flex-1">{children}</main>
    </div>
  )
}

Parallel Routes

Render multiple pages simultaneously:

// app/dashboard/@analytics/page.tsx
// app/dashboard/@metrics/page.tsx

// app/dashboard/layout.tsx
export default function Layout({
  children,
  analytics,
  metrics,
}: {
  children: React.ReactNode
  analytics: React.ReactNode
  metrics: React.ReactNode
}) {
  return (
    <div>
      {children}
      <div className="grid grid-cols-2">
        {analytics}
        {metrics}
      </div>
    </div>
  )
}

Intercepting Routes

Show modals while preserving URL context:

// app/photos/[id]/page.tsx - Full page view
// app/@modal/(.)photos/[id]/page.tsx - Modal intercept

// Soft navigation shows modal
// Hard navigation/refresh shows full page

Anti-Patterns to Refactor

God Component

Problem: One component handles data fetching, state, and UI. Solution: Split into Server Component (data) + Client Components (interactivity).

// BAD: God Component
'use client'
function ProductPage({ id }) {
  const [product, setProduct] = useState(null)
  const [cart, setCart] = useState([])
  const [loading, setLoading] = useState(true)

  useEffect(() => {
    fetch(`/api/products/${id}`)
      .then(r => r.json())
      .then(setProduct)
      .finally(() => setLoading(false))
  }, [id])

  // 200+ more lines...
}

// GOOD: Separated concerns
// app/products/[id]/page.tsx (Server Component)
async function ProductPage({ params }) {
  const product = await getProduct(params.id)
  return (
    <div>
      <ProductDetails product={product} />
      <AddToCartButton productId={params.id} />
    </div>
  )
}

Prop Drilling

Problem: Passing props through many component layers. Solution: Use React Context, Server Component composition, or URL state.

// BAD: Prop drilling
<Page user={user}>
  <Layout user={user}>
    <Sidebar user={user}>
      <Avatar user={user} />

// GOOD: Context or composition
// Option 1: Context for Client Components
const UserContext = createContext<User | null>(null)

// Option 2: Server Component composition
async function Sidebar() {
  const user = await getUser() // Fetch where needed
  return <Avatar user={user} />
}

Unnecessary 'use client'

Problem: Marking components as Client when not needed. Solution: Only use 'use client' for interactivity, keep it as low as possible.

// BAD: Entire page is Client Component
'use client'
function Dashboard() {
  // Only the button needs to be client
  return <div><Header /><Content /><Button /></div>
}

// GOOD: Only interactive parts are Client Components
function Dashboard() {
  return (
    <div>
      <Header />
      <Content />
      <InteractiveButton /> {/* Only this has 'use client' */}
    </div>
  )
}

useEffect for Data Fetching

Problem: Using useEffect + useState for initial data fetch. Solution: Use Server Components for data fetching.

// BAD: useEffect pattern
'use client'
function Posts() {
  const [posts, setPosts] = useState([])
  useEffect(() => {
    fetch('/api/posts').then(r => r.json()).then(setPosts)
  }, [])
  return posts.map(p => <Post key={p.id} {...p} />)
}

// GOOD: Server Component
async function Posts() {
  const posts = await db.post.findMany()
  return posts.map(p => <Post key={p.id} {...p} />)
}

Refactoring Process

Step 1: Analyze Current State

  1. Identify all 'use client' directives - are they necessary?
  2. Find data fetching patterns (useEffect, getServerSideProps)
  3. Map component hierarchy and prop flow
  4. Check for God Components doing too much
  5. Review caching and revalidation strategies

Step 2: Plan Refactoring

  1. Determine which components can be Server Components
  2. Identify the minimal Client Component boundaries
  3. Plan data flow and composition patterns
  4. Design Suspense boundaries for streaming
  5. Consider parallel data fetching opportunities

Step 3: Execute Refactoring

  1. Convert useEffect data fetching to Server Components
  2. Push 'use client' down to leaf components
  3. Extract reusable Server Actions
  4. Add proper Suspense boundaries
  5. Implement caching strategies
  6. Add proper TypeScript types

Step 4: Validate Changes

  1. Verify Server/Client boundaries are correct
  2. Test streaming and loading states
  3. Check bundle size improvements
  4. Validate SEO with proper metadata
  5. Test error boundaries

Output Format

When refactoring, provide:

  1. Analysis Summary: Brief overview of issues found
  2. Refactoring Plan: Steps to be taken
  3. Code Changes: Show before/after with explanations
  4. File Structure: New/modified file paths
  5. Verification Steps: How to validate changes work

Quality Standards

Performance

  • Minimize 'use client' usage
  • Use streaming for long data fetches
  • Implement proper caching
  • Optimize images with next/image
  • Use next/font for fonts

Maintainability

  • Clear separation of Server/Client concerns
  • Small, focused components (< 100 lines)
  • Consistent file organization
  • TypeScript for type safety

User Experience

  • Loading states with Suspense
  • Error boundaries for graceful failures
  • Optimistic updates for mutations
  • Progressive enhancement

When to Stop Refactoring

Stop when:

  • All unnecessary 'use client' directives are removed
  • Data fetching is in Server Components
  • Components follow single responsibility
  • Proper caching is implemented
  • Loading and error states are handled
  • Code is readable and maintainable
  • No prop drilling exists
  • Bundle size is optimized

Do NOT over-engineer:

  • Simple pages don't need complex patterns
  • Not everything needs to be abstracted
  • Premature optimization is the root of evil
  • Working code that's readable is good enough

平台分布

Claude Code

29.76%
按下载量换算104

OpenCode

24.93%
按下载量换算88

Cursor

15.83%
按下载量换算56

Antigravity

11.49%
按下载量换算40

windsurf

6.87%
按下载量换算24

Codex

3.15%
按下载量换算11

安全审计

暂无安全审计结果可展示。

权限和风险

权限未标注

当前来源未能明确判断权限范围,默认进入异常复核队列。

安装前确认

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

继续浏览同类 Skills