---
title: "Cursor Project Rules (.cursor/rules/*.mdc)：路径和格式 · DotsAgent"
description: ".cursor/rules/*.mdc 的存放位置、格式和 front matter，全局副本与嵌套副本的合并方式，以及哪些工具会读取它。核验日期：2026-10-01。"
url: https://dotsagent.io/zh/instructions/files/cursor-rules
---

.cursor/rules/*.mdc

# Cursor Project Rules (.cursor/rules/*.mdc)：存放位置及工具读取方式

Cursor Project Rules 是存放在 .cursor/rules/ 中的 .mdc 文件，其 frontmatter 决定每条规则何时生效。Cursor 也会读取 AGENTS.md，以及在仓库外设置的 User Rules 和 Team Rules。

## 存放位置

- .cursor/rules/**/*.mdc，可包含子目录；.cursor/rules 中的普通 .md 文件会被忽略。
- 根目录及嵌套文件夹中的 AGENTS.md。
- 在 Cursor 设置中配置的 User Rules。
- 在团队控制面板中配置的 Team Rules。

## 格式

使用带 YAML frontmatter 的 Markdown，且必须使用 .mdc 扩展名。alwaysApply: true 表示始终应用该规则；alwaysApply: false 时，只有匹配的文件位于上下文中，globs 才会触发该规则；仅设置 description 时，由 Agent 决定是否应用。若未设置这些字段，则只有通过 @ 提及该规则时才会应用。

Front matter 键： `description``globs``alwaysApply`

`.cursor/rules/*.mdc`

```
---
description: React component conventions
globs: src/components/**/*.tsx
alwaysApply: false
---

- One component per file, with a named export matching the file name.
- Type props with an interface named after the component plus Props.
- Use the existing CSS modules; no inline style objects.
- Follow @src/components/Button.tsx as the reference pattern.
```

## 优先级与合并

依次为 Team Rules、Project Rules、User Rules。所有适用规则会合并；发生冲突时，优先采用顺序靠前的来源；强制执行的 Team Rules 无法关闭。嵌套的 AGENTS.md 会与父级文件合并，具体范围更窄的文件优先。

## 可读取该文件的工具

| 工具 | 支持情况 |
| --- | --- |
| [Cline](https://docs.cline.bot/features/cline-rules) | 可检测旧版 .cursorrules 文件。 |

## 提示

- 在 globs 字段中使用逗号分隔多个 glob 模式。
- 每条规则控制在 500 行以内，并使用 @filename 引用文件，而不要直接粘贴文件内容。
- 规则不会影响 Cursor Tab，User Rules 也不适用于 Inline Edit。
- Cursor 文档已不再提及旧版 .cursorrules 文件；请将其移至 .cursor/rules/。

通过一个表单，为五种工具生成 AGENTS.md 和对应的规则文件。 [打开 AGENTS.md 生成器 →](https://dotsagent.io/zh/instructions)

## 其他指令文件

[AGENTS.md](https://dotsagent.io/zh/instructions/files/agents-md)

[CLAUDE.md](https://dotsagent.io/zh/instructions/files/claude-md)

[GEMINI.md](https://dotsagent.io/zh/instructions/files/gemini-md)

[.github/copilot-instructions.md](https://dotsagent.io/zh/instructions/files/github-copilot-instructions)

[.devin/rules/*.md](https://dotsagent.io/zh/instructions/files/windsurf-rules)

[.clinerules/](https://dotsagent.io/zh/instructions/files/cline-rules)

[~/.openclaw/workspace/AGENTS.md](https://dotsagent.io/zh/instructions/files/openclaw-workspace)

## 来源

1. [cursor.com](https://cursor.com/docs/context/rules)/docs/context/rules

为 AI agent 开发者提供的独立参考资料。与此处提及的任何厂商均无关联。

© 2026 DotsAgent · 事实核查日期：2026年10月1日
