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

# Gemini integration

> Enable Gemini to execute CodeRabbit directly in your development workflow. Let AI code, review, and fix issues autonomously without human intervention.

## Overview

Use CodeRabbit with Google's Gemini CLI in a full agentic loop. Code with Gemini, review the changes with CodeRabbit, and fix the issues with Gemini. In this quick guide, you'll learn how to prompt Gemini, what CodeRabbit commands to run, and what to add to your Gemini.md file.

## Video demo

[CodeRabbit CLI + Gemini integration demo](https://www.youtube.com/embed/bUsotzld3CA)

## Prerequisites

**1. Install the Gemini CLI**

Install the Gemini CLI following the [platform-specific instructions](https://geminicli.com/). Log in, and check that you can launch Gemini from your terminal.

**2. Install CodeRabbit CLI**

Install the CodeRabbit CLI globally on your system:

> [tab] Install script
>
> ```bash theme={null}
> curl -fsSL https://cli.coderabbit.ai/install.sh | sh
> ```
>
> If `coderabbit` is not available immediately after installation, start a new shell, or run the exact shell-specific reload command printed under **Next steps**. If the install script offers browser sign-in without first asking for a region, EU users should skip it and authenticate later with an explicit `--region eu`.

> [tab] Homebrew
>
> ```bash theme={null}
> brew install coderabbit
> ```
>
> If `coderabbit` is not available immediately after installation, start a new shell.

> [tab] Windows
>
> ```powershell PowerShell theme={null}
> irm https://cli.coderabbit.ai/install.ps1 | iex
> ```
>
> See [Install CodeRabbit CLI on Windows](https://docs.coderabbit.ai/cli/windows.md) for prerequisites, version pinning, and troubleshooting. If `coderabbit` is not available immediately after installation, open a new PowerShell window.

**3. Log into CodeRabbit**

Log into CodeRabbit by running the following command in your terminal:

```bash theme={null}
coderabbit auth login
```

For a first login to an EU-hosted CodeRabbit account, use `coderabbit auth login --region eu`. When no region is specified or saved, the CLI uses the US region.

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](https://docs.coderabbit.ai/cli.md#organization-selection).

> [!TIP]
>
> Authentication persists across Gemini instances - you only need to do this once per machine.

**4. Verify authentication**

Test that login was successful by running the following command in your terminal:

```bash Terminal command wrap theme={null}
coderabbit auth status
```

Success shows your login status and confirms you're logged into CodeRabbit.

## Use CodeRabbit as part of building new features

**1. CodeRabbit usage instructions for Gemini CLI**

Add the following to your Gemini.md file:

```Text Prompt for Gemini.md file wrap theme={null}
Run the CodeRabbit CLI with `coderabbit review --agent --uncommitted`. It's a long running task and may take up to 30 minutes. Check every 2 minutes if it's complete and once it's done review and validate critical fixes and recommended fixes, while ignoring nits or unnecessary changes. Then fix those and run CodeRabbit again. You can run this loop up to 3 times. Let the user know the outcomes.
```

Feel free to customize the prompt to your needs. In general you want to convey:

* How to run CodeRabbit, i.e. using the `--agent` flag and that it's a CLI tool already installed.
* That it's a long running task and may take a while. Otherwise it may time out.
* Any guidelines for how you want Gemini to review and implement the changes. i.e. fix only critical issues.
* Some agents run CodeRabbit multiple times, so let them know the total number of times it should run.

**2. Request implementation + review**

Ask Gemini to implement a feature and run CodeRabbit analysis with issue fixes:

```Text Prompt for Gemini wrap theme={null}
Please implement phase 7.3 of the planning doc and then run CodeRabbit
```

> [!TIP]
>
> Because we added how to run CodeRabbit to your Gemini.md file, Gemini should run it correctly, but it's non-deterministic, so you may need to remind it to reference the Gemini.md file for the instructions.

**3. Agentic step: Gemini implements feature and runs CodeRabbit**

Gemini: 1. Implements the requested feature 2. Runs `coderabbit review --agent`
3\. Checks CodeRabbit's progress periodically

**4. Agentic step: CodeRabbit analysis and task creation**

When CodeRabbit completes, Gemini:

1. Reads the `--agent` output
2. Reviews the issues CodeRabbit surfaced
3. Implements the fixes

**5. Agentic step: Loops to stop or resolution**

Gemini will run CodeRabbit again to verify the fixes and to make sure no other issues were introduced. This loop will continue until all critical issues are resolved or the loop limit is reached.

## 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}
# NDJSON output (one JSON object per line)
coderabbit review --agent

# Human-readable review output
coderabbit review

# Deeper review using the GitHub PR review policy
coderabbit review --deep

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

Deep review requires CLI 0.8.0 and a compatible server. See [deep review behavior and compatibility](https://docs.coderabbit.ai/cli.md#review-modes).

| Command | Best for |
| - | - |
| `coderabbit review --agent` | Gemini and other agent integrations that consume NDJSON, one JSON object per line |
| `coderabbit review` | Human-readable terminal output during manual workflows |
| `coderabbit review --deep` | Deeper review using the GitHub PR review policy |

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

### Configure CodeRabbit for Gemini

Pass your Gemini context file with `coderabbit review -c GEMINI.md`. Add context on how code reviews should run, your coding standards, and architectural preferences.

Essentials Plan (Passing a Gemini context file to CodeRabbit CLI is available on Essentials and higher paid plans.)

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

### Managing review duration

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

1. **Ensure background execution**: Configure Gemini 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


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.