nuxt-code-editor
遵循项目标准生成和修改 Vue 3、TypeScript 和 SCSS 代码。
When & Why to Use This Skill
The Nuxt Code Editor skill is a specialized development tool designed to automate the creation and modification of Vue 3, TypeScript, and SCSS code within Nuxt.js projects. It ensures high-quality, production-ready output by strictly adhering to modern standards such as the Composition API, PrimeVue integration, and Zod validation. By focusing on incremental editing and standardized API patterns, it helps developers maintain a consistent, type-safe, and internationalized codebase while significantly reducing manual boilerplate work.
Use Cases
- Scaffolding Vue 3 components: Automatically generate script setup components using PrimeVue and BEM-compliant SCSS styling with built-in i18n support.
- Building Type-Safe APIs: Create server-side API handlers using defineEventHandler that incorporate Zod schema validation and TypeORM entities for robust data management.
- Incremental Code Refactoring: Modify existing TypeScript or Vue files using a patching approach to preserve existing context and logic while implementing new features.
- Enforcing Project Standards: Ensure all new code follows specific architectural rules, such as using PUT for updates, standardized pagination formats, and avoiding circular dependencies.
- Authentication Integration: Streamline the implementation of frontend and backend auth logic using Better-Auth (authClient and auth) within the Nuxt ecosystem.
| name | nuxt-code-editor |
|---|---|
| description | 遵循项目标准生成和修改 Vue 3、TypeScript 和 SCSS 代码。 |
| version | 1.0.0 |
| author | GitHub Copilot |
| applyTo | "**/*.{ts,vue,scss}" |
Nuxt Code Editor Skill (Nuxt 代码编辑技能)
能力 (Capabilities)
- Vue 3 Composition API: 生成
<script setup lang="ts">组件。 - PrimeVue 集成: 根据
utils/或现有的components/用法正确使用 PrimeVue 组件。 - Better-Auth 集成: 正确使用
authClient(前端) 和auth(服务端) 进行身份验证和权限控制。 - 类型安全: 确保所有后端代码使用在
server/database/entities或types/中定义的 TypeORM 实体和 DTO。 - Zod 校验: 使用 Zod 进行 API 请求参数校验 (参考
utils/schemas/)。 - 增量编辑: 优先修补 (patch) 而非重写整个文件,以保留上下文。
指令 (Instructions)
- 代码风格指南: 遵守 ESLint 和 Prettier 配置。样式使用 SCSS,并适用 BEM 命名约定。
- 组件标准: 使用
defineProps,defineEmits并配合 TypeScript 接口/类型。 - 后端标准:
- 确保
server/api处理程序使用defineEventHandler并返回标准化响应 (参考docs/standards/api.md)。 - 禁止使用 PATCH 方法,所有更新操作应使用 PUT 方法。
- 列表类接口必须返回统一的分页格式:
items(数据列表),total(总条数),page,limit,totalPages。
- 确保
- 国际化 (I18n): 所有 UI 字符串必须包裹在
$t()中。 - 文件: 创建文件时,确保它们位于正确的 Nuxt 目录 (
components,composables,server/api等) 中。 - 依赖约束: 遵循
docs/standards/development.md中的依赖关系约束,避免循环依赖。
使用示例 (Usage Example)
输入: "创建一个按钮组件。"
动作: 使用 PrimeVue Button 生成 components/base/AppButton.vue,并在 TS 接口中定义 props。
输入: "创建一个获取文章列表的 API。"
动作: 在 server/api/posts.get.ts 中使用 defineEventHandler 和 typeorm 的 Repository 获取数据。