This lesson on Code Review with AI is hands-on and example-driven. You will configure Code Rabbit to automate pull request reviews on GitHub and perform pre-push code reviews directly from your local terminal using the CLI. You will also use AI-driven issue planning and machine-readable review output to create automated repair loops that resolve security vulnerabilities and performance bottlenecks before merging.
What You'll Be Able To Do
- Connect Code Rabbit to a GitHub repository to trigger automated pull request reviews.
- Triage AI review findings on GitHub and apply inline committable fixes for security vulnerabilities and blocking operations.
- Execute pre-push reviews locally using the Code Rabbit CLI with plain text output formatting.
- Generate phased feature implementation plans by invoking issue commands in GitHub.
- Construct an autonomous AI repair loop that pipes CLI review feedback directly into code generation agents for automated remediation.
Detailed Concept Walkthrough
1. GitHub App Pull Request Review
Integrates Code Rabbit directly into GitHub's pull request workflow to automatically analyze code changes for security, performance, and correctness before merging.
- Mechanism: Upon opening or updating a pull request, automated webhooks trigger Code Rabbit to scan diffs and post structured review comments alongside a high-level summary.
- Issue Triage: Distinguishes high-severity issues—such as SQL injection vulnerabilities, exposed stack traces in 500 errors, or synchronous disk I/O on request paths—from minor nitpicks.
- Committable Fixes: Provides direct inline code suggestions that developers can review, accept, and commit directly to the branch with a single click inside GitHub.
# Standard GitHub PR trigger workflow
git checkout -b feature/user-profile-api
git add src/controllers/userController.js
git commit -m "feat: add user profile endpoint with disk cache"
git push origin feature/user-profile-api
# Opening a Pull Request on GitHub triggers Code Rabbit automatically
Key Takeaway: Automated PR reviews catch architectural, security, and performance regressions before code merges into protected branches.
2. Local Code Review via CLI
Shifts code review left by analyzing uncommitted and local branch changes directly inside your terminal prior to pushing code upstream.
- Installation & Auth: Installed using a curl script and authenticated against your GitHub account to load organizational rules and repository context.
- Execution Flow: Running review commands evaluates local diffs against the target base branch, outputting line-by-line feedback directly into the terminal console.
- Machine-Readable Formatting: Using the plain flag suppresses interactive formatting and styling, outputting raw text suitable for log capturing and script processing.
# Install and authenticate Code Rabbit CLI
curl -fsSL https://coderabbit.ai/install.sh | sh
coderabbit auth login
# Run local review before pushing to remote
coderabbit review --plain
Key Takeaway: Local CLI reviews shorten feedback loops by flagging issues before code is committed or pushed to remote repositories.
3. Autonomous AI Repair Loops
Pairs automated AI code generation with AI code review in a closed terminal loop to iteratively detect and self-heal defects without manual coding.
- Mechanism: An AI coding agent generates an initial implementation, which is then immediately evaluated by the Code Rabbit CLI.
- Feedback Pipeline: The plain text output containing identified bugs, missing sanitization, or blocking operations is piped directly back into the AI agent prompt as error context.
- Iterative Fixes: The generating agent reads the feedback, refactors the source code, and repeats the CLI review until zero critical issues remain.
# Autonomous feedback loop between reviewer and generator
coderabbit review --plain > review_feedback.txt
cat review_feedback.txt | ai-agent "Fix all reported issues in src/"
git diff
coderabbit review --plain
Key Takeaway: Piping machine-readable CLI review output back into coding agents enables automated self-correction of code defects.
4. Feature Breakdown via Issue Planning
Commands the AI reviewer to decompose high-level GitHub issues into structured, phased architectural plans and actionable coding prompts.
- Trigger Command: Adding an issue comment prompts the AI to evaluate the issue description against the repository architecture and conventions.
- Phased Architecture: Outputs an implementation strategy broken into logical steps, including database migrations, business logic, and error handling considerations.
- Agent Prompt Generation: Supplies pre-formatted prompts tailored for each implementation phase that can be copied directly into AI coding agents.
# Post a comment on any open GitHub Issue:
# @coderabbit plan
#
# Generated Plan Structure:
# Phase 1: Database Migration & Schema Setup
# Phase 2: Service Layer & Async File Processing
# Phase 3: Error Sanitization & Route Registration
Key Takeaway: Issue planning converts unstructured feature requirements into phased implementation steps with ready-to-run AI prompts.
Topics Covered in Code Review with AI
- App Installation and Integration (1:10 - 1:45) — Authenticate with GitHub and link the Code Rabbit GitHub App to target repositories.
- Triggering Automated PR Review (1:45 - 2:24) — Create a feature branch with intentional code flaws and open a pull request to initiate AI review.
- Triage and Apply Fixes (2:24 - 4:21) — Analyze PR summaries, inspect critical security and I/O warnings, and commit inline suggested fixes.
- Local CLI Review Workflow (4:21 - 5:58) — Install the CLI tool, authenticate locally, and run pre-push reviews with plain text output.
- AI Issue Planning Feature (5:58 - 6:44) — Post an issue comment to generate structured phased tasks and actionable prompts for coding agents.
AI-Assisted Coding Cheat Sheet
-
coderabbit review— Runs AI code review on local branch diffscoderabbit review -
coderabbit review --plain— Outputs unformatted review text for automated scripting pipelinescoderabbit review --plain -
coderabbit auth login— Authenticates local CLI session with GitHub accountcoderabbit auth login -
@coderabbit plan— Generates phased feature implementation plan inside issue comment# Comment in GitHub issue: @coderabbit plan -
curl -fsSL https://coderabbit.ai/install.sh | sh— Installs the Code Rabbit CLI on Unix systemscurl -fsSL https://coderabbit.ai/install.sh | sh
Comparison Table
| Feature / Dimension | GitHub PR Review | Code Rabbit CLI |
|---|---|---|
| Execution Context | Remote GitHub Pull Request | Local terminal pre-push |
| Trigger Method | Pull request open or update | Manual command execution |
| Feedback Display | Interactive GitHub Markdown comments | Terminal stdout or raw text |
| Primary Use Case | Team merge gate & triage | Fast local self-checks and scripts |
Common Pitfalls
- Mistake: Placing synchronous disk I/O on request paths. Avoid: Using asynchronous non-blocking file operations or background workers.
- Mistake: Exposing raw database errors or stack traces in responses. Avoid: Sanitizing error output and returning generic status messages.
- Mistake: Pushing unverified code directly to remote pull requests. Avoid: Running coderabbit review locally to catch critical flaws pre-push.
FAQs
- How do I apply suggested changes directly from a GitHub PR review? Click the commit suggestion button directly inside GitHub's pull request diff view to apply the fix without leaving your browser.
- Why should I use the --plain flag with the CLI review command? The plain flag removes terminal ANSI styling, producing clean text that can be piped into automated scripts or AI coding agent prompts.
- Can Code Rabbit review my code before I open a pull request? Yes, installing and running the Code Rabbit CLI on your local branch reviews unpushed code changes directly inside your terminal.