open-code-review

alibabaApache-2.0活跃维护

阿里开源的大规模代码审查工具,用确定性流水线加 LLM Agent 混合架构,精准定位行级问题,内置 NPE、线程安全、XSS、SQL 注入等多语言规则集。

Secure, fast, efficient, battle-tested at Alibaba's scale. Hybrid architecture code review tool: deterministic pipelines + LLM Agent, precise line-level comments, built-in multi-language ruleset (NPE, thread-safety, XSS, SQL injection), OpenAI & Anthropic compatible.

v1.13.6发布于 2026-11-05 11:49 UTC49,754star +167 / 7 天3,666fork同步于 2026-11-10 11:19 UTC

怎么上手

由 README 提炼,执行前请确认
npm install -g @alibaba-group/open-code-review
ocr config provider
ocr review
硬件要求按 README 说明

README 未说明本地显存或 GPU 要求,模型通过可配置的 LLM 端点(OpenAI、Anthropic 兼容)调用;CLI 支持 Windows、macOS、Linux。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

阿里开源的 AI 代码审查 CLI,用确定性流水线加 LLM Agent 做行级精准评审

阿里开源的大规模代码审查工具,用确定性流水线加 LLM Agent 混合架构,精准定位行级问题,内置 NPE、线程安全、XSS、SQL 注入等多语言规则集。

核心能力

  • 确定性工程负责选文件与打包,Agent 只做评审
  • 按文件包拆子 Agent 隔离上下文,支持并发
  • 输出行级精准的结构化评审意见
  • 内置 NPE、线程安全、XSS、SQL 注入等多语言规则集
  • 支持 ocr scan 全文件扫描,无需 git 历史

容易踩的坑

