使用可重用的、带作用域的指令控制代理模型的行为。
.cursor/rules ,由版本控制并作用域于您的代码库。
.cursor/rules 。每个规则都是一个文件,并受到版本控制。它们可以通过路径模式进行作用域划定,手动调用,或根据相关性包含。子目录可以包含自己的 .cursor/rules 目录,该目录作用于该文件夹。
.mdc )格式编写,支持元数据和内容。通过类型下拉菜单控制规则的应用,该菜单会改变属性 description 、 globs 、 alwaysApply 。
| 规则类型 | 描述 |
|---|---|
Always | 始终包含在模型上下文中 |
Auto Attached | 在引用匹配某个 glob 模式的文件时包含 |
Agent Requested | 对 AI 可用,由 AI 决定是否包含。必须提供描述信息 |
Manual | 仅在明确使用 @ruleName 时才包含。 |
@service-template.ts 会在规则触发时作为附加上下文包含在内。
.cursor/rules 目录中进行组织。当引用其目录中的文件时,嵌套规则会自动附加。
New Cursor Rule 命令或导航到 Cursor Settings > Rules 来创建规则。这将在 .cursor/rules 中创建一个新的规则文件。在设置中,你可以查看所有规则及其状态。

/Generate Cursor Rules 命令生成规则。当你已对代理行为做出决策并希望重复使用时,这非常有用。
前端组件和 API 验证标准
Express 服务和 React 组件的模板
自动化开发流程和文档生成
npm run dev
在 Cursor 中添加新设置
@reactiveStorageTypes.ts.Add default value in INIT_APPLICATION_USER_PERSISTENT_STORAGE in @reactiveStorageService.tsx.For beta features, add toggle in @settingsBetaTab.tsx, otherwise add in @settingsGeneralTab.tsx. Toggles can be added as <SettingsSubSection> for general checkboxes. Look at the rest of the file for examples..cursorrules (遗产).cursorrules 文件仍然受到支持,但将被弃用。我们建议迁移到项目规则,以获得更多控制、灵活性和可见性。
为什么我的规则没有被应用?
Agent Requested, ensure a description is defined. For Auto Attached, ensure the file pattern matches referenced files.
规则可以引用其他规则或文件吗?
@filename.ts to include files in your rule’s context.
我可以通过聊天创建规则吗?
/Generate Cursor Rules command. If Memories are enabled, memories are generated automatically.
规则会影响 Cursor 标签页或其他 AI 功能吗?