open-code-review README

项目的 README,来自 github.com/alibaba/open-code-review。合并为一个 markdown 文件:README.md。

OpenCodeReview logo

OpenCodeReview

alibaba%2Fopen-code-review | Trendshift

alibaba%2Fopen-code-review | Trendshift alibaba%2Fopen-code-review | Trendshift

npm Build status License Ask DeepWiki OpenSSF Best Practices

Windows macOS Linux Claude Code Codex Cursor Kimi Code

English | 简体中文 | 日本語 | 한국어 | Русский | Türkçe | Français | Tiếng Việt


What is Open Code Review?

Open Code Review is an AI-powered code review CLI tool. It originated as Alibaba Group's internal official AI code review assistant — over the past two years, it has served tens of thousands of developers and identified millions of code defects. After thorough validation at massive scale, we incubated it into an open source project for the community. Simply configure a model endpoint to get started.

It 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. Beyond diff review, ocr scan reviews entire files for auditing unfamiliar codebases or directories that have no meaningful diff.

Visit the official website for more details.

Highlights

Benchmark

Compared to general-purpose agents (Claude Code), Open Code Review achieves significantly higher Precision and F1 with the same underlying model, while consuming only ~1/9 of the tokens and completing reviews faster. Note that its Recall is lower than general-purpose agents — a deliberate trade-off favoring precision over noise.

A real-world code review benchmark built from 50 popular open-source repositories, 200 real Pull Requests, and 10 programming languages — cross-validated by 80+ senior engineers (1,505 annotated ground-truth issues).

Hugging Face Explore the AACR-Bench dataset on Hugging Face.

Metric What it measures Why it matters
F1 Harmonic mean of precision and recall Best single number for overall review quality
Precision Proportion of reported issues that are real defects Higher = fewer false alarms to triage
Recall Proportion of real defects that are found Higher = fewer issues slip through review
Avg Time Wall-clock time per review Matters for CI pipeline latency
Avg Token Total tokens consumed per review Directly impacts API cost

Benchmark

Why Open Code Review?

The Problem with General-Purpose Agents

If you've used general-purpose agents like Claude Code with Skills for code review, you've likely encountered these pain points:

The root cause: a purely language-driven architecture lacks hard constraints on the review process.

Core Design: Deterministic Engineering × Agent Hybrid

Open Code Review's core philosophy is to combine deterministic engineering with an agent, each handling what it does best.

Deterministic Engineering — Hard Constraints

For review steps that must not go wrong, engineering logic — not the language model — guarantees correctness:

Agent — Dynamic Decision-Making

The agent's strengths are concentrated where they matter most — dynamic decisions and dynamic context retrieval:

How to Use

Prerequisites

Agent Skills

Use the skills in Claude Code, Codex, Cursor, Kimi Code, or another agent that supports Agent Skills and can run local commands. Both modes require Git >= 2.41 and the ocr CLI; only native mode requires an OCR model provider.

1. Install the Skills

Run in the project you want to review, then select the skills you need and your agent in the installer:

npx skills add alibaba/open-code-review

The skills guide your agent to install ocr if it is missing, subject to your environment's permissions. You can also install it ahead of time with npm install -g @alibaba-group/open-code-review. Prefer a plugin or manual installation? See the agent-specific setup guide, or copy the desired folders from skills/ into your agent's skill directory.

2. Choose a Review Mode

Native mode Delegation mode
Skill open-code-review open-code-review-delegate
Who reviews? OCR's specialized review agent and pipeline Your current coding agent, following OCR's review pipeline and guardrails
Model and authentication OCR's own provider configuration Your host agent's existing model and authentication
Choose it when You have a model endpoint for OCR and want its full review pipeline You have no separate API key, or want to use your existing agent subscription/setup

No separate key? Start with delegation mode. It skips OCR provider setup, not the host agent's own authentication, usage limits, or costs. A host-agent subscription is not automatically an API credential for native mode. In delegation mode, OCR's CLI and skill together provide the review pipeline and guardrails: file selection, rule resolution, coverage requirements, and structured reporting. The host agent performs analysis, positioning, and reporting within that workflow; it does not run OCR's full native pipeline.

For native mode, configure a provider once with ocr config provider and ocr config model. Authentication depends on the provider; see Configuration.

CLI

Install

npm install -g @alibaba-group/open-code-review

After installation, the ocr command is available globally.

