技能 nextjs-15-specialist

nextjs-15-specialist

低风险 📁 文件系统访问⚡ 包含脚本⚙️ 外部命令🌐 网络访问

正確實作 Next.js 15 App Router 模式

Next.js 15 引入了新的模式,容易被用錯。此技能提供 App Router、Server Components、Server Actions 與快取策略的完整指引,讓代理一次就能正確建置。

支持: Claude Codex Code(CC)
⚠️ 67
1

下载技能 ZIP

2

在 Claude 中上传

前往 设置 → 功能 → 技能 → 上传技能

3

开启并开始使用

测试它

正在使用“nextjs-15-specialist”。 Create a Server Action that creates a new project with name and description fields.

预期结果:

  • Server Action: createProject(formData)
  • - Validates input with Zod schema
  • - Creates project in database
  • - Revalidates /projects path
  • - Returns success with created project
  • - Includes authentication check
  • - Handles errors with try-catch

正在使用“nextjs-15-specialist”。 Convert this page to use proper cache strategy. It should refresh product data every hour.

预期结果:

  • Update fetch() with revalidate option
  • cache: 'force-cache' for base caching
  • next: { revalidate: 3600 } for hourly refresh
  • Add revalidateTag for manual invalidation
  • Document cache behavior in comments

安全审计

低风险
v5 • 1/16/2026

Documentation-only skill containing markdown guides and a Python static analyzer validator. The 786 static findings are all false positives triggered by code examples in documentation. The validate-patterns.py script only reads files for pattern validation, with no network calls, credential access, or code execution capabilities. All 'backtick execution' detections are markdown code fences, not Ruby shell commands. All 'fetch' and 'URL' detections are documentation examples, not runtime network calls.

8
已扫描文件
6,496
分析行数
5
发现项
5
审计总数
低风险问题 (1)
Static analysis tool reads source files
validate-patterns.py uses open() to read .tsx, .ts, .jsx, .js files for pattern validation. Standard static analysis behavior with no modifications.
审计者: claude 查看审计历史 →

质量评分

38
架构
100
可维护性
85
内容
21
社区
88
安全
87
规范符合性

你能构建什么

建置 Next.js 15 應用程式

從一開始就以正確的 App Router 模式建立新的 Next.js 15 應用程式。

實作伺服器端變更

建立具備適當驗證、驗證機制與錯誤處理的 Server Actions。

最佳化資料擷取

設定快取策略、重新驗證與串流以獲得最佳效能。

试试这些提示

建立頁面
Create a new Next.js 15 page at /projects that fetches and displays a list of projects using Server Components.
新增互動性
Create a Client Component that allows users to delete a project using a Server Action with proper loading and error states.
最佳化快取
Add proper caching to our product pages. Products should be cached for 1 hour and revalidated when inventory updates.
新增 metadata
Add dynamic metadata to our blog post pages including Open Graph images, Twitter cards, and JSON-LD structured data.

最佳实践

  • 預設使用 Server Components,只有在需要互動性時才加入 'use client'
  • 對 fetch 呼叫一律指定快取策略(force-cache、no-store 或 revalidate)
  • Server Action 驗證使用 Zod 並清理所有使用者輸入
  • 實作適當的 error boundary 與 loading state 以提升使用者體驗

避免

  • Async Client Components - 會造成建置錯誤與效能問題
  • 使用 <img> 取代 next/image 的 <Image> - 會破壞建置與最佳化
  • fetch 呼叫缺少快取策略 - 快取行為不可預期
  • Server Actions 未做驗證檢查 - 安全性漏洞

常见问题

此技能涵蓋哪些 Next.js 15 功能?
App Router、Server Components、Server Actions、資料擷取、快取、metadata API、route handlers 與串流。
包含多少程式碼範例?
超過 150 個實用範例,涵蓋所有主要的 Next.js 15 模式與真實情境用例。
此技能可以修改我的程式碼庫嗎?
不會。此技能提供指引,而選用的 Python 驗證器僅會讀取檔案進行靜態分析。
使用驗證器時我的資料安全嗎?
是。Python 腳本只會讀取 .tsx、.ts、.jsx、.js 檔案並輸出驗證結果,不會傳輸任何資料。
為什麼我會收到 'useState is not valid in Server Components'?
Server Components 不能使用 useState 等 React hooks。請在檔案最上方、imports 之前加入 'use client' 指令。
這與 Next.js 14 模式相比如何?
Next.js 15 透過 useActionState、更好的 async params 處理,以及強化的快取 API 改善了 Server Actions。此技能涵蓋所有新模式。