用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/Aradotso/devtools-skills --skill next-devtools-mcp-skill命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Sync DeviantArt galleries to local folders with OAuth 2.1 PKCE, SQLite indexing, and scheduled syncs using da-cli
Use oh-my-cli to run an autonomous code agent that can read/write files, execute shell commands, and manage multi-turn coding tasks with approval gates and session persistence
CLI tool that detects AI-written text patterns using 33 Wikipedia-documented signs, with draft checking and humanization prompts — zero dependencies
基于 SOC 职业分类
正在显示 SKILL.md
| name | next-devtools-mcp-skill |
| description | Expert in using next-devtools-mcp for Next.js development with AI coding agents |
| triggers | ["help me debug my Next.js application","set up Next.js DevTools MCP","upgrade my Next.js app to version 16","enable Cache Components in Next.js","search Next.js documentation","show me Next.js runtime diagnostics","what errors are in my Next.js app","analyze my Next.js routes structure"] |
Skill by ara.so — Devtools Skills collection.
Expert skill for using next-devtools-mcp, a Model Context Protocol (MCP) server that provides Next.js development tools and utilities for AI coding agents. Provides runtime diagnostics, documentation search, browser automation, and development workflow automation for Next.js projects.
next-devtools-mcp is an MCP server that gives AI coding agents powerful Next.js development capabilities:
Install for all detected AI coding agents in your project:
npx add-mcp next-devtools-mcp@latest
Add -y to skip confirmation. Add -g for global installation across all projects.
Add to your MCP client configuration file:
{
"mcpServers": {
"next-devtools": {
"command": "npx",
"args": ["-y", "next-devtools-mcp@latest"]
}
}
}
Claude Code / Claude Desktop:
claude mcp add next-devtools npx next-devtools-mcp@latest
Cursor: Click: Install in Cursor
Or manually: Cursor Settings → MCP → New MCP Server
Codex:
codex mcp add next-devtools -- npx next-devtools-mcp@latest
For Windows 11, update .codex/config.toml:
env = { SystemRoot="C:\\Windows", PROGRAMFILES="C:\\Program Files" }
startup_timeout_ms = 20_000
VS Code / Copilot:
code --add-mcp '{"name":"next-devtools","command":"npx","args":["-y","next-devtools-mcp@latest"]}'
CRITICAL: Call the init tool at the start of every Next.js session:
Use the init tool to set up Next.js DevTools context
This establishes proper documentation requirements and context. For automation, add to your agent's configuration:
.claude/CLAUDE.md or .cursorrules:
When starting work on a Next.js project, ALWAYS call the `init` tool from
next-devtools-mcp FIRST to set up proper context and establish documentation
requirements. Do this automatically without being asked.
For Next.js 16+ projects:
npm run dev
# or
pnpm dev
MCP is enabled by default at http://localhost:3000/_next/mcp. The next-devtools-mcp server auto-discovers and connects.
Initialize Next.js DevTools MCP context. Call this first in every session.
// Tool input schema
{
project_path?: string // Optional, defaults to current directory
}
Example prompts:
What it does:
nextjs_docs for all queries)Search and retrieve official Next.js documentation.
// Search for docs
{
action: "search",
query: string, // e.g., "metadata", "generateStaticParams"
routerType?: "app" | "pages" | "all" // default: "all"
}
// Get full doc content
{
action: "get",
path: string, // e.g., "/docs/app/api-reference/functions/refresh"
anchor?: string // e.g., "usage"
}
Example workflow:
Search Next.js docs for generateMetadata
Agent uses:
nextjs_docs with action: "search", query: "generateMetadata"nextjs_docs with action: "get", path: "/docs/app/api-reference/functions/generate-metadata"Common searches:
Query available runtime diagnostic resources from Next.js 16+ dev server.
// No input required
{}
Example prompts:
Output: List of available resource URIs (errors, routes, logs, etc.)
Call a specific runtime diagnostic resource from Next.js 16+ dev server.
{
uri: string // Resource URI from nextjs_index
}
Example workflows:
Check for errors:
Next Devtools, what errors are in my Next.js application?
Agent calls: nextjs_call with uri: "nextjs://errors"
View route structure:
Next Devtools, show me the structure of my routes
Agent calls: nextjs_call with uri: "nextjs://routes"
Check dev server logs:
Next Devtools, what's in the development server logs?
Agent calls: nextjs_call with uri: "nextjs://logs"
Common URIs:
nextjs://errors - Runtime errors and warningsnextjs://routes - App Router route structurenextjs://logs - Development server logsnextjs://config - Next.js configurationnextjs://env - Environment variablesAutomate browser testing with Playwright. Use for verifying pages, testing interactions, and detecting runtime issues.
// Start browser
{
action: "start",
browser?: "chrome" | "firefox" | "webkit" | "msedge", // default: "chrome"
headless?: boolean // default: true
}
// Navigate to URL
{
action: "navigate",
url: string
}
// Click element
{
action: "click",
selector: string // CSS selector
}
// Type text
{
action: "type",
selector: string,
text: string
}
// Fill form
{
action: "fill_form",
fields: Array<{ selector: string; value: string }>
}
// Execute JavaScript
{
action: "evaluate",
script: string
}
// Take screenshot
{
action: "screenshot",
path?: string // default: auto-generated
}
// Get console messages
{
action: "console_messages"
}
{
:
}
Example workflow - Test Next.js page:
Test the homepage at localhost:3000 and take a screenshot
Agent executes:
// 1. Start browser
{ action: "start", headless: true }
// 2. Navigate
{ action: "navigate", url: "http://localhost:3000" }
// 3. Wait for content
{ action: "evaluate", script: "document.querySelector('h1')?.textContent" }
// 4. Screenshot
{ action: "screenshot" }
// 5. Check for errors
{ action: "console_messages" }
// 6. Clean up
{ action: "close" }
Common patterns:
Verify upgrade (Next.js 15 → 16):
Verify that my app works on localhost:3000 after the upgrade
Test navigation:
Test navigating from home to /about page
Check for hydration errors:
Load the page and check for React hydration errors in the console
Important: For Next.js 16+, prefer nextjs_index and nextjs_call over browser_eval console messages for error detection.
Guide for upgrading from Next.js 15 to Next.js 16.
Help me upgrade my Next.js app to version 16
What it does:
package.jsonEnable Cache Components mode in Next.js 16.
Enable Cache Components in my Next.js app
What it does:
cache: "components" to next.config.ts"use cache" directiveThe MCP server includes focused documentation resources automatically available to agents:
Cache Components (12 sections):
cache-components://overviewcache-components://core-mechanicscache-components://public-cachescache-components://private-cachescache-components://runtime-prefetchingcache-components://request-apiscache-components://cache-invalidationcache-components://advanced-patternscache-components://build-behaviorcache-components://error-patternscache-components://test-patternscache-components://referenceMigration Guides:
nextjs16://migration/beta-to-stablenextjs16://migration/examplesFundamentals:
nextjs-fundamentals://use-clientResources are loaded on-demand by the agent as needed.
User request:
My Next.js app shows a blank page. Help me figure out what's wrong.
Agent workflow:
// 1. Initialize (if not done)
init({ project_path: "." })
// 2. Check runtime errors
nextjs_call({ uri: "nextjs://errors" })
// Output shows: "ReferenceError: window is not defined at Component.render"
// 3. Search docs for server component issues
nextjs_docs({
action: "search",
query: "window is not defined server component"
})
// 4. Get full doc content
nextjs_docs({
action: "get",
path: "/docs/app/building-your-application/rendering/server-components"
})
// 5. Provide solution: Add "use client" directive
User request:
Upgrade my app to Next.js 16 and enable Cache Components
Agent workflow:
// 1. Initialize
init({ project_path: "." })
// 2. Use upgrade prompt
// Triggers: upgrade-nextjs-16 prompt
// - Updates package.json
// - Runs codemods
// - Updates config
// 3. Enable Cache Components
// Triggers: enable-cache-components prompt
// - Adds cache: "components" to next.config.ts
// - Shows migration examples
// 4. Verify with browser
browser_eval({ action: "start" })
browser_eval({ action: "navigate", url: "http://localhost:3000" })
browser_eval({ action: "console_messages" })
browser_eval({ action: "screenshot" })
browser_eval({ action: "close" })
// 5. Check runtime state
nextjs_call({ uri: "nextjs://errors" })
User request:
Add proper SEO metadata to my blog post page
Agent workflow:
// 1. Search docs
nextjs_docs({
action: "search",
query: "generateMetadata"
})
// 2. Get detailed docs
nextjs_docs({
action: "get",
path: "/docs/app/api-reference/functions/generate-metadata"
})
// 3. Implement based on docs
Example implementation:
// app/blog/[slug]/page.tsx
import { Metadata } from 'next'
interface Props {
params: { slug: string }
}
export async function generateMetadata({ params }: Props): Promise<Metadata> {
const post = await fetch(`${process.env.API_URL}/posts/${params.slug}`)
.then(res => res.json())
return {
title: post.title,
description: post.excerpt,
openGraph: {
title: post.title,
description: post.excerpt,
images: [{ url: post.image }],
},
}
}
export default async function BlogPost({ params }: Props) {
const post = await fetch(`${process.env.API_URL}/posts/`)
.( res.())
(
)
}
User request:
Convert my data fetching component to use Cache Components
Before (traditional approach):
// app/posts/page.tsx
export const revalidate = 3600
export default async function PostsPage() {
const posts = await fetch('https://api.example.com/posts')
.then(res => res.json())
return (
<div>
{posts.map(post => (
<article key={post.id}>
<h2>{post.title}</h2>
</article>
))}
</div>
)
}
Agent searches docs:
nextjs_docs({
action: "search",
query: "use cache directive"
})
// Then gets resource
// (agent has cache-components://core-mechanics available)
After (Cache Components):
// app/posts/page.tsx
import { Posts } from './Posts'
export default function PostsPage() {
return <Posts />
}
// app/posts/Posts.tsx
"use cache"
export const revalidate = 3600
export async function Posts() {
const posts = await fetch('https://api.example.com/posts')
.then(res => res.json())
return (
<div>
{posts.map(post => (
<article key={post.id}>
<h2>{post.title}</h2>
</article>
))}
</div>
)
}
import type { NextConfig } from 'next'
const config: NextConfig = {
experimental: {
cache: 'components', // Enable Cache Components
},
}
export default config
Use environment variables for API keys and sensitive data:
# .env.local
API_URL=https://api.example.com
NEXTAUTH_SECRET=your-secret-here
NEXTAUTH_URL=http://localhost:3000
Access in code:
const apiUrl = process.env.API_URL
const secret = process.env.NEXTAUTH_SECRET
Next.js 16+ automatically enables MCP at:
http://localhost:{PORT}/_next/mcp
No configuration needed. The next-devtools-mcp server discovers it automatically.
Symptoms: nextjs_index returns empty or nextjs_call fails
Solution:
npm list nextnpm run devnext.config.ts for custom port)Symptoms: nextjs_docs with action: "search" returns empty
Solution:
routerType: "all" to search both App and Pages Router docsSymptoms: browser_eval with action: "start" times out
Solution:
.codex/config.tomlnpx playwright install chromiumSymptoms: Agent doesn't use Next.js docs properly, context is missing
Solution:
Symptoms: Breaking changes after running upgrade-nextjs-16 prompt
Solution:
nextjs_docs to verify migration patternsbrowser_eval before deployingnextjs://errors for runtime issuesAlways use nextjs_docs before implementing Next.js features:
// Search first
nextjs_docs({ action: "search", query: "feature-name" })
// Get detailed docs
nextjs_docs({ action: "get", path: "/docs/..." })
// Then implement based on official documentation
For Next.js 16+ projects, prefer built-in diagnostics:
// ✅ Preferred
nextjs_call({ uri: "nextjs://errors" })
// ❌ Avoid when above is available
browser_eval({ action: "console_messages" })
Browser automation is still valuable for visual verification and interaction testing.
Make init the first tool call:
// At start of every Next.js session
init({ project_path: "." })
Or automate with agent configuration (see Core Workflow).
Don't skip the search step:
// Step 1: Search to find relevant docs
nextjs_docs({ action: "search", query: "..." })
// Step 2: Get full content from search results
nextjs_docs({ action: "get", path: "..." })
This ensures you get the most relevant and up-to-date documentation.
After making changes, use a combination:
// 1. Check runtime errors
nextjs_call({ uri: "nextjs://errors" })
// 2. Visual verification
browser_eval({ action: "start" })
browser_eval({ action: "navigate", url: "http://localhost:3000" })
browser_eval({ action: "screenshot" })
browser_eval({ action: "close" })
// 3. Check routes structure
nextjs_call({ uri: "nextjs://routes" })
Recognize and handle these user requests:
nextjs_call for errorsnextjs_docs two-step workflowbrowser_eval workflownextjs_call with nextjs://errorsnextjs_call with nextjs://routesnextjs_call with nextjs://logsgenerateMetadatanextjs_docs to find config docsThe next-devtools-mcp skill enables AI coding agents to:
init tool (critical first step)nextjs_docsnextjs_index and nextjs_callbrowser_eval using PlaywrightAlways prioritize documentation lookup over assumptions, verify changes with runtime diagnostics, and test thoroughly with browser automation.