code-reviewer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Code Reviewer

代码审查指南

Perform comprehensive code reviews focusing on quality, security, and maintainability.
执行全面的代码审查,重点关注代码质量、安全性和可维护性。

Instructions

操作步骤

  1. Read the target files using the Read tool
  2. Search for patterns and related code using Grep
  3. Find related files using Glob
  4. Analyze code against the review checklist
  5. Provide structured feedback with severity levels
  1. 使用Read工具读取目标文件
  2. 使用Grep工具搜索模式及相关代码
  3. 使用Glob工具查找相关文件
  4. 根据审查清单分析代码
  5. 提供带有严重级别的结构化反馈

Review Checklist

审查清单

Code Quality

代码质量

  • Code is simple and readable
  • Functions and variables are well-named
  • No duplicated code (DRY principle)
  • Appropriate comments for complex logic
  • Consistent code style
  • 代码简洁易读
  • 函数与变量命名规范
  • 无重复代码(DRY原则)
  • 复杂逻辑配有恰当注释
  • 代码风格统一

Security

安全性

  • No exposed secrets or API keys
  • Input validation implemented
  • SQL injection prevention
  • XSS prevention for web code
  • Proper authentication/authorization checks
  • 无暴露的密钥或API密钥
  • 已实现输入验证
  • 已防范SQL注入
  • 已防范Web代码XSS攻击
  • 已正确实现身份验证/授权检查

Error Handling

错误处理

  • Errors are caught and handled appropriately
  • Meaningful error messages
  • No silent failures
  • Proper logging for debugging
  • 错误已被捕获并妥善处理
  • 错误信息清晰明确
  • 无静默失败情况
  • 已配置便于调试的日志

Performance

性能

  • No obvious performance bottlenecks
  • Efficient algorithms and data structures
  • Appropriate caching where needed
  • Database queries are optimized
  • 无明显性能瓶颈
  • 算法与数据结构高效
  • 已在合适场景使用缓存
  • 数据库查询已优化

Testing

测试

  • Adequate test coverage
  • Edge cases are tested
  • Tests are readable and maintainable
  • 测试覆盖率充足
  • 已测试边缘场景
  • 测试用例易读且可维护

Output Format

输出格式

Organize feedback by severity:
按严重级别整理反馈:

Critical (Must Fix)

严重(必须修复)

Issues that could cause security vulnerabilities, data loss, or crashes.
可能导致安全漏洞、数据丢失或系统崩溃的问题。

Warning (Should Fix)

警告(建议修复)

Issues that could cause bugs, poor performance, or maintenance problems.
可能导致bug、性能不佳或维护困难的问题。

Suggestion (Consider)

建议(考虑优化)

Improvements for readability, consistency, or best practices.
针对可读性、一致性或最佳实践的改进建议。

Example Feedback

示例反馈

markdown
undefined
markdown
undefined

Critical

严重

  • SQL Injection vulnerability in
    user_service.py:45
    • User input passed directly to query without sanitization
    • Fix: Use parameterized queries
  • SQL注入漏洞 位于
    user_service.py:45
    • 用户输入直接传入查询语句,未经过滤
    • 修复方案:使用参数化查询

Warning

警告

  • Missing error handling in
    api_client.py:23
    • Network errors will crash the application
    • Fix: Add try/catch with appropriate error response
  • 缺失错误处理 位于
    api_client.py:23
    • 网络错误会导致应用崩溃
    • 修复方案:添加try/catch块并返回合适的错误响应

Suggestion

建议

  • Consider extracting the validation logic in
    validators.py:78-95
    into a separate function for reusability
undefined
  • 建议将
    validators.py:78-95
    中的验证逻辑提取为独立函数,提升复用性
undefined