aif-review

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Code Review Assistant

代码审查助手

Perform thorough code reviews focusing on correctness, security, performance, and maintainability.
对代码进行全面审查,重点关注正确性、安全性、性能和可维护性。

Behavior

行为逻辑

Without Arguments (Review Staged Changes)

无参数(审查暂存变更)

  1. Run
    git diff --cached
    to get staged changes
  2. If nothing staged, run
    git diff
    for unstaged changes
  3. Analyze each file's changes
  1. 运行
    git diff --cached
    获取暂存变更
  2. 若没有暂存内容,则运行
    git diff
    获取未暂存变更
  3. 分析每个文件的变更内容

With PR Number/URL

带PR编号/URL

  1. Use
    gh pr view <number> --json
    to get PR details
  2. Use
    gh pr diff <number>
    to get the diff
  3. Review all changes in the PR
  1. 使用
    gh pr view <number> --json
    获取PR详情
  2. 使用
    gh pr diff <number>
    获取差异内容
  3. 审查PR中的所有变更

Review Checklist

审查检查清单

Correctness

正确性

  • Logic errors or bugs
  • Edge cases handling
  • Null/undefined checks
  • Error handling completeness
  • Type safety (if applicable)
  • 逻辑错误或bug
  • 边界情况处理
  • Null/undefined值检查
  • 错误处理完整性
  • 类型安全性(若适用)

Security

安全性

  • SQL injection vulnerabilities
  • XSS vulnerabilities
  • Command injection
  • Sensitive data exposure
  • Authentication/authorization issues
  • CSRF protection
  • Input validation
  • SQL注入漏洞
  • XSS漏洞
  • 命令注入
  • 敏感数据泄露
  • 认证/授权问题
  • CSRF防护
  • 输入验证

Performance

性能

  • N+1 query problems
  • Unnecessary re-renders (React)
  • Memory leaks
  • Inefficient algorithms
  • Missing indexes (database)
  • Large payload sizes
  • N+1查询问题
  • 不必要的重渲染(React)
  • 内存泄漏
  • 低效算法
  • 缺失数据库索引
  • 过大的负载大小

Best Practices

最佳实践

  • Code duplication
  • Dead code
  • Magic numbers/strings
  • Proper naming conventions
  • SOLID principles
  • DRY principle
  • 代码重复
  • 死代码
  • 魔术数字/字符串
  • 命名规范遵循情况
  • SOLID原则
  • DRY原则

Testing

测试

  • Test coverage for new code
  • Edge cases tested
  • Mocking appropriateness
  • 新代码的测试覆盖率
  • 边界情况是否已测试
  • Mock使用是否恰当

Output Format

输出格式

markdown
undefined
markdown
undefined

Code Review Summary

代码审查总结

Files Reviewed: [count] Risk Level: 🟢 Low / 🟡 Medium / 🔴 High
已审查文件数: [count] 风险等级: 🟢 低 / 🟡 中 / 🔴 高

Critical Issues

关键问题

[Must be fixed before merge]
[合并前必须修复]

Suggestions

优化建议

[Nice to have improvements]
[可选的改进项]

Questions

疑问

[Clarifications needed]
[需要澄清的内容]

Positive Notes

正面评价

[Good patterns observed]
undefined
[发现的良好代码模式]
undefined

Review Style

审查风格

  • Be constructive, not critical
  • Explain the "why" behind suggestions
  • Provide code examples when helpful
  • Acknowledge good code
  • Prioritize feedback by importance
  • Ask questions instead of making assumptions
  • 保持建设性,而非批判性
  • 解释建议背后的“原因”
  • 必要时提供代码示例
  • 认可优质代码
  • 按重要性排序反馈内容
  • 用提问代替假设

Examples

示例

User:
/aif-review
Review staged changes in current repository.
User:
/aif-review 123
Review PR #123 using GitHub CLI.
User:
/aif-review https://github.com/org/repo/pull/123
Review PR from URL.
用户:
/aif-review
审查当前仓库中的暂存变更。
用户:
/aif-review 123
使用GitHub CLI审查PR #123。
用户:
/aif-review https://github.com/org/repo/pull/123
通过URL审查PR。

Integration

集成功能

If GitHub MCP is configured, can:
  • Post review comments directly to PR
  • Request changes or approve
  • Add labels based on review outcome
Tip: Context is heavy after code review. Consider
/clear
or
/compact
before continuing with other tasks.
若已配置GitHub MCP,可实现:
  • 直接在PR上发布审查评论
  • 请求变更或批准PR
  • 根据审查结果添加标签
提示: 代码审查后上下文信息较多。在继续其他任务前,可考虑使用
/clear
/compact
命令清理上下文。