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

# CLI Command Reference

> Complete reference for all CodeRabbit CLI commands and options.

## Commands

`cr` is the short alias for `coderabbit`. Both work identically — use whichever fits your workflow.

| Command              | Description                                                                                                                                                              |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `cr`                 | Run code review in non-interactive plain text mode (default)                                                                                                             |
| `cr --plain`         | Output detailed feedback in plain text format                                                                                                                            |
| `cr --agent`         | Output structured JSON for agent-driven workflows                                                                                                                        |
| `cr review --light`  | Request a lighter CLI review for active local development                                                                                                                |
| `cr auth`            | Authentication commands                                                                                                                                                  |
| `cr auth login`      | Authenticate via browser OAuth, [self-hosted](/cli/cli-with-self-hosted-CodeRabbit) (`--self-hosted`), or [API key](/cli/headless-cli-integration) (`--api-key "<key>"`) |
| `cr auth logout`     | Log out from CodeRabbit                                                                                                                                                  |
| `cr auth status`     | Show current authentication status                                                                                                                                       |
| `cr auth org`        | Choose or switch the login/default organization for browser-based auth                                                                                                   |
| `cr stats`           | Show review statistics                                                                                                                                                   |
| `cr doctor`          | Check the CLI installation, local storage, authentication, Git repository state, update policy, and service connectivity                                                 |
| `cr review`          | AI-driven code reviews with plain text or agent output                                                                                                                   |
| `cr review findings` | Show review comments stored locally for the current review context                                                                                                       |
| `cr update`          | Check for and install the latest CLI version                                                                                                                             |

## Review modes

| Mode                | Description                                                        |
| ------------------- | ------------------------------------------------------------------ |
| Default / `--plain` | Detailed plain text feedback in the terminal                       |
| `--agent`           | Structured JSON output for coding agents and automation            |
| `--light`           | Faster local review policy for feedback on active development work |

## `--agent` review output

`cr review --agent` writes one JSON object per line to `stdout`. Read the stream line by line and handle events by their `type`.

| Field                 | Description                                                                 |
| --------------------- | --------------------------------------------------------------------------- |
| `type`                | Always `finding` for review results                                         |
| `severity`            | One of: `critical`, `major`, `minor`, `trivial`, `info`                     |
| `fileName`            | File path for the finding                                                   |
| `codegenInstructions` | Agent-oriented fix instructions                                             |
| `suggestions`         | Suggested fix commands or snippets                                          |
| `comment`             | Human-readable review comment, included when `codegenInstructions` is empty |

Other event types in the stream include `review_context`, `status`, `heartbeat`, `complete`, and `error`.

`heartbeat` events are periodic keep-alive signals — reset timeout timers on receipt and otherwise ignore them. For `finding` events, use `codegenInstructions` for agent fix logic and fall back to `comment` when it is absent.

When the selected review scope has no file changes, `cr review --agent` still emits the `review_context` event, then emits a `status` event with `status: "review_skipped"` and a `complete` event with `status: "review_skipped"`, `findings: 0`, and `message: "No changes detected"`. Plain mode prints a no-changes message and exits without starting a review.

## Diagnostics

Run `cr doctor` when installation, authentication, or review startup fails. 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

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

## Stats command

| Command              | Description                             |
| -------------------- | --------------------------------------- |
| `cr stats`           | Show stats (builds on first run)        |
| `cr stats --rebuild` | Rescan review history and rebuild stats |

## Agent-friendly auth commands

| Command                  | Description                                                                                           |
| ------------------------ | ----------------------------------------------------------------------------------------------------- |
| `cr auth login --agent`  | Browser-based OAuth login with structured JSON events for agents                                      |
| `cr auth logout --agent` | Log out with structured JSON events for agents                                                        |
| `cr auth status --agent` | Return authentication status as structured JSON                                                       |
| `cr auth org --agent`    | Return organization data as structured JSON for agent workflows; starts browser OAuth first if needed |

For GitHub Actions and other non-interactive environments, use `cr auth login --api-key "<key>"` and follow the [Headless CLI integration](/cli/headless-cli-integration) guide.

`cr auth org` changes the login/default org for browser-based auth. Review attribution still depends on the current repository, while API-key auth always uses the API key's organization.

## Options

| Option                    | Description                                                                                                                                            |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `--plain`                 | Output detailed feedback in plain text format (default)                                                                                                |
| `--agent`                 | Output structured JSON for agent-driven workflows                                                                                                      |
| `--light`                 | Request the lighter CLI review policy                                                                                                                  |
| `-t, --type <type>`       | Review type: all, committed, uncommitted (default: `all`)                                                                                              |
| `-c, --config <files...>` | Additional instructions for CodeRabbit AI (for example, `claude.md` or `coderabbit.yaml`)                                                              |
| `--base <branch>`         | Base branch for comparison                                                                                                                             |
| `--base-commit <commit>`  | Base commit on current branch for comparison                                                                                                           |
| `--api-key "<key>"`       | Agentic [API key](/cli/headless-cli-integration) for non-browser or headless authentication (auto-detected if logged in via `cr auth login --api-key`) |
| `--dir <path>`            | Review directory path (must contain an initialized Git repository)                                                                                     |
| `--show-prompts`          | Print saved AI prompts from the most recent local review without running a new review                                                                  |

<Info>
  `--agent` is supported in authentication workflows as well as reviews.
  `cr auth login --agent` applies to the browser-based OAuth login flow and is
  not used with `--self-hosted` or `--api-key` login.
</Info>

<Info>
  PR reviews and CLI reviews will differ, even if run on the same code. CLI
  reviews optimize for immediate feedback during active development, while PR
  reviews provide comprehensive team collaboration context and broader
  repository analysis.
</Info>