For other installation methods (install script, GitHub Release binary, from source), see Installation.

Quick Start

1. Configure LLM

You must configure an LLM before reviewing code, unless you use Delegation Mode.

ocr config provider          # Select a built-in provider or add a custom one
ocr config model             # Pick a model for the active provider

Model providers

The interactive UI guides you through provider selection, API key entry, and model configuration, then automatically tests connectivity.

For CLI setup, environment variables, custom providers, and other advanced configuration, see Configuration.

2. Review

cd your-project

# Workspace mode — review all staged, unstaged, and untracked changes
ocr review

# Current branch — review changes since it diverged from main (--to defaults to HEAD)
ocr review --from main

# Branch range — reviews feature-branch's changes since it diverged from main (merge-base mode)
ocr review --from main --to feature-branch

# Single commit
ocr review --commit abc123

# Resume an interrupted range or commit review
ocr session list
ocr review --from main --to feature-branch --resume <session-id>

# Full-file scan — review whole files instead of a diff (no git history needed)
ocr scan                          # scan the entire repository
ocr scan --path internal/agent    # scan a directory or specific files
ocr scan --resume <session-id>   # resume an interrupted full-file scan

# Save results to a file (recommended for AI host agents)
ocr review --format json --output result.json

# Delegation mode — let your AI coding agent perform the review itself
# OCR handles file selection and rule resolution; no LLM configuration needed
ocr delegate preview
ocr delegate rule src/main.go src/handler.go

Documentation

Full documentation lives at open-codereview.ai/docs:

Contributing

This project exists thanks to all the people who contribute. See CONTRIBUTING.md for development setup, coding guidelines, and how to submit pull requests.

License

Apache-2.0 — Copyright 2026 Alibaba

open-code-review (alibaba/open-code-review)

正在搜索数据库…

这是什么?一款诞生于阿里巴巴内部的 AI 代码审查命令行工具:它读取 Git 差异,把改动的文件发送给可配置的 LLM 智能体,并返回精确到代码行的结构化审查意见。
它是独立的命令行工具,还是集成在我编辑器里的东西?是一个独立的命令行工具——安装后 ocr 命令全局可用。此外还提供编码智能体插件(Claude Code、Codex、Cursor、Kimi Code、OpenCode)以及一个用于扩展审查智能体的 MCP 服务器。
把它跑起来需要做些什么?先安装,然后运行交互式设置:它会引导你选择服务商、输入 API 密钥并配置模型,还会在你首次审查前自动测试连通性。
在它能正常工作之前,我的电脑上需要装什么?需要 Git >= 2.41——ocr 依赖 Git 来生成差异、搜索代码和执行仓库操作——而且在审查代码之前你必须先配置好一个 LLM 接入点。
它能发现我改动里的每一个缺陷吗?不能——它的召回率刻意低于通用智能体,以此换取精确度:误报更少、需要排查的噪音更少,F1 分数更高,而且每次审查消耗的 token 大约只有九分之一。
它能在所有主流操作系统上运行吗?可以——文档覆盖了所有平台和包管理器的安装方式,还提供 GitHub Release 的二进制文件,所以 Linux、macOS 和 Windows 都没问题。
审查过程中我的代码会怎样?改动的文件会被发送到你配置的 LLM 接入点——ocr 读取 Git 差异,智能体通过该模型检查这些文件,所以代码去哪里取决于你选择的服务商。
为什么要用确定性流水线搭配 LLM 智能体?纯靠语言驱动的审查往往会在大规模改动上偷工减料,偏离实际的代码位置,而且结果会随提示词的微调而波动。这里由工程逻辑锁定文件选择、打包和规则匹配,智能体则负责动态决策和上下文检索。
它能审查整个文件而不只是差异吗?可以——ocr scan 会审查整个文件,适合审计不熟悉的代码库,或者没有有意义差异可看的目录。
什么是委派模式(Delegation Mode)?一种执行模式:由你的编码智能体用它自己的 LLM 来运行审查,因此不需要 OCR API 密钥;默认情况下,OCR 使用你为它配置的模型来运行审查。
审查可以在 CI 中自动运行吗?可以——文档涵盖了 GitHub Actions、GitLab CI、GitFlic CI 和 Gerrit 集成,所以审查可以在每次拉取请求时自动运行。
作者
alibaba
大小
57.1 MB
星标
57.2K
时长
6个月
提交 · 90 天