monorepo-workflow / rules
Cursor rule1 starsChanged 4 months agoMITView on GitHub
代码评审确保代码在合并前达到质量、安全和可维护性要求。本规则定义何时以及如何进行代码评审。 遇到以下情况时必须停下来使用 security-reviewer Agent: 代码评审使用以下 Agent: 本规则与以下规则协同工作: 评审涉及业务实现、接口或测试时,先按根目录 AGENTS.md 的「子项目文档优先级」读取目标子项目的 AGENTS.md、docs/README.md 及实际索引文件;不得根据固定模块文件名推测业务约定。
In this repository15 other files it gives its agents.
- AGENTS.mdAGENTS.md
- api/AGENTS.mdAGENTS.md
- fornt_admin/AGENTS.mdAGENTS.md
- m_front/AGENTS.mdAGENTS.md
- pc_fornt/AGENTS.mdAGENTS.md
- .cursor/rules/api-first-no-mock.mdcCursor rule
- .cursor/rules/multi-project-workspace.mdcCursor rule
- .cursor/rules/project-routing.mdcCursor rule
- .cursor/rules/project-workflow-api.mdcCursor rule
- .cursor/rules/project-workflow-front.mdcCursor rule
- .cursor/rules/project-workflow-product.mdcCursor rule
- .cursor/rules/project-workflow-test.mdcCursor rule
- .cursor/rules/project-workflow-ui.mdcCursor rule
- .cursor/rules/security.mdCursor rule
- .cursor/rules/subdir-rule-priority.mdcCursor rule
The file
Files
代码评审标准
目的
代码评审确保代码在合并前达到质量、安全和可维护性要求。本规则定义何时以及如何进行代码评审。
何时评审
强制评审触发条件:
- 编写或修改代码后
- 提交到共享分支前
- 安全敏感代码变更时(认证、支付、用户数据)
- 架构变更时
- 合并 Pull Request 前
评审前置要求:
请求评审前确保:
- 所有自动化检查(CI/CD)已通过
- 合并冲突已解决
- 分支与目标分支保持最新
评审清单
完成代码前逐项检查:
- 代码可读、命名清晰
- 函数聚焦(<50 行)
- 文件内聚(<800 行)
- 无深层嵌套(>4 层)
- 错误已显式处理
- 无硬编码密钥或凭据
- 无 console.log 或调试语句
- 新功能有对应测试
- 测试覆盖率达到 80% 最低要求
安全评审触发条件
遇到以下情况时必须停下来使用 security-reviewer Agent:
- 认证或授权代码
- 用户输入处理
- 数据库查询
- 文件系统操作
- 外部 API 调用
- 加密操作
- 支付或财务代码
评审严重级别
| 级别 | 含义 | 处理方式 |
| CRITICAL | 安全漏洞或数据丢失风险 | 阻断 - 合并前必须修复 |
| HIGH | Bug 或重大质量问题 | 警告 - 合并前应当修复 |
| MEDIUM | 可维护性问题 | 信息 - 建议修复 |
| LOW | 风格或小建议 | 备注 - 可选修复 |
Agent 使用
代码评审使用以下 Agent:
| Agent | 用途 |
| code-reviewer | 通用代码质量、模式、最佳实践 |
| security-reviewer | 安全漏洞、OWASP Top 10 |
| typescript-reviewer | TypeScript/JavaScript 专项问题 |
| python-reviewer | Python 专项问题 |
| go-reviewer | Go 专项问题 |
| rust-reviewer | Rust 专项问题 |
评审流程
1. 运行 git diff 了解变更内容
2. 优先检查安全清单
3. 检查代码质量清单
4. 运行相关测试
5. 验证覆盖率 >= 80%
6. 使用合适的 Agent 进行详细评审常见问题排查
安全类
- 硬编码凭据(API Key、密码、Token)
- SQL 注入(查询中使用字符串拼接)
- XSS 漏洞(未转义的用户输入)
- 路径遍历(未消毒的文件路径)
- 缺少 CSRF 保护
- 认证绕过
代码质量类
- 大函数(>50 行)- 拆分为更小的函数
- 大文件(>800 行)- 提取为独立模块
- 深层嵌套(>4 层)- 使用提前返回
- 缺少错误处理 - 显式处理
- 直接修改模式 - 使用不可变操作
- 缺少测试 - 补充测试覆盖
性能类
- N+1 查询 - 使用 JOIN 或批量查询
- 缺少分页 - 给查询添加 LIMIT
- 无约束查询 - 添加限制条件
- 缺少缓存 - 缓存高开销操作
批准标准
- 通过:无 CRITICAL 或 HIGH 问题
- 警告:仅有 HIGH 问题(谨慎合并)
- 阻断:存在 CRITICAL 问题
与其他规则的关联
本规则与以下规则协同工作:
- security.md - 安全检查清单
AGENTS.md- 项目识别、子项目文档优先级与工作区约束.codex/rules/project-workflow-test.mdc- 测试与验收工作流.codex/rules/subdir-rule-priority.mdc- 子目录规则优先级
评审涉及业务实现、接口或测试时,先按根目录 AGENTS.md 的「子项目文档优先级」读取目标子项目的 AGENTS.md、docs/README.md 及实际索引文件;不得根据固定模块文件名推测业务约定。
<!-- AIGC:codex|author:沉香|lines:约6|dates:2026-07|功能说明:代码评审规则改为关联实际Codex规则并遵循子项目文档优先级 -->Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

