The open source AI code review agent.
English | 简体中文
AI-powered code review CLI that reads Git diffs, sends changed files to a configurable LLM via an agent with tool-use capabilities, and generates structured review comments with line-level precision.
The agent can read full file contents, search the codebase, inspect other changed files for context, and produce deep reviews — not just surface-level diff feedback.

Install
Via NPM (Recommended)
npm install -g @alibaba-group/open-code-review
After installation, the ocr command is available globally.
From GitHub Release
Download the latest binary from GitHub Releases:
# macOS (Apple Silicon)
curl -Lo ocr https://github.com/alibaba/open-code-review/releases/latest/download/opencodereview-darwin-arm64
chmod +x ocr && sudo mv ocr /usr/local/bin/ocr
# macOS (Intel)
curl -Lo ocr https://github.com/alibaba/open-code-review/releases/latest/download/opencodereview-darwin-amd64
chmod +x ocr && sudo mv ocr /usr/local/bin/ocr
# Linux (x86_64)
curl -Lo ocr https://github.com/alibaba/open-code-review/releases/latest/download/opencodereview-linux-amd64
chmod +x ocr && sudo mv ocr /usr/local/bin/ocr
# Linux (ARM64)
curl -Lo ocr https://github.com/alibaba/open-code-review/releases/latest/download/opencodereview-linux-arm64
chmod +x ocr && sudo mv ocr /usr/local/bin/ocr
From Source
git clone https://github.com/alibaba/open-code-review.git
cd open-code-review
make build
sudo cp dist/opencodereview /usr/local/bin/ocr
Quick Start
1. Configure LLM
You must configure an LLM before reviewing code.
# Option A: Interactive config
ocr config set llm.url https://api.anthropic.com/v1/messages
ocr config set llm.auth_token your-api-key-here
ocr config set llm.model claude-opus-4-6
ocr config set llm.use_anthropic true
# Option B: Environment variables (highest priority)
export OCR_LLM_URL=https://api.anthropic.com/v1/messages
export OCR_LLM_TOKEN=your-api-key-here
export OCR_LLM_MODEL=claude-opus-4-6
export OCR_USE_ANTHROPIC=true
Config is stored in ~/.opencodereview/config.json.
The tool also falls back to Claude Code environment variables (ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_MODEL) and parses ~/.zshrc / ~/.bashrc for those exports.
2. Test Connectivity
ocr llm test
3. Review
cd your-project
# Workspace mode — review all staged, unstaged, and untracked changes
ocr review
# Branch range — compare two refs
ocr review --from main --to feature-branch
# Single commit
ocr review --commit abc123
Commands
| Command | Alias | Description |
|---|
ocr review | ocr r | Start a code review |
ocr rules check <file> | — | Preview which review rule applies to a file path |
ocr config set <key> <value> | — | Set configuration values |
ocr llm test | — | Test LLM connectivity |
ocr viewer | ocr v | Launch WebUI session viewer on localhost:5483 |
ocr version | — | Show version info |
ocr review Flags
| Flag | Shorthand | Default | Description |
|---|
--repo | — | current dir | Git repository root |
--from | — | — | Source ref (e.g., main) |
--to | — | — | Target ref (e.g., feature-branch) |
--commit | -c | — | Single commit to review |
--preview | -p | false | Preview which files will be reviewed without running the LLM |
--format | -f | text | Output format: text or json |
--concurrency | — | 8 | Max concurrent file reviews |
--timeout | — | 10 | Concurrent task timeout in minutes |
--audience | — | human | human (show progress) or agent (summary only) |
--rule | — | — | Path to custom JSON review rules |
--tools | — | — | Path to custom JSON tools config |
Examples
# Preview which files will be reviewed (no LLM calls)
ocr review --preview
ocr review -c abc123 -p