Token导航 LogoToken导航TokenDH.com
研究检索敏感数据github未标认证来源可访问许可证需确认审计通过

nextjs-architectureNext.js 架构

Agent Skill

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

总安装

509

周安装

21

GitHub Stars

3

下载量

166
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/alpoxdev/hypercore --skill nextjs-architecture

简介

nextjs-architecture 用于强制执行 Next.js 官方架构规范,确保路由与组件边界合规。

  • 适用于审查或生成 React/Next.js 代码,支持 App Router 与 Server Component 校验。
  • 基于框架文档作为权威依据,优先遵循官方而非本地自定义规则。
  • 安装前需确认项目为有效 Next.js 工程且已启用 App Router。
  • 注意不处理样式或构建细节,仅聚焦架构层面验证。

SKILL.md

Next.js Architecture Enforcement

Overview

Enforces official Next.js architecture rules before code changes. Validate that the target is actually a Next.js project, determine whether App Router is in use, then apply strict rules for routing, Server and Client Component boundaries, server-first data fetching, Server Actions, Route Handlers, Proxy, and environment setup.

This skill is official-first. Treat the Next.js documentation as the source of truth. If a repo-local convention is stricter than the framework, label it clearly instead of silently presenting it as a framework rule.

OPERATING MODE: This skill is self-contained. Do not block on external orchestration just to apply architecture rules. If the user wants exhaustive verification, keep verifying. Otherwise proceed with this skill's own validation flow.

IMPORTANT: App Router is the default path for this skill. If the repo is Pages Router only, apply only the shared platform and boundary checks and do not force App Router-only file conventions unless the user is migrating or explicitly adding app/.

IMPORTANT: Prefer Server Actions for internal UI writes, especially forms and app-originated mutations. Use Route Handlers when the surface is genuinely HTTP-native, such as webhooks, feeds, CORS-sensitive endpoints, or machine-readable/public endpoints.

IMPORTANT: Treat every Server Action as a reachable POST entry point. Validation, authentication, authorization, and return-value filtering must happen inside the action or the delegated server-only data layer, not only in the page that renders the form.

Quick Surface Chooser

Use this table before reading the full gates:

If the task sounds like...Default surfaceDo not default to...
Add a form or internal app mutation in App RouterServer Actionroute.ts
Add a webhook, feed, CORS endpoint, or public machine-readable endpointRoute HandlerServer Action
Fetch initial page data for UIServer ComponentClient-first fetching without a real need
Need redirect logic before render across many requestsnext.config.* or Proxy, with Proxy lastServer Action
Client Component imports DB code or private envmove the code behind a server-only boundaryleaving secrets in client-reachable code
Pages Router only repo and no migration requestedshared Next.js safety checks onlyforcing App Router file conventions

If the task matches one of these rows, start there, then read the linked rule file in Step 2 for detail.

Trigger Examples

Positive

  • Audit this Next.js app before I add more App Router routes.
  • Refactor a Next.js feature so Server Components, client boundaries, caching, and server actions follow the official docs.
  • Add a Next.js Route Handler or Server Action and keep the architecture compliant.

Negative

  • Create a generic React architecture guide.
  • Review a Remix or TanStack Start app.

Boundary

  • Make a tiny copy-only text change in a Next.js page. Direct editing can be enough if no architectural boundary is affected, but touched files still need a quick boundary check.
  • This repo is Pages Router only and I am not migrating to App Router. This skill still applies for shared Next.js platform, env, and boundary checks, but App Router-specific file rules must be relaxed.

Step 1: Project Validation

Before any work, confirm a Next.js project and detect router mode:

rg -n '"next"' package.json
find . -maxdepth 3 \( -path './app' -o -path './src/app' -o -path './pages' -o -path './src/pages' \)
test -f next.config.ts -o -f next.config.mjs -o -f next.config.js

Interpretation:

  • No next dependency found: stop, this skill does not apply.
  • app/ or src/app/ present: full App Router mode.
  • pages/ or src/pages/ present without App Router: shared Next.js mode only.
  • Mixed app/ and pages/: prefer App Router rules for touched app/ code and avoid breaking legacy pages/ code without explicit migration intent.

