关于 suggesting-cursor-rules
面向 Cursor 的技能,用于发现用户反复提出的代码风格或项目约定,并建议将其保存为 `.cursor/rules/` 规则。它要求先检查是否已有规则,并避免对单次反馈作出建议。
主要功能
- 01识别重复纠正和风格反馈
- 02建议创建 Cursor 规则文件
- 03按单一主题保持规则精简
- 04检查现有规则以避免重复
- 05仅在持续模式出现后提出建议
适用场景
- 01记录反复强调的导入约定
- 02保存代码注释风格偏好
- 03固定测试文件位置和命名惯例
- 04将项目约定写入 Cursor 规则
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ spencerpauly/ awesome-cursor-skills --skill suggesting-cursor-rules安装后在 Claude Code 中输入/suggesting-cursor-rules确认已加载。
详细介绍
建议使用 Cursor Rules
留意反复出现的纠正和沮丧情绪。当用户不断重复同样的要求时,建议创建 .cursor/rules/ 文件,这样他们就不必再说一遍。
触发条件
注意到以下情况时,建议创建规则:
- 用户对同一种模式纠正了 2 次或更多次(例如“使用命名导出”“不要使用默认导出”)
- 用户对代码风格或约定表示沮丧
- 用户说“我总是希望……”“绝不要……”“每次你……”之类的话
- 你在这个项目中反复犯同样的错误
如何提出建议
发现触发条件时,自然地提出建议:
I notice you've corrected me on [pattern] a couple times. Want me to
create a Cursor rule so I always follow this convention?
如果对方同意,就创建规则:
.cursor/rules/<name>.mdc
---
description: <what this rule enforces>
globs: <file pattern this applies to>
---
- <the convention, stated clearly>
示例
用户反复说“使用相对导入”:
---
description: Import conventions
globs: **/*.{ts,tsx}
---
- Use relative imports, not @ aliases
- Import from the same package with relative paths (e.g. "../../queries/..." not "src/queries/...")
用户反复说“显而易见的代码不要加注释”:
---
description: Comment style
globs: **/*.{ts,tsx,js,jsx}
---
- Do not add comments that narrate what the code does
- Only comment non-obvious intent, tradeoffs, or constraints
用户对测试文件的位置感到沮丧:
---
description: Test file conventions
globs: **/*.test.{ts,tsx}
---
- Co-locate test files next to the source file they test
- Name test files <source>.test.ts, not __tests__/<source>.ts
规则
- 不要惹人烦——只有在确实出现重复模式时才提出建议,不要在第一次纠正后就提
- 规则文件应简短且专注——每个文件只关注一个问题
- 先检查
.cursor/rules/,避免重复创建现有规则 - 把它作为贴心建议提出,而不是说教
评论
支持 Markdown