
1. Opening: why you need this tool
Every code review, you run into the same scenes: a PR touches 30 files, the AI tool comments on 8 and silently skips the rest; after finally locating a bug, the line numbers drift and the comment floats onto a blank line in the neighboring file; you change one line of prompt and output quality becomes a lottery, good one day and bad the next. These problems recur across general-purpose agents (Claude Code / Codex / Cursor), and the root cause is that a purely language-driven architecture has no hard constraints. Code review is not a chat: accuracy and stability are the real metrics.
2. Project overview: what it is in one sentence
OpenCodeReview is Alibaba's open-source AI code review CLI. It started as the internal official review assistant, serving tens of thousands of developers for two years and catching millions of defects before being spun out. It uses a hybrid "deterministic engineering pipeline + LLM agent" architecture, focusing on line-precise comments, built-in multi-language rule sets (NPE, thread safety, XSS, SQL injection) and compatibility with both the OpenAI and Anthropic protocols. GitHub stars have passed 20K, and it holds OpenSSF Gold certification.
3. Core features in depth
1. Line-precise comments
OpenCodeReview solves line drift with "external localization + a reflection module". Comment localization and content generation run serially in separate modules: first pin down the file and line, then have the model reflect on whether the comment matches the code. Compared with the general-agent approach of "generate once, put it wherever", localization accuracy is markedly higher, and engineers stop scrolling through code to find a comment.
2. Smart file batching
For large PRs, the system groups related files into the same review unit (for example message_en.properties and message_zh.properties must be read together), and each batch runs as an independent sub-agent in an isolated context. This is divide and conquer: it keeps large change sets stable and naturally supports concurrent review, so CI wait times stay predictable.
3. Fine-grained rule matching
Template-engine-based rule matching dispatches rule sets according to file characteristics, so the model's attention stays on the risks that matter for the current file. Compared with stuffing a long block of rule text into the prompt, the matching process is more stable and more predictable, and output noise drops noticeably.
4. Full-file scanning (ocr scan)
It reviews more than diffs: ocr scan reviews an entire file, which is useful when auditing an unfamiliar codebase or a directory with no git history. Combined with --resume session recovery, an interrupted run can continue seamlessly.
4. Technical highlights and performance data
Benchmarks were run on 50 popular open-source repositories, 200 real PRs and 10 programming languages, with 1,505 ground-truth items cross-annotated by more than 80 senior engineers. Results:
- F1 and Precision are clearly higher than general-purpose agents (same model comparison)
- Average token consumption is about 1/9 of a general-purpose agent
- Average review time is shorter
By design, the toolset was distilled from how tools are actually invoked on large-scale production data — call frequency, duplication rate and the impact of new tools — and is built specifically for code review rather than as a general agent toolkit. On the ecosystem side, the CLI runs natively on Windows / macOS / Linux, ships plugins for Claude Code, Codex, Cursor and OpenCode, and integrates with GitHub Actions, GitLab CI, GitFlic CI and Gerrit.

5. Use cases and audience
Scenario 1: reviewing large PRs
When a feature branch touches 50+ files across modules, OpenCodeReview's file batching plus concurrent sub-agents covers every change reliably, avoiding the selective skimming that general-purpose agents fall into.
Scenario 2: CI/CD gates
Wire it into GitHub Actions / GitLab CI and every push gets reviewed automatically. High F1 with low token use means predictable cost and little noise, so it never floods the PR and blocks merges.
Scenario 3: auditing legacy code
When you inherit a legacy system or audit open-source code, run ocr scan --path internal/ for a full scan. No git diff needed — you get a risk list directly.
A good fit for mid-sized and large teams that want high Precision, care about API cost and run CI pipelines. Not a good fit for individuals who just want "chat-style code Q&A" and don't need line-accurate comments.
6. Comparison with alternatives
| Dimension | OpenCodeReview | General agents (Claude Code/Codex) | Traditional static analysis (SonarQube etc.) |
|---|---|---|---|
| Architecture | deterministic pipeline + agent hybrid | purely language-driven | rule matching, no LLM |
| Location accuracy | line-level, dedicated localization module | drifts easily | N/A (reports by rule) |
| Token cost | about 1/9 of general agents | baseline | very low (no LLM calls) |
| Context understanding | agent sub-units with isolated context | global context | weak |
| Custom rules | built-in NPE/thread safety/XSS/SQL injection | via prompt | strong |
| Stability on large change sets | batching + concurrency, stable | prone to skipping files | stable |
The core reason to pick OpenCodeReview: general agents are flexible but unstable, traditional static analysis is stable but lacks contextual understanding, and OpenCodeReview welds the strengths of both together.

7. How to get started fast
Install
npm install -g @alibaba-group/open-code-review
After installation the ocr command is available globally. Install scripts, GitHub Release binaries and building from source are also supported; see the official docs.
Configure the LLM
ocr config provider # choose a built-in provider or add a custom one
ocr config model # choose a model for the current provider
The interactive UI walks you through picking a provider, entering an API key, selecting a model and running a connectivity test automatically. The OpenAI and Anthropic compatible protocols work out of the box.
Minimal working example
cd your-project
# Workspace mode: review all staged, unstaged and untracked changes
ocr review
# Branch range: review everything on feature-branch since it forked from main
ocr review --from main --to feature-branch
# A single commit
ocr review --commit abc123
# Full scan (no git diff needed)
ocr scan --path internal/agent
# Delegate mode: let the host agent (Claude Code / Codex, etc.) do the reviewing,
# while OCR only handles file selection and rule resolution
ocr delegate preview
ocr delegate rule src/main.go src/handler.go
Advanced tips
- Add
--from main --to HEADin CI so every PR is reviewed automatically - Use
ocr session listto inspect past sessions and resume from a breakpoint - Hook up OpenTelemetry for observability and track tokens and latency per PR

8. Summary and next steps
With its hybrid "deterministic engineering + agent" architecture, OpenCodeReview pulls code review away from "hoping the prompt works" and back to "engineering-grade, stable output". Higher F1, one-ninth the tokens of a general agent, line-level accuracy, and two years of large-scale production validation at Alibaba make it a dependable way for mid-sized and large teams to gate code quality in CI.
- GitHub: https://github.com/alibaba/open-code-review
- Website: https://open-codereview.ai
- Docs: https://open-codereview.ai/docs
- npm:
@alibaba-group/open-code-review
One-line recommendation: for line-level accuracy, low token cost and stable CI runs, choose OpenCodeReview.
