A Pull Request code review tool based on CodeBuddy CLI that automatically performs AI-powered code reviews on PR changes and posts comments.
Note: Only supports the following pipeline events:
output: Output file path for review results. When specified, results are saved as a JSON file; otherwise, they are printed to the terminal.context: Number of context lines to include when generating diff, i.e., how many lines to show before and after the changed code. Higher values provide more context for AI, resulting in more accurate reviews, but also increase token consumption. Default: 5verbose: Whether to show detailed logs. When enabled, outputs more debugging information including Git command execution and file filtering details. Default: falsecomment: Whether to post review results as PR comments. When enabled, adds a review summary comment and specific line-level issue comments to the PR page. Default: truemax_comments: Maximum number of comments when posting to PR. To avoid excessive comments affecting readability, comments are sorted by issue severity and truncated. Default: 10max_diff_size: Maximum allowed diff size (in characters). Diffs exceeding this size will be truncated, and some files may not be reviewed. Default: 100000 (approximately 100K characters)max_files: Maximum number of files to review. When exceeded, only the first N files are reviewed to prevent review timeout or excessive token consumption. Default: 30fail_on_critical: Whether to return a non-zero exit code when critical issues are found. When enabled, can be used as a pipeline gate to block merging code with critical issues. Default: falseprompt_output: Output the complete prompt sent to AI to the specified file path. Used for debugging and viewing the actual review content, including system prompts and code diff. Not output if not specified.Configure in .cnb.yml:
main:
pull_request:
- stages:
- name: code-review
image: cnbcool/code-review:latest
settings:
# Output file path
output: ./code_review.json
context: 10
comment: true
max_comments: 10
max_diff_size: 100000
# Whether to return non-zero exit code when critical issues are found (pipeline will fail)
fail_on_critical: false
# Output prompt to file (for debugging)
# prompt_output: ./prompt.txt
The code_review.json review results are in JSON format:
{
"status": "passed | needs_modification | critical",
"issues": [
{
"severity": "critical | warning | info",
"file": "file path",
"start_line": 42,
"end_line": 45,
"problem": "Problem description",
"suggestion": "Fix suggestion"
}
]
}
passed: Code quality is good, can be mergedneeds_modification: There are issues that need to be fixedcritical: There are critical issues that must be fixedcritical: Critical issues (security vulnerabilities, severe bugs), must be fixedwarning: Medium issues (potential risks, code quality), recommended to fixinfo: Minor issues/suggestions (code style, best practices), optional to fix0: Review completed, no critical issues1: Review failed or runtime error2: Critical issues found (requires fail_on_critical to be enabled)