Cursor Next.js 编码规范

Model: qwen-max | ¥0.15/call
AI工具GPT-4.1智能助手CursorNext.js

Cursor Next.js 编码规范:来自 PatrickJS/awesome-cursorrules (40k stars) 的 nex,适用于各类文档与内容的智能化处理。

Calls: 1

Skill Documentation

Cursor Next.js 编码规范

摘要

Cursor Next.js 编码规范:来自 PatrickJS/awesome-cursorrules (40k stars) 的 nex,适用于各类文档与内容的智能化处理。

**文件来源:** PatrickJS/awesome-cursorrules → `rules/nextjs-supabase-shadcn-pwa-cursorrules-prompt-file.mdc`

**原仓库:** https://github.com/PatrickJS/awesome-cursorrules

**评分:** ⭐ 仓库 40k stars (社区最权威 Cursor rules 合集)

这个 skill 是干什么的?

把 `nextjs-supabase-shadcn-pwa-cursorrules-prompt-file.mdc` 这条 Cursor 编码规则打包成可调用的 AI skill,帮你把代码生成统一到一致的标准上。

> Cursor rules for Nextjs Supabase Shadcn Pwa.

🤖 Agent 使用说明

👤 用户需要做什么?

适用场景

原始规则内容

globs: **/*
alwaysApply: false
---
## Key Principles

- **Code Quality & Style**

  - Write concise, maintainable, and strongly typed code with accurate TypeScript implementations.
  - Embrace functional, declarative programming. Avoid OOP and classes.
  - Limit files to a maximum of 150 lines; refactor into smaller modules if exceeded.
  - Prefer iteration and modularization over duplication.
  - Use descriptive, semantic variable names with auxiliary verbs (e.g., `isLoading`, `hasError`).
  - Use lowercase with dashes for directories and files (e.g., `components/auth-wizard`).
  - Favor named exports for components.
  - Adopt RORO (Receive an Object, Return an Object) for function parameters/returns.
  - Always attain to use DRY (Don't Repeat Yourself) principles.
  - Conduct regular code reviews and frequent refactoring sessions to ensure consistency and quality.
  - Check and improve Web Vitals (LCP, CLS, FID) to maintain performance and user experience.

- **Create 'Build Notes':**

  - You must create a 'Build Notes' file for each task group to track the progress of the task group we work on.
  - **Clarity & Brevity:** Keep notes concise, direct, and focused on the task at hand.
  - **Logical Naming:** Use a consistent naming convention that ties each notes file to a specific task and date.
  - **Incremental Updates:** Update notes as plans evolve or tasks are completed. Append rather than overwrite.
  - **Traceability:** Ensure that each decision or change in approach is recorded and easy to follow.

- **Review 'Project Contexts':**

  - You must review the `projectContext.md` as we need to ensure that the project context is up to date and accurate.
  - **Stability:** Treat context files as stable references, not daily scratchpads.
  - **Selective Updates:** Update context files only when there are significant, approved changes to requirements or project scope.
  - **Accessibility:** Make context files easily understandable and organized so future developers can quickly grasp the project’s core guidance.

- **Stack and Framework Conventions**

  - Target **Next.js 15+** and leverage the App Router, React Server Components (RSC), and SSR capabilities.
  - Use Zustand for state management in client components when necessary.
  - Maintain proper Shadcn UI management using `npx shadcn@latest add` for new components.
  - Follow a mobile-first approach and responsive design patterns.
  - Emphasize server-side logic, minimizing the usage of `use client` and other client-only APIs.
  - Structure project as Progressive Web App (PWA) with offline capabilities, app-like experience, and installability across devices.

- **Monorepo & Tooling**

  - If using a monorepo structure, place shared code in a `packages/` directory and app-specific code in `app/`.
  - Use `Taskfile.yml` commands for development, testing, and deployment tasks.
  - Keep environment variables and sensitive data outside of code and access them through `.env` files or similar config

...(完整内容在原仓库)...

数据来源

联系方式

有问题或建议,在本 skill 下留言。

FAQ

这个 skill 是干什么的?

把 `nextjs-supabase-shadcn-pwa-cursorrules-prompt-file.mdc` 这条 Cursor 编码规则打包成可调用的 AI skill,帮你把代码生成统一到一致的标准上。

> Cursor rules for Nextjs Supabase Shadcn Pwa.

👤 用户需要做什么?
  • [ ] 知道这条规则适合用在什么场景(参考下面"适用场景")
  • [ ] 把规则原文内容应用到 IDE 项目的 `.cursor/rules/` 目录(直接复制 .mdc 文件)
  • [ ] 调本 skill 时说清楚你的代码任务(语言/框架/目标)
  • [ ] 输出后人工 review 风格是否符合预期