Loading...
Loading...
Compare original and translation side by side
app/app/| If the task sounds like... | Default surface | Do not default to... |
|---|---|---|
| Server Action | |
| Route Handler | Server Action |
| Server Component | Client-first fetching without a real need |
| | Server Action |
| move the code behind a server-only boundary | leaving secrets in client-reachable code |
| shared Next.js safety checks only | forcing App Router file conventions |
| 如果任务描述类似... | 默认选用方案 | 不建议默认选用... |
|---|---|---|
| Server Action | |
| Route Handler | Server Action |
| Server Component | 无实际需求却优先使用客户端获取 |
| | Server Action |
| 将代码迁移至服务端专属边界后 | 将敏感信息留在客户端可访问代码中 |
| 仅执行Next.js通用安全检查 | 强制应用App Router文件约定 |
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.在我添加更多App Router路由之前,审核这个Next.js应用。重构Next.js功能,确保Server Components、客户端边界、缓存和Server Actions符合官方文档要求。添加Next.js Route Handler或Server Action,并保持架构合规。Create a generic React architecture guide.Review a Remix or TanStack Start app.创建通用React架构指南。审核Remix或TanStack Start应用。Make a tiny copy-only text change in a Next.js page.This repo is Pages Router only and I am not migrating to App Router.在Next.js页面中进行微小的纯文本修改。这个仓库仅使用Pages Router,且我不打算迁移到App Router。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.jsnextapp/src/app/pages/src/pages/app/pages/app/pages/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.jsnextapp/src/app/pages/src/pages/app/pages/app/pages/architecture-rules.mdrules/routes.mdrules/execution-model.mduse clientserver-onlyrules/data-fetching.mdrules/server-actions.mduse serverrules/route-handlers.mdroute.tsrules/platform.mdnext.config.*typedRoutesreferences/official/nextjs-docs.mdarchitecture-rules.mdrules/routes.mdrules/execution-model.mduse clientserver-onlyrules/data-fetching.mdrules/server-actions.mduse serverrules/route-handlers.mdroute.tsrules/platform.mdnext.config.*typedRoutesreferences/official/nextjs-docs.mdpages/pages/| Check | Rule |
|---|---|
| BLOCKED |
| BLOCKED |
App Router feature work done in | BLOCKED unless explicitly requested |
| Route groups or private folders used without understanding URL impact? | WARNING. |
| Segment needs loading/error/not-found UX but no boundary exists? | WARNING. Add |
| 检查项 | 规则 |
|---|---|
| 阻止操作 |
在同一路由分段下同时创建 | 阻止操作 |
已存在对应 | 阻止操作(除非明确要求) |
| 使用路由组或私有文件夹但未理解其对URL的影响? | 警告。 |
| 分段需要加载/错误/未找到页面的UX,但未设置对应边界? | 警告。需主动添加 |
| Check | Rule |
|---|---|
Interactive component missing | BLOCKED |
| BLOCKED. Keep client boundaries as narrow as possible |
Client Component imports server-only code, secrets, DB clients, or | BLOCKED |
Server-only helper missing | 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 |
| 检查项 | 规则 |
|---|---|
交互式组件缺少 | 阻止操作 |
无需求却在组件树高层添加 | 阻止操作。尽量缩小客户端边界范围 |
Client Component导入服务端专属代码、敏感信息、数据库客户端或 | 阻止操作 |
服务端专属助手未添加 | 警告。添加明确的服务端专属边界 |
| Client Component的props包含完整数据库记录或不可序列化值? | 阻止操作 |
| 上下文提供者放置在文档根节点,但可在更深处设置边界? | 警告。尽量在较深层级渲染提供者 |
| Check | Rule |
|---|---|
| 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 | 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 | BLOCKED |
| 检查项 | 规则 |
|---|---|
| 可通过Server Component获取初始页面数据,却在Client Component中获取? | 阻止操作(除非确实有客户端专属需求) |
布局读取未缓存的运行时数据,且未设置更接近的 | 阻止操作 |
| 缓存行为意外或不明确? | 阻止操作。需选择并说明缓存策略 |
| 敏感或特权读取操作未在DAL/服务端专属模块中执行且无合理理由? | 原型项目警告,面向生产的代码阻止操作 |
变更完成后,UI依赖新数据但未执行 | 阻止操作 |
| Check | Rule |
|---|---|
Internal UI mutation or form submit implemented with | 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 ( | BLOCKED |
| BLOCKED. Revalidate first, then redirect |
| 检查项 | 规则 |
|---|---|
内部UI变更或表单提交使用 | 阻止操作(除非确实需要HTTP语义) |
| Action信任表单数据、参数、请求头或查询参数,未进行验证或重新验证? | 阻止操作 |
| Action仅依赖页面级认证检查? | 阻止操作。需在Action内部重新授权 |
| Action返回原始数据库行或完整内部对象? | 阻止操作 |
| 已有或应存在服务端专属DAL的情况下,Action仍直接执行数据库或敏感操作? | 小型代码警告,重复领域逻辑阻止操作 |
Action在渲染期间而非通过明确的Action路径( | 阻止操作 |
在必要的重新验证前调用 | 阻止操作。先重新验证,再重定向 |
| Check | Rule |
|---|---|
Internal UI mutation implemented as | BLOCKED unless real HTTP semantics are required |
| Route Handler used for webhooks, feeds, CORS, or public machine endpoints? | ALLOWED |
Route Handler uses | BLOCKED |
Proxy added when | BLOCKED. Proxy is last resort |
| BLOCKED |
| Proxy matcher is missing or too broad for the actual need? | BLOCKED |
| 检查项 | 规则 |
|---|---|
内部UI变更使用 | 阻止操作(除非确实需要HTTP语义) |
| Route Handlers用于webhook、订阅源、CORS或公开机器端点? | 允许操作 |
Route Handlers使用 | 阻止操作 |
可通过 | 阻止操作。Proxy为最后选择 |
| 阻止操作 |
| Proxy匹配器缺失或范围远超实际需求? | 阻止操作 |
| Check | Rule |
|---|---|
| BLOCKED. They belong at project root |
Client code reads non- | 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 | WARNING |
| Next config toggles caching, routing, or server action behavior without clear intent? | BLOCKED |
Typed route safety would materially reduce routing mistakes but | WARNING. Consider enabling it intentionally |
| 检查项 | 规则 |
|---|---|
假设 | 阻止操作。此类文件应放置在项目根目录 |
客户端代码读取非 | 阻止操作 |
| 需要运行时客户端环境变量,但将其视为构建时内联配置? | 阻止操作。应通过服务端路径/API暴露 |
多代理或反向代理部署中使用Server Actions,但未检查 | 警告 |
| Next配置切换缓存、路由或Server Action行为,但未明确说明意图? | 阻止操作 |
TypeScript代码库中启用 | 警告。建议主动启用 |
'use client'loading.tsxerror.tsxnot-found.tsxserver-onlyroute.tsnext.config.*.envNEXT_PUBLIC_'use client'loading.tsxerror.tsxnot-found.tsxserver-onlyroute.tsnext.config.*.envNEXT_PUBLIC_- [ ] 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- [ ] 编辑前已验证Next.js项目模式
- [ ] App Router规则仅在适用场景下应用
- [ ] 路由文件放置在正确的路由分段结构中
- [ ] Server与Client Component边界明确且范围最小
- [ ] 客户端代码无法访问服务端专属数据、环境变量或模块
- [ ] 数据获取与缓存策略明确
- [ ] 内部UI写入操作默认使用Server Actions
- [ ] Server Actions验证输入、重新授权并返回最小化数据
- [ ] Route Handlers仅用于真正的HTTP原生场景
- [ ] 仅在更简单方案无法满足需求时才使用Proxy
- [ ] 环境处理与next.config配置符合边界安全要求app/pages/'use client'revalidatePathrevalidateTagnext.config.*app/pages/'use client'revalidatePathrevalidateTagnext.config.*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(group)_folderroute.tsloading.tsxerror.tsxnot-found.tsxapp/
├── layout.tsx
├── page.tsx
├── dashboard/
│ ├── page.tsx
│ ├── loading.tsx
│ ├── error.tsx
│ ├── not-found.tsx
│ ├── _components/
│ └── _lib/
├── api/
│ └── webhooks/
│ └── route.ts
└── (marketing)/
└── about/
└── page.tsx(group)_folderroute.tsloading.tsxerror.tsxnot-found.tsx