> ## 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.

# Cursor integration: run CodeRabbit CLI reviews in your IDE

> Configure Cursor to run the CodeRabbit CLI on generated code, then automatically review, fix, and iterate on issues as part of an autonomous AI workflow.

<Info>
  This guide covers integrating CodeRabbit CLI with Cursor. For standalone CLI
  usage, see [CLI overview](/cli/).
</Info>

## Autonomous AI development workflows

CodeRabbit CLI + Cursor allows you to develop faster with code that gets reviewed for issues before it reaches the PR. Because Cursor executes CodeRabbit directly as part of its steps, code that gets made by Cursor can automatically be reviewed by CodeRabbit. Ask Cursor to implement a feature, run a code review, and fix any issues, as a natural part of agentic development.

## Video demo

<iframe className="w-full aspect-video rounded-xl" src="https://www.youtube.com/embed/Fx2TrJHkUc0" title="CodeRabbit CLI + Cursor integration demo" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen />

## Why integrate these tools

<CardGroup cols={2}>
  <Card title="Expert issue detection" icon="search">
    CodeRabbit spots race conditions, memory leaks, and logic errors that
    generic linters miss. Same pattern recognition that powers our PR reviews.
  </Card>

  <Card title="AI-powered fixes" icon="wand">
    Cursor implements fixes with full context from CodeRabbit's analysis.
    Complex architectural changes are handled intelligently.
  </Card>

  <Card title="Context preservation" icon="brain">
    CodeRabbit's `--agent` mode gives Cursor structured findings with file
    locations, severity, and suggested approaches.
  </Card>

  <Card title="Agentic development loop" icon="refresh-cw">
    Run a better agentic development loop - AI codes, runs reviews, applies
    fixes, and iterates before you even look at the code.
  </Card>
</CardGroup>

## Prerequisites

<Warning>
  **Windows users:** The CodeRabbit CLI requires WSL (Windows Subsystem for
  Linux) to run on Windows. See our [WSL on Windows guide](/cli/wsl-windows) for
  setup instructions before proceeding with this integration.
</Warning>

