> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coderabbit.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Command-Line Review Tool

> Get AI code reviews directly in your CLI before you commit. Catch race conditions, memory leaks, and security vulnerabilities without leaving your development environment.

export const OpenBetaBadge = ({tip = "This feature is currently in open beta. We are actively improving it based on your feedback. If you encounter any issues or have suggestions, please share them on our Discord community or visit the support page.", title = "Open Beta", cta = "Contact support", href = "/support", disabled = false}) => {
  return <Tooltip tip={tip} cta={cta} href={href}>
        <Badge icon="badge-alert" disabled={disabled || undefined}>
            {title}
        </Badge>
    </Tooltip>;
};

<OpenBetaBadge />

## Review local changes

The CodeRabbit CLI analyzes your uncommitted changes using the same pattern recognition that powers our PR reviews. Review code as you write it, apply suggested fixes instantly, and catch critical issues while you still have full context in memory.

## Key features

<Card title="Review uncommitted changes" icon="code" horizontal>
  Catch bugs before they reach your repository. CodeRabbit scans your working directory for race conditions, null pointer exceptions, and logic errors before you commit.
</Card>

<Card title="Apply fixes in one step" icon="wand-sparkles" horizontal>
  Fix simple issues like missing imports or syntax errors instantly. For complex architectural problems, send the full context directly to your AI coding agent.
</Card>

<Card title="Context-aware reviews" icon="brain" horizontal>
  Paid plans unlock reviews powered by your team's codebase history: error handling conventions, architectural patterns, and coding preferences applied automatically to every review.
</Card>

## Getting started

<Steps>
  <Step title="Install CLI">
    Download and install the CodeRabbit CLI using your preferred method.

    <CodeGroup>
      ```bash Installation script theme={null}
      curl -fsSL https://cli.coderabbit.ai/install.sh | sh
      ```

      ```bash Homebrew theme={null}
      brew install coderabbit
      ```
    </CodeGroup>

    After installation, restart your shell or reload your shell configuration:

    ```bash theme={null}
    source ~/.zshrc
    ```
  </Step>

  <Step title="Authenticate">
    Link your CodeRabbit account to enable personalized reviews based on your team's patterns.

    ```bash theme={null}
    # cr is the short alias for coderabbit — both work identically
    cr auth login
    ```

    A browser window opens automatically. Sign in to CodeRabbit and the authentication completes in the browser.

    If your account has access to multiple CodeRabbit organizations, choose the organization that should power CLI reviews during sign-in. You can change it later with `cr auth org`.
  </Step>

  <Step title="Review your code">
    Analyze your Git repository for issues using the CodeRabbit CLI.

    <Info>
      **Git repository required**: The CLI must be run from within an initialized Git repository. The `--dir` flag changes the review directory, but that directory must also contain a Git repository.
    </Info>

    ```bash wrap theme={null}
    cr
    ```

    If your main branch is not `main`, specify your base branch:

    ```bash theme={null}
    cr --base develop
    # or for other base branches
    cr --base master
    ```

    CodeRabbit scans your working directory and provides specific feedback with suggested fixes.
  </Step>

  <Step title="Verify local setup">
    If setup, authentication, or review startup fails, run the local diagnostics command:

    ```bash theme={null}
    cr doctor
    ```

    The command checks installation, local storage, authentication, Git repository state, and CodeRabbit service connectivity.
  </Step>

  <Step title="Apply suggestions">
    Review findings in your terminal and either apply quick fixes or send complex issues to your AI coding agent.
  </Step>
</Steps>

## Organization selection

The active CodeRabbit organization controls which organization context, learnings, repository installation, and billing path apply to CLI reviews. During browser sign-in, select the organization that owns the repositories you plan to review.

To change organizations later, run:

```bash theme={null}
cr auth org
```

`cr auth org` opens sign-in automatically if your local session is missing or expired. Organization switching is not available for self-hosted mode or API key authentication.

## Review modes

The CLI offers three primary review modes to fit your workflow:

```bash theme={null}
# Plain mode (default) - detailed feedback with fix suggestions
cr

# Explicit plain mode
cr --plain

# Agent mode - structured JSON output for Skills and agent integrations
cr --agent

# Interactive mode - terminal UI for manual review
cr --interactive
```

Plain mode displays a finding count and severity summary at the end of each run. If the CLI detects a known agent environment, it suggests re-running with `--agent` for structured JSON output.

