委託模式把工作切開:OCR 負責確定性工程(檔案篩選、規則解析、排除邏輯),宿主 Agent 使用自身的 LLM 能力執行實際評審。OCR 端不需要配置 LLM。
專為訂閱制 AI 編碼代理設計——Claude Code、Codex、Cursor、OpenCode、Qoder 等:
which ocr || npm install -g @alibaba-group/open-code-review
不需配置 LLM——委託模式在 OCR 端不呼叫任何 LLM。
# Claude Code — Command
mkdir -p .claude/commands
curl -o .claude/commands/delegate-review.md \
https://raw.githubusercontent.com/alibaba/open-code-review/main/plugins/open-code-review/claude-code/commands/delegate-review.md
# 任意 Agent — Skill
npx skills add alibaba/open-code-review --skill open-code-review-delegate
ocr delegate preview # 工作區
ocr delegate preview --from main --to feature
ocr delegate preview -c abc123 # 單次提交
輸出 mode(workspace/range/commit)、ref 元資料、可評審檔案清單(路徑、狀態、插入/刪除行數)、已排除檔案與原因。
ocr delegate rule <path1> <path2> ...
依規則內容分組輸出——共享相同規則的檔案歸為一組,避免重複。
# Range 模式
git diff <merge_base>..<to> -- <path>
# Commit 模式
git show <commit> -- <path>
# Workspace 模式
git diff HEAD -- <path> # 已追蹤檔案
cat <path> # 新的未追蹤檔案
| 命令 | 用途 |
|---|---|
ocr delegate preview | 列出可評審檔案 + mode/ref 元資料 |
ocr delegate rule <path...> | 依內容分組解析評審規則 |
通用旗標:--from / --to / -c --commit / --repo / --rule / --exclude / -b --background / -B --background-file。
| 模式 | 誰呼叫 LLM? | 適用場景 |
|---|---|---|
| Agent Skill | OCR | OCR 驅動完整評審 |
| Command(Claude Code) | OCR | 斜線命令,OCR 驅動,自動修復 |
| 委託模式 | 宿主 Agent | OCR 提供腳手架,Agent 驅動評審 |
委託模式的核心是職責分離:
OCR 端完全不呼叫 LLM,所以不需要 API key。這是與 Agent Skill / Command 的本質差異。
Step 1 ocr delegate preview 的輸出不只是清單——它包含 mode(workspace/range/commit)、merge_base、以及每個檔案的排除原因。先看排除原因再決定是否調整 --exclude。Step 2 ocr delegate rule 會自動按規則內容分組——共享相同規則的檔案只出現一次規則文本,避免重複。
選哪個?看兩個問題:① OCR 的 LLM 要用誰的?② 要自動修復嗎?