coderabbit-review

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

CodeRabbit Review Handler

CodeRabbit 审查处理流程

Process CodeRabbit review comments with context-aware discretion.
结合上下文审慎处理CodeRabbit的审查评论。

Instructions

操作指南

1. Initial Context

1. 初始上下文告知

Inform the user:
I'll review the CodeRabbit comments with discretion, as CodeRabbit doesn't have access to the entire codebase and may not understand the full context.

For each comment, I'll:
- Evaluate if it's valid given our codebase context
- Accept suggestions that improve code quality
- Ignore suggestions that don't apply to our architecture
- Explain my reasoning for accept/ignore decisions
告知用户:
I'll review the CodeRabbit comments with discretion, as CodeRabbit doesn't have access to the entire codebase and may not understand the full context.

For each comment, I'll:
- Evaluate if it's valid given our codebase context
- Accept suggestions that improve code quality
- Ignore suggestions that don't apply to our architecture
- Explain my reasoning for accept/ignore decisions

2. Run Code Rabbit

2. 运行CodeRabbit

If no comments are provided, run CodeRabbit in prompt-only mode to generate comments:
bash
undefined
如果未提供任何评论,以仅提示模式运行CodeRabbit来生成评论:
bash
undefined

Run CodeRabbit cli

Run CodeRabbit cli

coderabbit --prompt-only
undefined
coderabbit --prompt-only
undefined

3. Evaluate Comments

3. 评估评论

  • Parse the comments
  • For each comment:
    • Read the relevant file to understand context
    • Determine if the suggestion is valid and beneficial
    • Decide to accept or ignore the suggestion
    • Document reasoning for each decision
  • Ignore *.md files
  • 解析评论
  • 针对每条评论:
    • 阅读相关文件以理解上下文
    • 判断建议是否有效且有益
    • 决定接受或忽略该建议
    • 记录每个决定的理由
  • 忽略*.md文件

4. Execute Fixes

4. 执行修复

Task a subagent to address the comments you've accepted
指派子Agent处理你已接受的评论

5. Validate Changes

5. 验证变更

Run relevant tests and linters to ensure code integrity:
Example:
bash
undefined
运行相关测试与代码检查工具以确保代码完整性:
示例:
bash
undefined

Run all unit tests

Run all unit tests

./scripts/test.sh unit 1 2>&1 | tail -100
./scripts/test.sh unit 1 2>&1 | tail -100

Run affected UI tests

Run affected UI tests

./scripts/test.sh ui [TestName] 2>&1 | tail -100
./scripts/test.sh ui [TestName] 2>&1 | tail -100

Run swiftlint on changed files and fix ANY issues

Run swiftlint on changed files and fix ANY issues

git diff --name-only origin/main...HEAD -- '*.swift' | xargs -r swiftlint lint --strict
undefined
git diff --name-only origin/main...HEAD -- '*.swift' | xargs -r swiftlint lint --strict
undefined

6. Commit Changes

6. 提交变更

After applying changes commit your work using appropriate commit messages summarizing the changes made. Address any re-commit hook violations as needed.
应用变更后,使用合适的提交信息总结所做修改并提交代码。如有需要,处理任何提交钩子触发的违规问题。

7. Consolidate Results

7. 整理结果

After completion, provide a summary report:
📋 CodeRabbit Review Summary

Files Processed: {count}

Accepted Suggestions:
  {file}: {changes_made}
  
Ignored Suggestions:
  {file}: {reason_ignored}

Overall: {X}/{Y} suggestions applied
完成后,提供一份总结报告:
📋 CodeRabbit Review Summary

Files Processed: {count}

Accepted Suggestions:
  {file}: {changes_made}
  
Ignored Suggestions:
  {file}: {reason_ignored}

Overall: {X}/{Y} suggestions applied

Common Patterns to Ignore

常见忽略场景

  • Style preferences that conflict with project conventions
  • Generic best practices that don't apply to our specific use case
  • Performance optimizations for code that isn't performance-critical
  • Accessibility suggestions for internal tools
  • Security warnings for already-validated patterns
  • Import reorganization that would break our structure
  • 与项目规范冲突的风格偏好
  • 不适用于我们特定场景的通用最佳实践
  • 针对非性能关键代码的性能优化建议
  • 针对内部工具的可访问性建议
  • 针对已验证模式的安全警告
  • 会破坏现有结构的导入语句重排建议

Common Patterns to Accept

常见接受场景

  • Actual bugs (null checks, error handling)
  • Security vulnerabilities (unless false positive)
  • Resource leaks (unclosed connections, memory leaks)
  • Type safety issues (TypeScript/type hints)
  • Logic errors (off-by-one, incorrect conditions)
  • Missing error handling
  • 实际漏洞(空值检查、错误处理相关)
  • 安全漏洞(误报除外)
  • 资源泄漏(未关闭的连接、内存泄漏等)
  • 类型安全问题(TypeScript/类型提示相关)
  • 逻辑错误(边界错误、条件判断错误等)
  • 缺失的错误处理

Decision Framework

决策框架

For each suggestion, consider:
  1. Is it correct? - Does the issue actually exist?
  2. Is it relevant? - Does it apply to our use case?
  3. Is it beneficial? - Will fixing it improve the code?
  4. Is it safe? - Could the change introduce problems?
Only apply if all answers are "yes" or the benefit clearly outweighs risks.
针对每条建议,需考量:
  1. 是否正确? - 该问题是否真实存在?
  2. 是否相关? - 是否适用于我们的使用场景?
  3. 是否有益? - 修复后是否能提升代码质量?
  4. 是否安全? - 变更是否会引入新问题?
仅当所有问题的答案都是“是”,或是收益明显大于风险时,才应用该建议。

Important Notes

重要提示

  • CodeRabbit is helpful but lacks context
  • Trust your understanding of the codebase over generic suggestions
  • Explain decisions briefly to maintain audit trail
  • Batch related changes for efficiency
  • Always run the relevant ui and unit tests, and/or create new tests to verify correctness after applying changes
  • CodeRabbit虽有帮助,但缺乏上下文信息
  • 相较于通用建议,更应依赖你对代码库的理解
  • 简要解释决策,以保留审计轨迹
  • 批量处理相关变更以提升效率
  • 应用变更后,务必运行相关UI测试和单元测试,或创建新测试以验证正确性