alibaba/open-code-review
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.
這是什麼
OpenCodeReview 是 Alibaba 開源的 AI code review CLI,定位不是泛用聊天代理,而是專門為程式碼審查設計的工具。README 說它源自 Alibaba Group 內部官方 AI code review assistant,過去兩年服務過數萬名開發者、識別出數百萬個 code defects,之後才孵化為開源專案。它會讀取 Git diff,把變更檔案交給可設定的 LLM,透過具備 tool-use 能力的 agent 產生 line-level precision 的結構化審查意見;agent 也能讀完整檔案、搜尋 codebase、檢查其他變更檔案取得脈絡。除了 diff review,ocr scan 還能針對整個檔案或目錄做 full-file scan,適合沒有明確 diff 的陌生程式碼稽核。
為什麼上榜
這週它爆紅的原因很清楚:AI code review 已經不是新題目,但 README 主打的是 deterministic engineering × agent hybrid,也就是把不能出錯的流程交給工程邏輯約束,把需要判斷與脈絡檢索的部分交給 agent。專案目前有 38,367 stars,本週新增 15,504 stars,熱度非常集中。README 也提出 benchmark:基於 50 個熱門開源 repo、200 個真實 PR、10 種程式語言,並由 80+ senior engineers 交叉驗證出 1,505 個 ground-truth issues。它宣稱相較 general-purpose agents,在同底層模型下有更高 Precision 與 F1、token 約為 1/9,但 Recall 較低;這個取捨很重要,代表它刻意偏向降低誤報與審查噪音,而不是追求抓到所有可能問題。
適合誰,可以拿來做什麼
OpenCodeReview 適合已經在用 AI coding agent、但對「審查品質不穩、line number 飄移、大片 changeset 覆蓋不完整」感到困擾的團隊。README 直指 general-purpose agents 的痛點:大型變更容易挑檔案看、回報位置可能漂移、用自然語言 Skills 控制審查流程難以除錯。它的設計比較像 CI/本地審查工具,而不只是 prompt 套件;可用在 workspace mode、branch range、single commit、full-file scan,也能把結果輸出成 JSON 供 AI host agents 或其他流程讀取。對企業或大型 repo 來說,精準檔案選擇、智慧分組、細粒度規則匹配、外部定位與反思模組 這些設計,比單純「叫模型幫我 review」更可控。
上手
README 提供 npm 全域安裝,前置需求是 Git >= 2.41:
npm install -g @alibaba-group/open-code-review
安裝後會有 ocr 指令。一般模式需要先設定 LLM provider 與 model:
ocr config provider
ocr config model
接著在專案目錄中執行審查:
ocr review
ocr review --from main --to feature-branch
ocr review --commit abc123
ocr scan --path internal/agent
ocr review --format json --output result.json
README 也提到 Delegation Mode,可讓 coding agent 本身執行 review,OCR 負責檔案選擇與規則解析,不一定需要 OCR 自己配置 API key。
README 重點摘要
- OpenCodeReview 是專門的 AI code review CLI,支援 diff review 與 full-file scan,並輸出 line-level comments。
- 核心架構把 deterministic pipeline 與 LLM agent 分工:前者處理檔案選擇、分組、規則匹配與定位;後者做動態判斷與脈絡檢索。
- Benchmark 以 50 個 repo、200 個 PR、10 種語言與 1,505 個標註問題建立,README 強調 Precision/F1 與 token 成本優勢,但也承認 Recall 較低。
- CLI 支援 workspace、branch range、single commit、session resume、JSON output、scan 以及 delegate preview/rule 等流程。
- 支援 Claude Code、Codex、Cursor、Kimi Code、OpenCode 等 coding agent integration,並提供 CI/CD、Session Viewer、Telemetry、MCP Server 等文件入口。