suggesting-cursor-rules

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Suggesting Cursor Rules

建议创建Cursor规则

Watch for repeated corrections and frustration. When the user keeps telling you the same thing, suggest a
.cursor/rules/
file so they never have to say it again.
留意用户重复的修正和不满情绪。当用户反复提及同一要求时,建议创建一个
.cursor/rules/
文件,这样他们就再也不用重复说明该要求了。

Triggers

触发场景

Suggest a rule when you notice:
  • The user corrects the same pattern 2+ times (e.g. "use named exports", "don't use default exports")
  • The user expresses frustration about code style or conventions
  • The user says things like "I always want...", "never do...", "every time you..."
  • You keep making the same mistake in this project
当你注意到以下情况时,建议创建规则:
  • 用户多次(2次及以上)修正同一模式(例如“使用具名导出”“不要使用默认导出”)
  • 用户对代码风格或约定表达不满
  • 用户说出类似“我一直希望……”“永远不要……”“每次你都……”的话
  • 你在该项目中反复犯同样的错误

How to Suggest

建议方式

When you detect a trigger, offer it naturally:
I notice you've corrected me on [pattern] a couple times. Want me to 
create a Cursor rule so I always follow this convention?
If they say yes, create the rule:
.cursor/rules/<name>.mdc
---
description: <what this rule enforces>
globs: <file pattern this applies to>
---

- <the convention, stated clearly>
当检测到触发场景时,自然地提出建议:
我注意到你已经多次纠正我关于[模式]的问题了。要不要我创建一条Cursor规则,让我以后始终遵循这个约定?
如果用户同意,就创建规则:
.cursor/rules/<name>.mdc
---
description: <该规则的约束内容>
globs: <适用的文件模式>
---

- <清晰表述约定内容>

Examples

示例

User keeps saying "use relative imports":
---
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/...")
User keeps saying "no comments on obvious code":
---
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
User frustrated about test file locations:
---
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
用户反复要求“使用相对导入”:
---
description: 导入约定
globs: **/*.{ts,tsx}
---

- 使用相对导入,而非@别名
- 从同一包导入时使用相对路径(例如"../../queries/..."而非"src/queries/...")
用户反复要求“不对明显代码添加注释”:
---
description: 注释风格
globs: **/*.{ts,tsx,js,jsx}
---

- 不要添加解释代码功能的注释
- 仅对非显而易见的意图、权衡或约束添加注释
用户对测试文件位置不满:
---
description: 测试文件约定
globs: **/*.test.{ts,tsx}
---

- 测试文件与对应的源文件放在同一目录下
- 测试文件命名为<source>.test.ts,而非__tests__/<source>.ts

Rules

规则要点

  • Don't be annoying — only suggest after a genuine repeated pattern, not on the first correction
  • Keep rule files small and focused — one concern per file
  • Check
    .cursor/rules/
    first so you don't duplicate an existing rule
  • Frame it as a helpful offer, not a lecture
  • 不要惹人厌烦——只有在确实出现重复模式时才建议,第一次修正时不要提
  • 规则文件要简洁聚焦——每个文件只处理一个关注点
  • 先检查
    .cursor/rules/
    目录,避免重复创建已有的规则
  • 以提供帮助的语气提出建议,不要说教