<Steps>
  <Step title="Install Cursor">
    Install Cursor and set up an account if needed.
  </Step>

  <Step title="Install CodeRabbit CLI">
    Install the CodeRabbit CLI globally on your system:

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

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

    Restart your shell:

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

  <Step title="Authenticate CodeRabbit">
    Create an account or log in to CodeRabbit if you already have one by running this command in your terminal:

    ```
    coderabbit auth login
    ```

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

    If you belong to multiple CodeRabbit organizations, the sign-in choice sets your default org only. Review attribution still depends on the current repository. See [Organization selection](/cli#organization-selection).

    <Info>
      Free accounts get a limited set of reviews per hour, and less comprehensive reviews. Pro accounts get higher review limits, and more robust reviews. See [coderabbit.ai/pricing](https://www.coderabbit.ai/pricing) for more details.
    </Info>
  </Step>

  <Step title="Verify auth">
    Verify authentication was successful by running in your terminal:

    ```
    Run: coderabbit auth status
    ```

    Success shows your login status and confirms everything is set correctly.
  </Step>

  <Step title="Test that Cursor can run CodeRabbit">
    Open up the chat interface in Cursor (Command +L) and prompt it:

    ```text wrap theme={null}
    Let's verify you can run the CodeRabbit CLI. Run the terminal command: coderabbit auth status and tell me the output.
    ```

    Because prompts and agents are non-deterministic, meaning every response will vary, and we can't predict with certainty every outcome, sometimes Cursor (and other agents) will try to install CodeRabbit as a package, or try to run other commands to determine what CodeRabbit is. In this case, it's recommended that you create a Cursor Rule, covered in the step below.
  </Step>

  <Step title="Setup a Cursor Rule for CodeRabbit">
    Learn more about Cursor rules in their [documentation](https://cursor.com/docs/context/rules). Create a Cursor rule by running the Cursor rule command from the chat `@rule`. Enter this prompt or modify it to fit your development preferences:

    ```text wrap theme={null}
      # Running the CodeRabbit CLI

      CodeRabbit is already installed in the terminal. Run it as a way to review your code. Run the command: cr -h for details on commands available. In general, I want you to run coderabbit with the `--agent` flag. To review staged and tracked local edits (this is what we'll use most of the time), run: `coderabbit review --agent --uncommitted`.

      IMPORTANT: When running CodeRabbit to review code changes, don't run it more than 3 times in a given set of changes.
    ```
  </Step>
</Steps>

## Integration workflow

### Use CodeRabbit as part of building new features

<Steps>
  <Step title="Request implementation + review">
    Ask Cursor to implement a feature and run CodeRabbit, analyze the suggestions and apply fixes:

    ```
    Please implement phase 7.3 of the planning doc and then run coderabbit review --agent --uncommitted,
    let it run as long as it needs and fix any issues.
    ```

    Key components:

    * **Implement the feature**: Cursor codes the requested functionality
    * **Run CodeRabbit**: Uses `--agent` for structured findings Cursor can process directly
    * **Review uncommitted changes**: Uses `--uncommitted` so CodeRabbit reviews staged and tracked local edits instead of committed branch changes
    * **Fix issues**: Cursor addresses all problems CodeRabbit identifies. You can also tell it to fix critical issues and ignore nits.
  </Step>

  <Step title="Cursor implements and runs CodeRabbit">
    Cursor: 1. Implements the requested feature 2. Runs `coderabbit review --agent --uncommitted` 3. Waits, reviews may take anywhere from 7-30 minutes depending on the amount of changes.
  </Step>

  <Step title="CodeRabbit analysis and task creation">
    When CodeRabbit completes, Cursor: 1. Reads the `--agent` output (structured JSON for agent workflows) 2. Creates a task list addressing each issue CodeRabbit surfaced 3. Shows you the planned fixes before implementing them
  </Step>

  <Step title="Automated issue resolution">
    Cursor systematically works through the task list, implementing fixes for each CodeRabbit finding. The cycle continues until all issues are resolved or the limit of 3 times is reached which we set on a rule earlier.
  </Step>
</Steps>

### Example: API integration implementation

This example shows the workflow implementing a webhook handler for payment processing:

<Steps>
  <Step title="Start implementation">
    ```bash theme={null}
    # Working on payment webhook feature
    git checkout -b feature/payment-webhooks
    ```
  </Step>

  <Step title="Run integrated workflow">
    Tell Cursor to implement and review:

    ```
    Implement the payment webhook handler from the spec document.
    Then run coderabbit review --agent --uncommitted, review the suggestions then fix any critical issues. Ignore nits.
    ```
  </Step>

  <Step title="CodeRabbit analysis">
    CodeRabbit analyzes the webhook code and identifies issues: - Missing signature verification - Race conditions in payment state updates - Insufficient error handling for network failures - Webhook replay attack vulnerabilities
  </Step>

  <Step title="Cursor fixes">
    Cursor automatically applies fixes: - Adds HMAC signature verification - Implements database transactions for state consistency - Adds retry logic with exponential backoff - Includes idempotency key handling
  </Step>

  <Step title="Verification">
    The workflow continues until all critical issues are resolved or a set number of loops is reached. Cursor reports completion.
  </Step>
</Steps>

## Optimization tips

### Review commands for agent integration

When running CodeRabbit for agent use, choose the review command that best fits your workflow:

```bash theme={null}
# Structured JSON output
coderabbit review --agent

# Human-readable review output
coderabbit review

# Lighter local review policy
coderabbit review --light

# Review only committed changes
coderabbit review --committed

# Review staged and tracked local edits
coderabbit review --uncommitted

# Also review files not added to Git
coderabbit review --include-untracked
```

| Command                     | Best for                                                         |
| --------------------------- | ---------------------------------------------------------------- |
| `coderabbit review --agent` | Cursor and other agent integrations that consume structured JSON |
| `coderabbit review`         | Human-readable terminal output during manual workflows           |
| `coderabbit review --light` | Lighter local review for active development work                 |

Both output formats include specific file locations, problem descriptions, and suggested fix approaches.

### Configure CodeRabbit for Cursor

Pass Cursor guideline files with `coderabbit review -c .cursorrules .cursor/rules/team.mdc` so CodeRabbit can include how code reviews should run, your coding standards, and architectural preferences.

<Info>This is a Pro paid plan feature.</Info>

## Troubleshooting

### CodeRabbit not finding issues

If CodeRabbit isn't detecting expected issues:

1. **Check authentication status**: Run `coderabbit auth status`. Reviews require authentication through `coderabbit auth login` or an API key.
2. **Verify git status**: CodeRabbit analyzes tracked changes by default. Check `git status`; brand-new untracked files require `--include-untracked`.
3. **Choose a review scope**:
   * `coderabbit review` - tracked changes
   * `coderabbit review --uncommitted` - staged changes and tracked local edits
   * `coderabbit review --committed` - only committed changes
   * `coderabbit review --include-untracked` - also include files not added to Git
4. **Specify base branch**: If your main branch isn't `main`, use `--base`:
   * `coderabbit review --base develop`
   * `coderabbit review --base master`
5. **Review file types**: CodeRabbit focuses on code files, not docs or configuration

### Managing review duration

CodeRabbit reviews may take 7 to 30+ minutes depending on the scope of changes:

1. **Ensure background execution**: Configure Cursor to run CodeRabbit in the background so you can continue working
2. **Review smaller changesets**: Adjust what you're reviewing to reduce analysis time:
   * Use `--uncommitted` to review only staged and tracked local edits
   * Work on smaller feature branches compared to main
   * Break large features into smaller, reviewable chunks
3. **Configure the diff scope**: Control what changes are analyzed:
   * **Review uncommitted changes only**: Use `--uncommitted` to analyze staged and tracked local edits
   * **Configure base branch**: Use `--base develop` or `--base main` to set the comparison point
   * **Use feature branches**: Work on focused feature branches instead of large staging branches

<Info>
  The integration creates a more thorough review process than either tool alone.
</Info>
