.cursor/rules/project.mdc
--- description: Project rules for Next.js globs: ["**/*"] alwaysApply: true --- # Cursor Project Rules ## Project Context - Project type: Next.js - Tech stack: Next.js, TypeScript, React, CSS modules - Coding style: Prefer small components, explicit types, accessible UI, and existing project patterns. - AI tool target: Cursor Rules 生成器 ## Project Commands - Package manager: npm - Test: `npm test` - Build: `npm run build` - Lint: `npm run lint` ## How Cursor Should Work - Inspect existing patterns before adding new abstractions. - Keep edits scoped to the requested behavior. - Prefer typed, accessible, maintainable code. - Run targeted checks before final handoff when possible. - If a command fails, report the exact failure and the likely next step. ## Extra Instructions Before handoff, summarize changed files and mention any checks that could not be run.
使用 Cursor Rules 生成器创建起步 .cursor/rules/project.mdc,让 Cursor 与仓库约定保持一致。好的规则会写明真实命令、文件 globs、代码风格和 AI 应避免的错误。
什么是好的 Cursor Rule
好的 Cursor Rules 具体且有范围。它会说明规则适用哪些文件、应该复用哪些模式,以及这个区域的改动需要哪些验证命令。
如何维护 Cursor Rules
当代码结构变化,或开发者反复纠正同一种 AI 行为时,就应该审查规则。只有当一个项目级文件过宽时,才按 package 或文件类型拆分。
常见问题
Cursor Rules 放在哪里?
项目规则通常放在 .cursor/rules 下,常见起点是 project.mdc。
规则能只匹配部分文件吗?
可以。用 globs 把规则限制到 package、框架或文件类型。