Communitygithub.com

Anhvu1107/all-agent-skill

當使用者提及 Next.js 最佳實踐、要求建置、除錯、審查、文件化、自動化、測試、設定、遷移或在此領域做出決策,或任務明顯依賴 Next.js 最佳實踐時,一律使用此技能;範圍:Next.js App Router 原則。在最終輸出前,套用配套的工作流程、參考資料、腳本、高階大師標準及 Codex 嚴格審查關卡。

all-agent-skill 是什麼?

此技能為 AI 代理器(如 Claude Code、Cursor、Codex)提供了一套完整的 Next.js 最佳實踐指南,專注於 App Router 架構。它涵蓋了伺服器與用戶端元件的決策樹、資料擷取模式(靜態、ISR、動態)、路由原則(檔案約定、路由群組、平行路由)、API 路由處理、效能最佳化(圖片與套件)、中繼資料管理、快取策略、伺服器操作以及常見反模式。該技能強調以伺服器元件為預設,僅在必要時使用用戶端元件,以提升應用程式的效能與可維護性。支援的範圍包括建置、除錯、審查、文件化、自動化、測試、設定和遷移等任務。它透過選擇性閱讀規則,引導代理器先載入關鍵參考文件(高階大師標準、使用路由、品質檢查清單),再根據實際任務載入其他相關資源。此技能旨在協助開發者遵循 Next.js 官方推薦的現代開發模式,避免常見陷阱,並確保程式碼品質與專案結構的一致性。

相容平台~Claude Code✓Codex CLI~Cursor
npx skills add https://github.com/Anhvu1107/all-agent-skill/tree/HEAD/.agent/skills/nextjs-best-practices

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Next.js 最佳實踐

選擇性閱讀規則

從以下開始:

  • references/senior-master-standard.md
  • references/usage-routing.md
  • references/quality-checklist.md

然後僅載入與使用者實際任務相符的繼承文件、腳本、資產或範例。

Next.js App Router 開發原則。


1. 伺服器元件 vs 用戶端元件

決策樹

是否需要...?
│
├── useState、useEffect、事件處理函式
│   └── 用戶端元件('use client')
│
├── 直接資料擷取,無互動性
│   └── 伺服器元件(預設)
│
└── 兩者都需要?
    └── 拆分:伺服器父元件 + 用戶端子元件

預設情況

類型用途
伺服器資料擷取、佈局、靜態內容
用戶端表單、按鈕、互動式 UI

2. 資料擷取模式

擷取策略

模式用途
預設靜態(在建置時快取)
重新驗證ISR(基於時間的重新整理)
不儲存動態(每次請求)

資料流

來源模式
資料庫伺服器元件擷取
API使用快取的 fetch
使用者輸入用戶端狀態 + 伺服器操作

3. 路由原則

檔案慣例

檔案用途
page.tsx路由 UI
layout.tsx共用佈局
loading.tsx載入狀態
error.tsx錯誤邊界
not-found.tsx404 頁面

路由組織

模式用途
路由群組 (name)組織但不影響 URL
平行路由 @slot多個同層級頁面
攔截路由 (.)模態視窗覆蓋層

4. API 路由

路由處理常式

方法用途
GET讀取資料
POST建立資料
PUT/PATCH更新資料
DELETE刪除資料

最佳實踐

  • 使用 Zod 驗證輸入
  • 回傳正確的狀態碼
  • 優雅地處理錯誤
  • 盡可能使用 Edge 執行時期

5. 效能原則

圖片最佳化

  • 使用 next/image 元件
  • 為摺疊以上內容設定優先權
  • 提供模糊佔位圖
  • 使用響應式尺寸

套件最佳化

  • 對重量級元件使用動態導入
  • 基於路由的程式碼分割(自動)
  • 使用套件分析器進行分析

6. 中繼資料

靜態 vs 動態

類型用途
靜態匯出固定中繼資料
generateMetadata每條路由動態產生

必要標籤

  • title(50-60 字元)
  • description(150-160 字元)
  • Open Graph 圖片
  • 標準網址 (Canonical URL)