Step 2: Read Architecture Rules

Load the detailed rules reference:

REQUIRED: Read architecture-rules.md in this skill directory before writing code.

Then read the relevant rule files for the change:

  • rules/routes.md - App Router structure, special files, route groups, private folders, and segment boundaries
  • rules/execution-model.md - Server vs Client Components, use client, providers, serializable props, and server-only
  • rules/data-fetching.md - server data fetching, streaming, cache intent, dynamic rendering triggers, and revalidation
  • rules/server-actions.md - use server, validation, auth, authz, DAL delegation, revalidation, redirect ordering, and side-effect rules
  • rules/route-handlers.md - when route.ts is justified, method handling, caching defaults, and HTTP-only surfaces
  • rules/platform.md - environment variables, next.config.*, typedRoutes, Proxy, and deployment-sensitive setup

If framework behavior may have drifted, also read:

  • references/official/nextjs-docs.md - official doc map for the rules this skill depends on

Step 3: Pre-Change Validation Checklist

Before writing any code, verify the planned change against these gates:

Brownfield Adoption Rule

  • Do not treat every untouched legacy deviation as an immediate project-wide failure.
  • Safety and boundary issues still block immediately, especially in touched files.
  • Legacy pages/ code can remain in place when the task is local and non-migratory.
  • Any file you touch should be brought into compliance unless that would require a materially risky migration.

Gate 1: Routing and File Conventions

CheckRule
page.tsx, layout.tsx, loading.tsx, error.tsx, not-found.tsx, or route.ts placed outside the expected segment structure?BLOCKED
route.ts and page.tsx created at the same route segment?BLOCKED
App Router feature work done in pages/ even though app/ already exists for that surface?BLOCKED unless explicitly requested
Route groups or private folders used without understanding URL impact?WARNING. (group) does not affect URL, _folder stays private
Segment needs loading/error/not-found UX but no boundary exists?WARNING. Add loading.tsx, error.tsx, or not-found.tsx intentionally

Gate 2: Server and Client Boundaries

CheckRule
Interactive component missing 'use client'?BLOCKED
'use client' added high in the tree without need?BLOCKED. Keep client boundaries as narrow as possible
Client Component imports server-only code, secrets, DB clients, or process.env private values?BLOCKED
Server-only helper missing import 'server-only' or equivalent protected placement?WARNING. Add a clear server-only boundary
Client Component props include broad DB records or non-serializable values?BLOCKED
Context provider placed at the document root when a deeper boundary works?WARNING. Render providers as deep as possible

Gate 3: Data Fetching and Caching

CheckRule
Initial page data fetched in a Client Component when a Server Component can do it?BLOCKED unless there is a real client-only need
Layout reads uncached runtime data and blocks same-segment loading.tsx without a closer <Suspense> boundary?BLOCKED
Cache behavior is accidental or unclear?BLOCKED. Choose and explain the cache strategy
Sensitive or privileged reads happen outside a DAL/server-only module without justification?WARNING for prototypes, BLOCKED for production-oriented code
Mutation completes without revalidatePath, revalidateTag, redirect, or another freshness strategy where the UI depends on new data?BLOCKED

Gate 4: Server Actions

CheckRule
Internal UI mutation or form submit implemented with route.ts even though a Server Action fits?BLOCKED unless real HTTP semantics are required
Action trusts form data, params, headers, or search params without validation or re-verification?BLOCKED
Action relies only on page-level auth checks?BLOCKED. Re-authorize inside the action
Action returns raw database rows or broad internal objects?BLOCKED
Action performs DB or secret-heavy work directly when a server-only DAL exists or should exist?WARNING for small code, BLOCKED for repeated domain logic
Action mutates during rendering instead of from an explicit action path (form, event, transition)?BLOCKED
redirect() called before required revalidation?BLOCKED. Revalidate first, then redirect

Gate 5: Route Handlers and Proxy

