maintain-project-rules
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesemaintain-project-rules
维护项目规则
Activation gate
触发条件
Use if:
- User asks to audit or maintain project rules, check prefix convention, or sync doc/rules.md.
- Context involves , rule files (
.cursor/rules/), or conventions from cursor-rules-principles / retro..mdc
适用场景:
- 用户要求审核或维护项目规则、检查前缀规范,或同步 doc/rules.md。
- 上下文涉及 、规则文件(
.cursor/rules/),或 cursor-rules-principles/retro 中的约定。.mdc
Source of truth
权威依据
- cursor-rules-principles.md (in repo or ~/.cursor) – prefix table 000–500, general principles. See reference.md for full prefix table.
- commands/retro.md (PROJECT RULES section) – prefixes 000/050/100/200/900, flat .mdc, no subfolders in rules.
- cursor-rules-principles.md(位于仓库或 ~/.cursor 中)——包含000-500的前缀表及通用原则。完整前缀表请参见 reference.md。
- commands/retro.md(PROJECT RULES 章节)——包含前缀000/050/100/200/900,规则采用扁平化 .mdc 文件结构,rules目录下无子文件夹。
Procedure
操作流程
-
Resolve paths
- PROJECT_ROOT:
git rev-parse --show-toplevel - PROJECT_CURSOR_DIR:
${PROJECT_ROOT}/.cursor - PROJECT_RULES_DIR:
${PROJECT_CURSOR_DIR}/rules - If PROJECT_RULES_DIR does not exist, report "No .cursor/rules in this repo" and stop.
- PROJECT_ROOT:
-
Audit
- List all in PROJECT_RULES_DIR (flat; no subfolders per convention).
*.mdc - For each file: name, prefix vs principles/retro, frontmatter (,
description,alwaysApply), line count (~<50 preferred), overlap with other rules (duplicate or near-duplicate content).globs - Flag: missing prefix, wrong prefix slot, missing/invalid frontmatter, oversized file, duplicate content.
- List all
-
Proposals
- RENAME: file without numeric prefix → suggest prefix from reference.md / retro.
- MERGE: two or more rules with overlapping scope → suggest target file and sections.
- DELETE: only with clear justification (obsolete, fully merged); do not execute without user confirmation.
- Do not delete, move, or rename until user confirms.
-
Sync doc/rules.md
- If repo has or
doc/rules.md: update the "Context-Specific Rules" (or equivalent) list to match currentdocs/rules.mdfiles and their globs/scope. Keep doc and rules directory in sync..mdc
- If repo has
-
解析路径
- PROJECT_ROOT:
git rev-parse --show-toplevel - PROJECT_CURSOR_DIR:
${PROJECT_ROOT}/.cursor - PROJECT_RULES_DIR:
${PROJECT_CURSOR_DIR}/rules - 若 PROJECT_RULES_DIR 不存在,提示“当前仓库中无 .cursor/rules 目录”并终止操作。
- PROJECT_ROOT:
-
审核操作
- 列出 PROJECT_RULES_DIR 中所有 文件(按约定为扁平化结构,无任何子文件夹)。
*.mdc - 对每个文件检查:文件名、前缀是否符合 principles/retro 中的约定、前置元数据(、
description、alwaysApply)、文件行数(建议不超过50行)、与其他规则的内容重叠情况(重复或近似重复内容)。globs - 标记问题:缺少前缀、前缀位置错误、前置元数据缺失/无效、文件过大、内容重复。
- 列出 PROJECT_RULES_DIR 中所有
-
优化建议
- 重命名:无数字前缀的文件 → 从 reference.md / retro 中推荐合适的前缀。
- 合并:存在范围重叠的两个或多个规则 → 建议目标文件及合并后的章节划分。
- 删除:仅在有明确理由时提出(如规则已过时、已完全合并);未得到用户确认前不得执行删除操作。
- 在用户确认前,不得执行删除、移动或重命名操作。
-
同步 doc/rules.md
- 若仓库中存在 或
doc/rules.md:更新“上下文特定规则”(或同类名称)列表,使其与当前docs/rules.md文件及其 globs/作用范围保持一致,确保文档与规则目录同步。.mdc
- 若仓库中存在
Output
输出内容
- Report: table of files (path, prefix OK?, frontmatter OK?, lines, notes); list of proposals (RENAME/MERGE/DELETE with reason and target).
- Closing line: "Do zastosowania: potwierdź zmiany lub wywołaj agenta rules-keeper."
- No destructive changes without explicit user confirmation.
- 报告: 文件列表表格(包含路径、前缀是否合规、前置元数据是否合规、行数、备注);优化建议列表(包含重命名/合并/删除的理由及目标操作)。
- 结尾语句:“执行方式:确认更改或调用 rules-keeper 代理。”
- 未得到用户明确确认前,不得执行任何破坏性操作。
Reference
参考资料
For full prefix table and conventions, see reference.md.
完整前缀表及约定请参见 reference.md。