使用前必须先配置 LLM provider 和 model,否则无法评审(除非用 Delegation 模式);Delegation 模式由宿主编码 Agent 自行评审,不需要 OCR 的 API key;中断的范围或提交评审需用 ocr session list 配合 --resume 续跑。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v1.13.6
  1. v1.13.6最新正式版2026-11-05 · 2026-11-05 11:49 UTC

    🚀 Features

    • feat(pages): showcase supported model providers (#1862)
    • feat(lang): review Starlark files (#1851)
    • feat(rules): add C# review rules (#1840)

    🐛 Bug Fixes

    • fix(llm): preserve explicit false stream override (#1531)
    • fix(action): only rewrite the bot's own summary comment (#1560)

    Full Changelog: https://github.com/alibaba/open-code-review/compare/v1.13.5...v1.13.6

  2. v1.13.52026-11-03 · 2026-11-03 14:43 UTC
    查看更新说明

    🚀 Features

    • feat(allowlist): add HAML, Slim and ERB template support (#1552)
    • feat(allowlist): review .jsonc files (#1801)
    • feat(allowlist): add EJS, Liquid and Nunjucks template support (#1553)
    • feat(rules): add Scala-specific review rules (#1095)

    🐛 Bug Fixes

    • fix(diff): retry new-side hunk match without blank lines (#1777)
    • fix(diff): split a bare "diff --git" header at its separator (#1691)
    • fix(review): honor lower max-tools overrides (#1118)
    • fix(diff): keep tracked gitignored files in workspace review (#1837)

    Full Changelog: https://github.com/alibaba/open-code-review/compare/v1.13.4...v1.13.5

  3. v1.13.42026-11-02 · 2026-11-02 15:19 UTC
    查看更新说明

    🐛 Bug Fixes

    • fix(tool): name missing paths in file_read_diff not-found error (#1836)
    • fix(session): print an empty items array from session show --json (#1792)
    • fix(action): keep OCR runtime stable during review (#1204)
    • fix(security): update Go to 1.26.10 and Node to 24.22.1 (#1799)

    Full Changelog: https://github.com/alibaba/open-code-review/compare/v1.13.3...v1.13.4

  4. v1.13.32026-10-22 · 2026-10-22 04:38 UTC
    查看更新说明

    🐛 Bug Fixes

    • fix(tool): report an empty code_comment batch instead of success (#1773)
    • fix(mcp): follow tools/list pagination when caching server tools (#1770)
    • fix(ci): prevent PR policy checkout state pollution (#1783)

    Other Changes

    • include pkgs/ as a provider directory for NixPkgs (#1642)

    Full Changelog: https://github.com/alibaba/open-code-review/compare/v1.13.2...v1.13.3

  5. v1.13.22026-10-20 · 2026-10-20 03:17 UTC
    查看更新说明

    🚀 Features

    • feat(allowlist): add Shader Languages support (#975)
    • feat(language): support for Nushell language (#956)
    • feat(rules): add PowerShell review support (#970)

    🐛 Bug Fixes

    • fix(scan): resolve --path like the filesystem and reject nonexistent paths (#1709)

    📖 Documentation

    • docs(contributing): update directory structure and descriptions across multiple languages (#1729)
    • docs(contributing): refresh Project Structure and add chatgptauth (#1721)

    Other Changes

    • ci: enforce PR commit policy (#1775)
    • terraform: adding .tofu extension used by opentofu (#1464)

    Full Changelog: https://github.com/alibaba/open-code-review/compare/v1.13.1...v1.13.2

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

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

    Explore the AACR-Bench dataset on Hugging Face.

    MetricWhat it measuresWhy it matters
    F1Harmonic mean of precision and recallBest single number for overall review quality
    PrecisionProportion of reported issues that are real defectsHigher = fewer false alarms to triage
    RecallProportion of real defects that are foundHigher = fewer issues slip through review
    Avg TimeWall-clock time per reviewMatters for CI pipeline latency
    Avg TokenTotal tokens consumed per reviewDirectly 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:

    • Incomplete coverage — On larger changesets, agents tend to "cut corners," selectively reviewing only some files and missing others.
    • Position drift — Reported issues frequently don't match the actual code location, with line numbers or file references drifting off target.
    • Unstable quality — Natural-language-driven Skills are hard to debug, and review quality fluctuates significantly with minor prompt variations.

    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:

    • Precise file selection — Determines exactly which files need review and which should be filtered, ensuring no important change is missed.
    • Smart file bundling — Groups related files into a single review unit (e.g., message_en.properties and message_zh.properties are bundled together). Each bundle runs as a sub-agent with isolated context — a divide-and-conquer strategy that stays stable on very large changesets and naturally supports concurrent review.
    • Fine-grained rule matching — Matches review rules to each file's characteristics, keeping the model's attention sharply focused and eliminating information noise at the source. Compared to purely language-driven rule guidance, template-engine-based rule matching is more stable and predictable.
    • External positioning and reflection modules — Independent comment-positioning and comment-reflection modules systematically improve both the location accuracy and content accuracy of AI feedback.

    Agent — Dynamic Decision-Making

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

    • Scenario-tuned prompts — Prompt templates deeply optimized for code review, improving effectiveness while reducing token consumption.
    • Scenario-tuned toolset — Distilled from deep analysis of tool-call traces in large-scale production data — including call frequency distributions, per-tool repetition rates, and the impact of new tools on the overall call chain — resulting in a purpose-built toolset that is more stable and predictable for code review than a generic agent toolkit.

    How to Use

    Prerequisites

    • Git >= 2.41 — Open Code Review relies on Git for diff generation, code search, and repository operations.

    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
    

    Provider setup

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

    • Quickstart — install and run your first review
    • Installation — all platforms and package managers
    • CLI Reference — every command and flag
    • Review Rules — customize review rules with path filtering and targeting
    • Configuration — config keys and environment variables
    • MCP Server — extend the review agent with external tools
    • Coding Agent Integrations — choose the platform you use
      • Claude Code — install a plugin with review slash commands
      • Codex — install a plugin with callable review skills
      • Cursor — install a plugin with portable review skills
      • Kimi Code — install a plugin with review slash commands and skills
      • OpenCode — install native review tools and slash commands
      • QCA Forward — run delegation mode with the QCA host model and a ready-to-publish template
      • Skill-compatible agents — install the portable agent skill
    • Review Execution Modes — after integration, choose which LLM performs the review
    • CI/CD Integration — GitHub Actions, GitLab CI, GitFlic CI, and Gerrit integration
    • Session Viewer — browse and replay review sessions in browser, mark comments as fixed or ignored and hide them while you work through the findings
    • Telemetry — OpenTelemetry integration for observability
    • FAQ — common questions and troubleshooting

    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