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

> Enable Cursor to run the CodeRabbit CLI as part of your development workflow. Let AI code, review, and fix issues autonomously without human intervention.

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

    <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 uncommitted changes (this is what we'll use most of the time) run: `coderabbit --agent -t 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 --agent -t 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 `-t uncommitted` so CodeRabbit reviews current changes instead of a feature branch or staging branch against `main`
    * **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 --agent -t 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 --agent -t 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

### Output modes for agent integration

When running CodeRabbit for agent use, choose the output mode that best fits your workflow:

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

# Detailed plain-text output
coderabbit --plain

# Browsable terminal UI
coderabbit --interactive
```

| Mode            | Best for                                                         |
| --------------- | ---------------------------------------------------------------- |
| `--agent`       | Cursor and other agent integrations that consume structured JSON |
| `--plain`       | Human-readable terminal output during manual workflows           |
| `--interactive` | Manual review in an interactive terminal UI                      |

All three modes include specific file locations, problem descriptions, and suggested fix approaches.

### Configure CodeRabbit for Cursor

CodeRabbit automatically reads your `cursor.md` file, so you can add context there on 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` (authentication improves review quality but isn't required)
2. **Verify git status**: CodeRabbit analyzes tracked changes - check `git status`
3. **Consider review type**: Use the `--type` flag to specify what to review:
   * `coderabbit --type uncommitted` - only uncommitted changes
   * `coderabbit --type committed` - only committed changes
   * `coderabbit --type all` - both committed and uncommitted (default)
4. **Specify base branch**: If your main branch isn't `main`, use `--base`:
   * `coderabbit --base develop`
   * `coderabbit --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 `--type uncommitted` to review only uncommitted changes
   * 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 `--type uncommitted` to analyze just working directory changes
   * **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

<Note>
  The integration creates a more thorough review process than either tool alone.
  Expect comprehensive analysis that catches issues that would otherwise reach
  production.
</Note>
