Skip to content
cccskills
FreePublished on GitHub

fec-nuxt-project-standard

用于创建或审查 Nuxt 3 项目、文件路由、pages、layouts、SSR/SSG/SPA 行为、Nuxt 数据获取、route middleware、plugins、modules、server routes 或 Nuxt 特定 Vue 3 约定。

通用 Vue 组件架构另按项目 Vue 约定处理;中文触发词包括 Nuxt、Nuxt 3。

The English summary is being prepared. Showing the original description.

Run score Not tested

See how to install

Files included (1)

  • SKILL.md4.4 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Nuxt 3 项目规范

适用于使用 Nuxt 3 + Vue 3 + TypeScript 的仓库。

用途

规范 Nuxt 3 项目中 SSR/SSG 渲染模式、组合式 API、自动导入、数据获取、路由中间件和模块插件的工程实践,确保约定式开发和类型安全。

流程

  1. 先识别目标属于 Nuxt pages/layouts、渲染模式、数据获取、route middleware、plugin/module 还是 server route。
  2. 明确 SSR / SSG / SPA 选择,避免服务端可执行代码依赖 window 或 document。
  3. 数据获取优先使用 Nuxt 的 useFetch / useAsyncData,并检查水合一致性。
  4. 路由鉴权、redirect 和权限问题与路由保护 workflow 对齐。
  5. 通用 Vue 组件架构问题分流到 Vue 项目 workflow。

项目结构

├── app.vue                    # 根组件
├── nuxt.config.ts              # Nuxt 配置
│
├── pages/                     # 基于文件的路由
│   ├── index.vue               # /
│   ├── login.vue               # /login
│   ├── dashboard/
│   │   ├── index.vue           # /dashboard
│   │   └── users/
│   │       ├── index.vue       # /dashboard/users
│   │       └── [id].vue       # /dashboard/users/:id
│   └── [...slug].vue          # 捕获所有
│
├── layouts/                   # 布局
│   ├── default.vue
│   └── auth.vue
│
├── components/                # 自动导入组件
│   ├── Button/
│   │   └── Button.vue
│   └── AppHeader.vue
│
├── composables/               # 组合式函数(自动导入)
│   ├── useAuth.ts
│   └── useFetch.ts
│
├── server/                    # 服务端 API
│   ├── api/                   # API 路由
│   │   └── users/
│   │       └── index.get.ts
│   ├── middleware/            # 服务端中间件
│   └── utils/                 # 服务端工具
│
├── plugins/                   # 插件
│   └── i18n.client.ts
│
├── middleware/                # 路由中间件
│   └── auth.ts
│
├── public/                    # 静态资源
├── assets/                    # 需构建的资源
└── types/                     # 类型定义

渲染模式

模式配置说明
SSR默认ssr: true
SSGnuxt generate预渲染所有页面
SPAssr: false纯客户端渲染
// nuxt.config.ts
export default defineNuxtConfig({
  ssr: true, // 或 false
});

数据获取

  • useFetch / useAsyncData:服务端 + 客户端,自动去重
  • $fetch:直接请求,适合服务端或一次性调用
  • useLazyAsyncData:不阻塞导航,适合非首屏
  • 避免在 setup 顶层混用同步/异步逻辑导致水合不匹配

路由与布局

  • pages/ 下文件自动生成路由
  • 动态路由:[id].vue、[...slug].vue
  • 布局:layout 选项或 layouts/default.vue 默认
  • 嵌套路由:pages/parent/child.vue 需配合 NuxtPage

中间件

  • middleware/ 下文件自动注册
  • 页面级:definePageMeta({ middleware: ['auth'] })
  • 全局:nuxt.config.ts 的 router.middleware
  • 服务端中间件:server/middleware/

插件与模块

  • 插件:plugins/*.ts,支持 .client、.server 后缀
  • 模块:modules/ 或 node_modules,在 nuxt.config 中 modules: []

约束

  • 服务端可访问的代码不要依赖 window、document
  • 使用 useState 共享状态时注意 SSR 序列化
  • 图片使用 NuxtImg,链接使用 NuxtLink
  • 避免在 setup 顶层使用 await 导致阻塞,优先用 useAsyncData / useFetch

预期输出

  • 页面按 pages/ 约定式路由组织,动态路由正确配置
  • 渲染模式(SSR/SSG/SPA)选择正确,nuxt.config.ts 配置清晰
  • 数据获取使用 useFetch / useAsyncData,自动去重和水合
  • Composables 和组件自动导入正确,服务端/客户端边界清晰

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

用于审查或改进前端无障碍、语义结构、键盘支持、焦点管理、ARIA 标签、屏幕阅读器行为、WCAG 2.2 问题、触控无障碍或辅助技术回归;中文触发词包括 无障碍、accessibility、a11y、WCAG、屏幕阅读器。

The English summary is being prepared. Showing the original description.

bovinphang/frontend-craft22Updated Sep 26, 2026

Use when reviewing or improving frontend accessibility, semantic structure, keyboard support, focus management, ARIA labels, screen reader behavior, WCAG 2.2 issues, touch accessibility, or assistive-technology regressions; Chinese triggers include accessibility, accessibility, a11y, WCAG, screen reader.

The English summary is being prepared. Showing the original description.

bovinphang/frontend-craft22Updated Sep 26, 2026

Use when absorbing ideas, capabilities, workflows, architecture, quality systems, ecosystem extensions, or engineering practices from any reference system into the current project through original, project-native redesign rather than copying.

The English summary is being prepared. Showing the original description.

bovinphang/frontend-craft22Updated Sep 26, 2026

用于从参考系统中吸收想法、能力、工作流、架构、质量体系、生态扩展或工程实践,并通过原创的项目内重设计转化为当前项目能力,而不是复制原实现。

The English summary is being prepared. Showing the original description.

bovinphang/frontend-craft22Updated Sep 26, 2026

用于设计、实现或审查前后端 API 集成、类型化 API client、REST/tRPC/OpenAPI 客户端选型、认证刷新、API 错误映射、上传流程、SSE/WebSocket/轮询选择、CORS 相关前端行为或跨边界 loading/error 状态。不要用于纯后端服务架构或仅 TanStack Query 缓存策略;中文触发词包括 API 集成、前后端联调、typed API client、接口错误处理、SSE、WebSocket。

The English summary is being prepared. Showing the original description.

bovinphang/frontend-craft22Updated Sep 26, 2026

Use when designing, implementing, or reviewing frontend-to-backend API integration, typed API clients, REST/tRPC/OpenAPI client choices, auth refresh, API error mapping, upload flows, SSE/WebSocket/polling choices, CORS-facing frontend behavior, or cross-boundary loading/error states. Do not use for backend-only service architecture or TanStack Query cache policy alone; Chinese triggers include API integration, front-end and back-end joint debugging, typed API client, Interface error handling, SSE, WebSocket.

The English summary is being prepared. Showing the original description.

bovinphang/frontend-craft22Updated Sep 26, 2026

See all skills by bovinphang

Report a problem with this skill