generic-code-reviewer
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGeneric Code Reviewer
通用代码审查工具
Review code against production quality standards. Adapts to any project's tech stack.
Full Standards: See Code Review Standards
按照生产环境质量标准审查代码,适配任意项目的技术栈。
完整标准: 查看 代码审查标准
CLAUDE.md Compliance
CLAUDE.md 合规性
Always check the project's CLAUDE.md for specific rules.
Before ANY Commit:
- Task file exists in
tasks/[feature-name].md - All tests passing
- Type checking passing (if TypeScript)
- No console errors/warnings
- Bundle size within limits
请始终检查项目的CLAUDE.md文件以了解特定规则。
提交代码前必须完成:
- 路径下存在任务文件
tasks/[feature-name].md - 所有测试用例通过
- 类型检查通过(若使用TypeScript)
- 无控制台错误/警告
- 包体积在限制范围内
Tech Stack Detection
技术栈检测
| Detection | Stack | Key Checks |
|---|---|---|
| React in package.json | React/TS | Components, hooks, state |
| Next.js in package.json | Next.js | SSR, API routes |
| NestJS in package.json | NestJS | Guards, DTOs, services |
| .html files, no build | Vanilla | Semantic HTML, minimal JS |
| .py files | Python | Type hints, validation |
| 检测方式 | 技术栈 | 核心检查项 |
|---|---|---|
| package.json中包含React | React/TS | 组件、钩子、状态管理 |
| package.json中包含Next.js | Next.js | SSR、API路由 |
| package.json中包含NestJS | NestJS | 守卫、DTO、服务 |
| 存在.html文件且无构建流程 | 原生技术栈 | 语义化HTML、最小化JS代码 |
| 存在.py文件 | Python | 类型提示、数据验证 |
P0 Issues (Block Merge)
P0级问题(阻止合并)
Security - Frontend
安全 - 前端
- Sanitize input (textContent, not innerHTML)
- type for external data
unknown - No exposed API keys
- HTTPS for external requests
- 对输入进行 sanitize 处理(使用textContent而非innerHTML)
- 外部数据使用类型
unknown - 不暴露API密钥
- 外部请求使用HTTPS
Security - Backend
安全 - 后端
- Input validation on all endpoints
- Auth on protected routes
- Parameterized queries (no raw SQL)
- Secrets in environment variables
- 所有端点都进行输入验证
- 受保护路由添加认证
- 使用参数化查询(禁止原生SQL)
- 敏感信息存储在环境变量中
Correctness
正确性
- Logic errors that break functionality
- Type errors in strict mode
- Unhandled promise rejections
- 破坏功能的逻辑错误
- 严格模式下的类型错误
- 未处理的Promise拒绝
P1 Issues (Should Fix)
P1级问题(建议修复)
Performance
性能
| Project Type | Target |
|---|---|
| Static site | < 50KB (excluding media) |
| SPA/React | < 100KB gzipped initial |
| Full-stack | < 200KB gzipped initial |
Animation:
- GPU-accelerated only (transform, opacity)
- 60fps target
- Use requestAnimationFrame
| 项目类型 | 目标要求 |
|---|---|
| 静态站点 | 小于50KB(不含媒体资源) |
| SPA/React应用 | 初始包体积压缩后小于100KB |
| 全栈应用 | 初始包体积压缩后小于200KB |
动画:
- 仅使用GPU加速的动画(transform、opacity)
- 目标帧率60fps
- 使用requestAnimationFrame
Accessibility (WCAG AA)
可访问性(WCAG AA标准)
- Focus indicators on interactive elements
- Keyboard navigation (Tab, Enter, Escape)
- Color contrast >= 4.5:1
- ARIA labels on icon-only buttons
- Alt text for meaningful images
- Semantic HTML structure
- 交互元素带有焦点指示器
- 支持键盘导航(Tab、Enter、Escape键)
- 颜色对比度≥4.5:1
- 纯图标按钮添加ARIA标签
- 有意义的图片添加替代文本
- 使用语义化HTML结构
P2 Issues (Nice to Have)
P2级问题(优化建议)
Code Quality
代码质量
- DRY, Single Responsibility
- No magic numbers/strings
- Self-documenting code
- Follow existing patterns
- No commented-out/dead code
- 遵循DRY原则、单一职责原则
- 避免魔法数字/字符串
- 代码自文档化
- 遵循现有代码模式
- 移除注释掉的无效代码
Review Output Format
审查输出格式
Only report issues found (don't list empty categories):
Blocking Issues (P0):
- [Only if found - security, correctness issues]
Should Fix (P1):
- [Only if found - performance, accessibility issues]
Consider (P2):
- [Only if found - code quality polish]
If no issues: "Code review passed. Ready to merge."
仅报告发现的问题(无需列出无问题的分类):
阻止合并的问题(P0):
- [仅在发现问题时列出 - 安全、正确性相关问题]
建议修复的问题(P1):
- [仅在发现问题时列出 - 性能、可访问性相关问题]
优化建议(P2):
- [仅在发现问题时列出 - 代码质量优化]
若无问题: "代码审查通过,可合并。"
Judgment Calls
判断准则
When user asks "Is this OK?", consider:
| Context | Stricter | More Lenient |
|---|---|---|
| Environment | Production | Prototype/POC |
| Path | Hot path, frequently executed | One-time setup, admin only |
| Visibility | Public API, external interface | Internal helper, private method |
| Timeline | Feature complete | Active iteration |
Adjust severity accordingly. P0 security issues are never lenient.
当用户询问“这样可以吗?”时,需考虑以下场景:
| 场景 | 更严格标准 | 更宽松标准 |
|---|---|---|
| 运行环境 | 生产环境 | 原型/POC |
| 代码路径 | 热路径、高频执行代码 | 一次性配置、仅管理员使用代码 |
| 可见性 | 公开API、外部接口 | 内部辅助工具、私有方法 |
| 开发阶段 | 功能开发完成 | 迭代开发中 |
根据上述情况调整问题严重程度。P0级安全问题绝不放宽标准。
Quick Checklist
快速检查清单
Pre-Commit:
- Tests pass
- Type/lint pass
- Build succeeds
- No console errors
Before Merge:
- All P0 issues resolved
- P1 issues addressed or tracked
- P2 issues noted for future
提交代码前:
- 测试用例全部通过
- 类型检查/代码规范检查通过
- 构建成功
- 无控制台错误
合并前:
- 所有P0级问题已解决
- P1级问题已处理或记录追踪
- P2级问题已记录以便后续优化
See Also
相关链接
- Code Review Standards - Full requirements
- Design Patterns - UI consistency
- Project - Workflow rules
CLAUDE.md
- 代码审查标准 - 完整要求
- 设计模式 - UI一致性规范
- 项目文件 - 工作流规则
CLAUDE.md