CheckRule
Internal UI mutation implemented as route.ts even though a Server Action fits better?BLOCKED unless real HTTP semantics are required
Route Handler used for webhooks, feeds, CORS, or public machine endpoints?ALLOWED
Route Handler uses NextResponse.next() to forward like Proxy?BLOCKED
Proxy added when redirects, rewrites, headers, or render-time logic would be enough?BLOCKED. Proxy is last resort
proxy.ts not placed at project root or src/ root level next to app or pages?BLOCKED
Proxy matcher is missing or too broad for the actual need?BLOCKED

Gate 6: Platform and Environment

CheckRule
.env* files assumed to load from src/?BLOCKED. They belong at project root
Client code reads non-NEXT_PUBLIC_ env vars?BLOCKED
Runtime client env needed but treated as build-time inlined config?BLOCKED. Expose via server path/API instead
Multi-proxy or reverse-proxy deployment uses Server Actions without checking serverActions.allowedOrigins needs?WARNING
Next config toggles caching, routing, or server action behavior without clear intent?BLOCKED
Typed route safety would materially reduce routing mistakes but typedRoutes is ignored in a TypeScript codebase?WARNING. Consider enabling it intentionally

Step 3.5: Auto-Remediation Policy

Auto-fix directly when the issue is local, reversible, and low-risk.

  • narrow an overly broad 'use client' boundary
  • add loading.tsx, error.tsx, or not-found.tsx for a touched segment
  • move privileged reads into a server-only helper or DAL
  • add server-only markers and tighten client props
  • add missing revalidation after a Server Action mutation
  • move a misused internal route.ts mutation to a Server Action when the change is small and local
  • tighten Proxy matcher scope or move simple redirects into next.config.*
  • correct .env / NEXT_PUBLIC_ usage and explicit config wiring

Do not auto-apply broad or potentially breaking migrations without explicit justification.

  • mass route tree rewrites
  • Pages Router to App Router migrations across large surfaces
  • sweeping cache model changes
  • turning many Route Handlers into Server Actions in one pass
  • deployment-sensitive Server Action origin or encryption-key changes

Step 4: Implementation

Carry these acceptance criteria into the active task:

- [ ] Next.js project mode validated before editing
- [ ] App Router rules applied only where they actually fit
- [ ] Routing files live in the correct route segment structure
- [ ] Server and Client Component boundaries are explicit and minimal
- [ ] Client code cannot reach server-only data, env, or modules
- [ ] Data fetching and caching strategy is intentional
- [ ] Server Actions are the default surface for internal UI writes
- [ ] Server Actions validate input, re-authorize, and return minimal data
- [ ] Route Handlers exist only for real HTTP-native needs
- [ ] Proxy is used only when simpler surfaces are insufficient
- [ ] Environment handling and next.config setup are boundary-safe

Step 5: Post-Change Verification

After writing code, verify:

  1. project mode still matches the edited surface (app/, pages/, or mixed)
  2. route segment file placement is valid
  3. 'use client' boundaries are as small as possible
  4. client code does not import server-only modules or private env
  5. data freshness after mutations is explicit (revalidatePath, revalidateTag, redirect flow, or documented alternative)
  6. Route Handlers and Proxy usage are still justified
  7. next.config.*, env loading, and deployment-sensitive settings remain coherent

Quick Reference: App Router Shape

app/
├── layout.tsx
├── page.tsx
├── dashboard/
│   ├── page.tsx
│   ├── loading.tsx
│   ├── error.tsx
│   ├── not-found.tsx
│   ├── _components/
│   └── _lib/
├── api/
│   └── webhooks/
│       └── route.ts
└── (marketing)/
    └── about/
        └── page.tsx

Key meaning:

  • (group) organizes routes without affecting the URL
  • _folder is a private implementation folder and does not become a route segment
  • route.ts is for HTTP handling, not page UI
  • loading.tsx, error.tsx, and not-found.tsx are route-segment boundaries, not general-purpose components

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.33%
按下载量换算60

Claude

31.63%
按下载量换算53

Cursor

19.45%
按下载量换算32

Gemini CLI

9.08%
按下载量换算15

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

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

来源信息

继续浏览同类 Skills