> ## 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 --interactive`   | Launch the interactive terminal review UI                                                                                                                                |
| `cr --agent`         | Output structured JSON for agent-driven workflows                                                                                                                        |
| `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`        | Switch between organizations                                                                                                                                             |
| `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, interactive, 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 |
| `--interactive`     | Browsable terminal UI for manual review                 |

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

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

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

## Options

| Option                    | Description                                                                                                                         |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `--plain`                 | Output detailed feedback in plain text format (default)                                                                             |
| `--agent`                 | Output structured JSON for agent-driven workflows                                                                                   |
| `--interactive`           | Launch the interactive review UI                                                                                                    |
| `-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 usage-based reviews (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>