## Diagnostics

Run `cr doctor` at any time to verify your local setup. The command checks:

* CLI runtime and version
* Local CodeRabbit storage directory
* Authentication state and auth environment
* Current Git repository and branch metadata
* Auto-update policy
* CodeRabbit backend reachability
* CodeRabbit WebSocket reachability

```bash theme={null}
cr doctor
```

`cr doctor` exits with status code `1` when any check fails. Warnings appear in the report but do not cause a non-zero exit code.

## Working with review results

CodeRabbit analyzes your code and surfaces specific issues with actionable suggestions. Each finding includes the problem location, explanation, and recommended fix.

Example findings include:

* **Race condition detected**: "This goroutine accesses shared state without proper locking"
* **Memory leak potential**: "Stream not closed in error path - consider using defer"
* **Security vulnerability**: "SQL query uses string concatenation - switch to parameterized queries"
* **Logic error**: "Function returns nil without checking error condition first"

### Browse and apply suggestions

In interactive mode, use the arrow keys to navigate to a finding and press enter to see the detailed explanation and suggested fix inline in your CLI.

For simple issues like missing imports, syntax errors, or formatting problems, choose **Apply suggested change** to fix immediately.

### Use AI coding agents

For AI agent integration, see the [AI agent integration](#ai-agent-integration) section for detailed workflow guidance and integration guides.

### Managing comments

* **Ignore**: Hide findings you want to address later
* **Restore**: Click collapsed findings in the sidebar to show again

### Replay stored findings

Run `cr review findings` to re-read the results from the most recent local review without re-running the full analysis. This is useful in multi-step agent loops where a downstream step needs to consume results from a prior review.

### Inspect AI prompts

Run `cr review --show-prompts` to print the AI prompts saved from the most recent local review without triggering a new review. Useful for tuning `--config` instructions or understanding why the model flagged a particular finding.

## AI agent integration

CodeRabbit detects the problems, then your AI coding agent implements the fixes.

<Info>
  **Claude Code users**: Claude Code now supports CodeRabbit through a native
  plugin. See the [Claude Code integration guide](/cli/claude-code-integration)
  for the recommended plugin-based setup using `/coderabbit:review` instead of
  the CLI commands shown below.
</Info>

### Integration guides

See detailed workflows for AI coding agents and workflows:

<Card title="CodeRabbit Skills" icon="wand-sparkles" href="/cli/skills" horizontal>
  The fastest way to get started — install agent-native Skills and trigger reviews with natural language: "Review my code."
</Card>

<CardGroup cols={2}>
  <Card title="Claude Code integration" icon="bot" href="/cli/claude-code-integration">
    Automated workflow with background execution and task-based fixes
  </Card>

  <Card title="Codex integration" icon="terminal" href="/cli/codex-integration">
    Integrated code review and fix implementation with Codex CLI
  </Card>
</CardGroup>

<Card title="Headless CLI integration" icon="workflow" href="/cli/headless-cli-integration" horizontal>
  Authenticate CodeRabbit non-interactively in GitHub Actions and other bot-driven automation
</Card>

### Example prompt for your AI agent

Here's a complete prompt you can use with Cursor, Codex, or other AI coding agents:

```text Sample prompt wrap theme={null}
Please implement phase 7.3 of the planning doc and then run cr --agent, let it run as long as it needs (run it in the background) and fix any issues.
```

### Components of a good prompt

Breaking down what makes an effective CodeRabbit + AI agent workflow:

<AccordionGroup>
  <Accordion title="1. Run CodeRabbit CLI">
    Tell your AI agent to run CodeRabbit with the `--agent` flag:

    ```bash theme={null}
    cr --agent
    ```

    You can also specify review types or branches:

    ```bash theme={null}
    # Review only uncommitted changes
    cr --agent --type uncommitted

    # With specific base branch
    cr --agent --base develop
    ```
  </Accordion>

  <Accordion title="2. Run in the background">
    CodeRabbit reviews can take 7-30+ minutes depending on the scope of changes. Instruct your AI agent to run CodeRabbit in the background and set up a timer to check periodically:

    ```text Prompt wrap theme={null}
    Run cr --agent --type uncommitted in the background, let it take as long as it needs, and check on it periodically.
    ```
  </Accordion>

  <Accordion title="3. Evaluate and implement fixes">
    Once CodeRabbit completes, have your AI agent evaluate the findings and prioritize:

    ```text Prompt wrap theme={null}
    Evaluate the fixes and considerations. Fix major issues only, or fix any critical issues and ignore the nits.
    ```

    This keeps your agent focused on meaningful improvements rather than minor style issues.
  </Accordion>

  <Accordion title="4. Verify with a second pass">
    Run CodeRabbit one more time to ensure fixes didn't introduce new issues:

    ```text Prompt wrap theme={null}
    Once those changes are implemented, run cr --agent one more time to make sure we addressed all the critical issues and didn't introduce any additional bugs.
    ```
  </Accordion>

  <Accordion title="5. Set loop limits">
    Prevent infinite iteration by setting clear completion criteria:

    ```text Prompt wrap theme={null}
    Only run the loop twice. If on the second run you don't find any critical issues, ignore the nits and you're complete. Give me a summary of everything that was completed and why.
    ```

    This ensures your AI agent completes the task efficiently and provides a clear report.
  </Accordion>
</AccordionGroup>

## Pricing and capabilities

See the [rate limits table on the Plans and pricing page](/management/plans#rate-limits) for current per-plan limits. To increase the limits, consider upgrading your plan or using the [Usage-based Add-on](#cli-with-usage-based-add-on).

<CardGroup cols={1}>
  <Card title="Free tier" icon="heart">
    Basic static analysis with limited daily usage. Catches syntax errors, logic issues, and security vulnerabilities. Eligible Free users may see a Pro+ trial prompt after sign-in or when a CLI review reaches the rate limit.
  </Card>

  <Card title="Paid plans" icon="crown">
    Enhanced reviews powered by learnings from your CodeRabbit organization plus higher rate limits and more files per review. Paid users reviewing repositories connected to that organization get:

    * **Learnings-powered reviews**: Remembers your team's preferred patterns for error handling, state management, and architecture
    * **Full contextual analysis**: Understands your imports, dependencies, and project structure
    * **Team standards enforcement**: Applies your documented coding guidelines automatically
    * **Advanced issue detection**: Spots subtle race conditions, performance bottlenecks, and security vulnerabilities
  </Card>

  <Card title="Usage-based Add-On (Pay-as-you-Go)" icon="badge-dollar-sign">
    Allows unrestricted access to CodeRabbit CLI

    * Unlimited code reviews across every agentic coding loop
    * Full control over usage and scaling through the dashboard
    * Flexible purchase options (one-time & monthly subscription)
  </Card>
</CardGroup>

Contact [sales@coderabbit.ai](mailto:sales@coderabbit.ai) for custom rate limits or enterprise needs.

## CLI with Usage-based Add-on

The usage-based add-on uses a credit system to give you unlimited access to CodeRabbit CLI reviews. Each file reviewed costs **\$0.25** in credits. You can purchase credits as a one-time top-up or a recurring monthly subscription from the [Subscription and Billing](https://app.coderabbit.ai/settings/subscription) dashboard.

<Steps>
  <Step title="Buy credits">
    Go to **[Subscription and Billing](https://app.coderabbit.ai/settings/subscription)** and open the **Usage-based add-on** tab to purchase credits.

    For full setup details, see [Manage your subscription](/management/usage-based-addon).
  </Step>

  <Step title="Create an Agentic API Key">
    Once your purchase is complete, navigate to the [API Keys](https://app.coderabbit.ai/settings/api-keys) section and generate your **Agentic API key**.
  </Step>

  <Step title="Authenticate with your API key">
    You can pass `--api-key KEY` to any command directly, but if you plan to make multiple calls, it is more convenient to authenticate once with your CodeRabbit API key:

    ```bash theme={null}
    coderabbit auth login --api-key "cr-************"
    ```

    For GitHub Actions and other non-interactive environments, see [Headless CLI integration](/cli/headless-cli-integration).
  </Step>

  <Step title="Run a CodeRabbit review">
    After logging in, prompt your agent to run a CodeRabbit CLI review without passing the API key again:

    ```bash theme={null}
    coderabbit review --plain
    ```
  </Step>
</Steps>

## Command reference

See the [CLI Command Reference](/cli/reference) for a complete list of commands and options.

## Uninstall

Remove CodeRabbit CLI based on how you installed it.

```bash If installed using install script theme={null}
rm $(which coderabbit)
```

```bash If installed using Homebrew theme={null}
brew remove coderabbit
```