7. 快取策略

快取層級

層級控制
請求fetch 選項
資料revalidate / tags
完整路由路由設定

重新驗證

方法用途
基於時間revalidate: 60
按需revalidatePath / revalidateTag
無快取no-store

8. 伺服器操作

使用案例

  • 表單提交
  • 資料變異
  • 觸發重新驗證

最佳實踐

  • 標記為 'use server'
  • 驗證所有輸入
  • 回傳型別化的回應
  • 處理錯誤

9. 反模式

❌ 避免✅ 應採用
到處使用 'use client'預設使用伺服器元件
在用戶端元件中擷取資料在伺服器元件中擷取
跳過載入狀態使用 loading.tsx
忽略錯誤邊界使用 error.tsx
大型用戶端套件使用動態導入

10. 專案結構

app/
├── (marketing)/     # 路由群組
│   └── page.tsx
├── (dashboard)/
│   ├── layout.tsx   # 儀表板佈局
│   └── page.tsx
├── api/
│   └── [resource]/
│       └── route.ts
└── components/
    └── ui/

切記: 伺服器元件是預設選擇,原因在此。從伺服器元件開始,僅在需要時才加入用戶端元件。

使用時機

此技能適用於執行概述中所述的工作流程或動作。

限制

  • 僅在任務明確符合上述範圍時使用此技能。
  • 請勿將輸出視為環境特定驗證、測試或專家審查的替代方案。
  • 如果缺少必要的輸入、權限、安全邊界或成功標準,請停止並要求釐清。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches 007: Security audit, hardening, threat modeling (STRIDE/PASTA), Red/Blue Team, OWASP checks, code review, incident response, and infrastructure security for any project.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Agentfolio: Skill for discovering and researching autonomous AI agents, tools, and ecosystems using the AgentFolio directory.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Animejs Animation: Advanced JavaScript animation library skill for creating complex, high-performance web animations.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Astropy: Astropy is the core Python package for astronomy, providing essential functionality for astronomical research and data analysis.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Astro: Build content-focused websites with Astro — zero JS by default, islands architecture, multi-framework components, and Markdown/MDX support.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Emotional ARC Designer: One sentence - what this skill does and when to invoke it

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Fixing Motion Performance: Audit and fix animation performance issues including layout thrashing, compositor properties, scroll-linked motion, and blur effects.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches I18n Localization: Internationalization and localization patterns.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Interactive Portfolio: Expert in building portfolios that actually land jobs and clients - not just showing work, but creating memorable experiences.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches JQ: Expert jq usage for JSON querying, filtering, transformation, and pipeline integration.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Landing Page Generator: Generates high-converting Next.js/React landing pages with Tailwind CSS.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches LEX: Centralized ''Truth Engine'' for cross-jurisdictional legal context (US, EU, CA) and contract scaffolding.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Magic Animator: AI-powered animation tool for creating motion in logos, UI, icons, and social media assets.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Makepad Animation: CRITICAL: Use for Makepad animation system.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Nextjs APP Router Patterns: Comprehensive patterns for Next.js 14+ App Router architecture, Server Components, and modern full-stack React development.

Anhvu1107/all-agent-skill

description: ALWAYS use this when the work is specifically about modern Next.js or React architecture, data flow, rendering strategy, routing, or performance-sensitive frontend behavior.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Nextjs Supabase Auth: Expert integration of Supabase Auth with Next.js App Router

Anhvu1107/all-agent-skill

ALWAYS use this when the task involves reading, extracting, splitting, merging, rotating, creating, validating, OCR-ing, form-filling, or otherwise producing or modifying PDF files.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches React Nextjs Development: React and Next.js 14+ application development with App Router, Server Components, TypeScript, Tailwind CSS, and modern frontend patterns.

Anhvu1107/all-agent-skill

ALWAYS use this when working with Remotion code, video compositions, rendering logic, timing, media assets, or React-based motion workflows.

相關技能