Skip to content

Commit 2967f2a

Browse files
docs(pages): add Delegation Mode documentation to website (#386)
Add a new Delegation Mode page under Integrations in the docs site, covering the ocr delegate subcommand workflow for subscription-based AI coding agents (Claude Code, Codex, Cursor, Open Code, Qoder). - New docs in en/zh/ja under integrations/delegate.md - Register 'delegate' slug in docs index.ts - Add sidebar entry in DocsPage.tsx - Add i18n labels for all three languages - Fix list-style-type reset caused by Tailwind Preflight in docs
1 parent 4ee453f commit 2967f2a

9 files changed

Lines changed: 486 additions & 0 deletions

File tree

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
---
2+
title: Delegation Mode
3+
sidebar:
4+
order: 5
5+
---
6+
7+
OCR handles deterministic engineering (file selection, rule resolution)
8+
while the host agent performs the actual code review using its own LLM
9+
capabilities. No LLM endpoint is required on the OCR side.
10+
11+
## When to use delegation mode
12+
13+
Delegation mode is designed for subscription-based AI coding agents —
14+
such as Claude Code, Codex, Cursor, Open Code, Qoder, etc. — where you
15+
already have an LLM subscription bundled with the host agent. Instead
16+
of configuring a separate model endpoint for OCR, you reuse the host
17+
agent's existing subscription quota to perform the review.
18+
19+
Use delegation mode when:
20+
21+
1. Your AI coding agent runs on a subscription plan and you want to
22+
reuse that quota for code review — no extra API key or model
23+
configuration needed.
24+
2. You want OCR only for its engineering scaffolding — file filtering,
25+
rule resolution, exclusion logic — while the host agent handles all
26+
LLM reasoning.
27+
3. You're building a custom agent pipeline that needs structured inputs
28+
(file list + rules) for its own review step.
29+
30+
## Prerequisites
31+
32+
The `ocr` CLI must be installed:
33+
34+
```bash
35+
which ocr || npm install -g @alibaba-group/open-code-review
36+
```
37+
38+
No LLM configuration (`ocr config set …` or environment variables) is
39+
needed — delegation mode never calls an LLM on the OCR side.
40+
41+
## Install the skill / command
42+
43+
### Claude Code — Command
44+
45+
```bash
46+
mkdir -p .claude/commands
47+
curl -o .claude/commands/delegate-review.md \
48+
https://raw.githubusercontent.com/alibaba/open-code-review/main/plugins/open-code-review/claude-code/commands/delegate-review.md
49+
```
50+
51+
### Any agent — Skill
52+
53+
```bash
54+
npx skills add alibaba/open-code-review --skill open-code-review-delegate
55+
```
56+
57+
Or copy the manifest manually:
58+
59+
```bash
60+
cp -R /path/to/open-code-review/skills/open-code-review-delegate ~/.claude/skills/
61+
```
62+
63+
## Workflow
64+
65+
### Step 1: Preview — determine what to review
66+
67+
```bash
68+
ocr delegate preview [--from <ref> --to <ref>] [--commit <hash>] [--exclude <patterns>]
69+
```
70+
71+
Outputs:
72+
73+
- **mode** — workspace / range / commit
74+
- **ref metadata** — from, to, commit, merge\_base
75+
- **Reviewable file list** — paths, status, insertions/deletions
76+
- **Excluded files** — with exclusion reason
77+
78+
Common invocations:
79+
80+
| Scenario | Command |
81+
|----------|---------|
82+
| Workspace changes | `ocr delegate preview` |
83+
| Branch comparison | `ocr delegate preview --from main --to feature` |
84+
| Single commit | `ocr delegate preview -c abc123` |
85+
86+
### Step 2: Get rules for files
87+
88+
```bash
89+
ocr delegate rule <path1> <path2> ...
90+
```
91+
92+
Pass the reviewable paths from Step 1. Output is grouped by rule
93+
content — files sharing the same rule appear under one group, avoiding
94+
repetition.
95+
96+
### Step 3: Get diffs
97+
98+
Use git directly, based on the mode/ref info from Step 1:
99+
100+
**Range mode** (merge\_base provided):
101+
```bash
102+
git diff <merge_base>..<to> -- <path>
103+
```
104+
105+
**Commit mode**:
106+
```bash
107+
git show <commit> -- <path>
108+
```
109+
110+
**Workspace mode**:
111+
```bash
112+
git diff HEAD -- <path> # tracked files
113+
cat <path> # new untracked files
114+
```
115+
116+
### Step 4: Review each file
117+
118+
For each reviewable file:
119+
120+
1. Get its diff (Step 3)
121+
2. Consult the matching Rule Group (Step 2) as the review checklist
122+
3. Conduct a thorough review, using context exploration as needed
123+
124+
### Step 5: Report
125+
126+
Classify each finding by severity:
127+
128+
- **Critical/High** — bugs, security issues, data loss risks. Always report.
129+
- **Medium** — performance concerns, error handling gaps. Report with context.
130+
- **Low** — style nits, minor suggestions. Discard silently unless clearly valuable.
131+
132+
## Sub-commands reference
133+
134+
| Command | Purpose |
135+
|---------|---------|
136+
| `ocr delegate preview` | List reviewable files + mode/ref metadata |
137+
| `ocr delegate rule <path...>` | Resolve review rules grouped by content |
138+
139+
## Shared flags
140+
141+
| Flag | Description |
142+
|------|-------------|
143+
| `--from <ref>` | Source ref for range mode |
144+
| `--to <ref>` | Target ref for range mode |
145+
| `-c, --commit <hash>` | Single commit mode |
146+
| `--repo <path>` | Repository root (default: cwd) |
147+
| `--rule <path>` | Custom rule.json path |
148+
| `--exclude <patterns>` | Comma-separated exclude patterns |
149+
| `-b, --background <text>` | Business context |
150+
| `-B, --background-file <path>` | Business context from Markdown file |
151+
152+
## Comparison with other integration modes
153+
154+
| Mode | Who calls the LLM? | Use case |
155+
|------|-------------------|----------|
156+
| [Agent Skill](../agent-skill/) | OCR | Agent invokes `ocr review`; OCR drives the full review |
157+
| [Command (Claude Code)](../claude-code/) | OCR | Slash command in Claude Code; OCR drives the review |
158+
| **Delegation Mode** | Host agent | OCR provides scaffolding; agent drives the review |
159+
| [Direct Subprocess](../subprocess/) | OCR | Manual CLI invocation |
160+
161+
## See Also
162+
163+
- [Agent Skill](../agent-skill/) — OCR drives the full review on behalf of the agent.
164+
- [Command (Claude Code)](../claude-code/) — slash-command flavor with auto-fix.
165+
- [Direct Subprocess](../subprocess/) — bypass skills/commands, call CLI directly.

pages/src/content/docs/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import enAgentSkill from './en/integrations/agent-skill.md';
1616
import enClaudeCode from './en/integrations/claude-code.md';
1717
import enSubprocess from './en/integrations/subprocess.md';
1818
import enCicd from './en/integrations/ci.md';
19+
import enDelegate from './en/integrations/delegate.md';
1920
import enContributing from './en/contributing.md';
2021
import enFaq from './en/faq.md';
2122

@@ -35,6 +36,7 @@ import zhAgentSkill from './zh/integrations/agent-skill.md';
3536
import zhClaudeCode from './zh/integrations/claude-code.md';
3637
import zhSubprocess from './zh/integrations/subprocess.md';
3738
import zhCicd from './zh/integrations/ci.md';
39+
import zhDelegate from './zh/integrations/delegate.md';
3840
import zhContributing from './zh/contributing.md';
3941
import zhFaq from './zh/faq.md';
4042

@@ -54,6 +56,7 @@ import jaAgentSkill from './ja/integrations/agent-skill.md';
5456
import jaClaudeCode from './ja/integrations/claude-code.md';
5557
import jaSubprocess from './ja/integrations/subprocess.md';
5658
import jaCicd from './ja/integrations/ci.md';
59+
import jaDelegate from './ja/integrations/delegate.md';
5760
import jaContributing from './ja/contributing.md';
5861
import jaFaq from './ja/faq.md';
5962

@@ -73,6 +76,7 @@ export type DocSlug =
7376
| 'claude-code'
7477
| 'subprocess'
7578
| 'cicd'
79+
| 'delegate'
7680
| 'contributing'
7781
| 'faq';
7882

@@ -92,6 +96,7 @@ const enDocs: Record<DocSlug, string> = {
9296
'claude-code': enClaudeCode,
9397
'subprocess': enSubprocess,
9498
'cicd': enCicd,
99+
'delegate': enDelegate,
95100
'contributing': enContributing,
96101
'faq': enFaq,
97102
};
@@ -112,6 +117,7 @@ const zhDocs: Record<DocSlug, string> = {
112117
'claude-code': zhClaudeCode,
113118
'subprocess': zhSubprocess,
114119
'cicd': zhCicd,
120+
'delegate': zhDelegate,
115121
'contributing': zhContributing,
116122
'faq': zhFaq,
117123
};
@@ -132,6 +138,7 @@ const jaDocs: Record<DocSlug, string> = {
132138
'claude-code': jaClaudeCode,
133139
'subprocess': jaSubprocess,
134140
'cicd': jaCicd,
141+
'delegate': jaDelegate,
135142
'contributing': jaContributing,
136143
'faq': jaFaq,
137144
};
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
---
2+
title: デリゲーションモード
3+
sidebar:
4+
order: 5
5+
---
6+
7+
OCR が確定的エンジニアリング(ファイル選択、ルール解決)を担当し、ホストエージェントが自身の LLM 能力を使って実際のコードレビューを行います。OCR 側に LLM エンドポイントは不要です。
8+
9+
## デリゲーションモードを使うタイミング
10+
11+
デリゲーションモードは、サブスクリプション型の AI コーディングエージェント向けに設計されています — Claude Code、Codex、Cursor、Open Code、Qoder など。これらのツールには LLM サブスクリプションが組み込まれており、デリゲーションモードを使えばホストエージェントの既存サブスクリプション枠をそのままコードレビューに活用できます。追加のモデル設定や API キーは不要です。
12+
13+
以下の場合に使用してください:
14+
15+
1. AI コーディングエージェントがサブスクリプション制で、その枠をコードレビューに再利用したい場合 — 追加の API キーやモデル設定は不要。
16+
2. OCR のエンジニアリング機能のみ(ファイルフィルタリング、ルール解決、除外ロジック)を利用し、LLM 推論はホストエージェントに任せたい場合。
17+
3. 構造化された入力(ファイルリスト+ルール)を独自のレビューステップに必要とするカスタムエージェントパイプラインを構築している場合。
18+
19+
## 前提条件
20+
21+
`ocr` CLI がインストールされている必要があります:
22+
23+
```bash
24+
which ocr || npm install -g @alibaba-group/open-code-review
25+
```
26+
27+
LLM 設定(`ocr config set …` や環境変数)は不要です — デリゲーションモードは OCR 側で LLM を呼び出しません。
28+
29+
## Skill / Command のインストール
30+
31+
### Claude Code — Command
32+
33+
```bash
34+
mkdir -p .claude/commands
35+
curl -o .claude/commands/delegate-review.md \
36+
https://raw.githubusercontent.com/alibaba/open-code-review/main/plugins/open-code-review/claude-code/commands/delegate-review.md
37+
```
38+
39+
### 任意のエージェント — Skill
40+
41+
```bash
42+
npx skills add alibaba/open-code-review --skill open-code-review-delegate
43+
```
44+
45+
または手動コピー:
46+
47+
```bash
48+
cp -R /path/to/open-code-review/skills/open-code-review-delegate ~/.claude/skills/
49+
```
50+
51+
## ワークフロー
52+
53+
### ステップ 1:Preview — レビュー対象の決定
54+
55+
```bash
56+
ocr delegate preview [--from <ref> --to <ref>] [--commit <hash>] [--exclude <patterns>]
57+
```
58+
59+
出力内容:
60+
61+
- **mode** — workspace / range / commit
62+
- **ref メタデータ** — from、to、commit、merge\_base
63+
- **レビュー可能ファイルリスト** — パス、ステータス、挿入/削除行数
64+
- **除外ファイル** — 除外理由付き
65+
66+
よく使うパターン:
67+
68+
| シナリオ | コマンド |
69+
|----------|---------|
70+
| ワークスペースの変更 | `ocr delegate preview` |
71+
| ブランチ比較 | `ocr delegate preview --from main --to feature` |
72+
| 単一コミット | `ocr delegate preview -c abc123` |
73+
74+
### ステップ 2:ファイルのルール取得
75+
76+
```bash
77+
ocr delegate rule <path1> <path2> ...
78+
```
79+
80+
ステップ 1 のレビュー可能パスを渡します。出力はルール内容でグループ化されます — 同じルールを共有するファイルは1つのグループにまとめられ、重複を避けます。
81+
82+
### ステップ 3:diff の取得
83+
84+
ステップ 1 の mode/ref 情報に基づき、git を直接使用:
85+
86+
**Range モード**(merge\_base あり):
87+
```bash
88+
git diff <merge_base>..<to> -- <path>
89+
```
90+
91+
**Commit モード**
92+
```bash
93+
git show <commit> -- <path>
94+
```
95+
96+
**Workspace モード**
97+
```bash
98+
git diff HEAD -- <path> # 追跡ファイル
99+
cat <path> # 新規未追跡ファイル
100+
```
101+
102+
### ステップ 4:各ファイルのレビュー
103+
104+
レビュー可能な各ファイルについて:
105+
106+
1. diff を取得(ステップ 3)
107+
2. 対応するルールグループ(ステップ 2)をレビューチェックリストとして参照
108+
3. コンテキスト探索を必要に応じて行い、徹底的にレビュー
109+
110+
### ステップ 5:レポート
111+
112+
重要度で分類:
113+
114+
- **Critical/High** — バグ、セキュリティ問題、データ損失リスク。常に報告。
115+
- **Medium** — パフォーマンスの懸念、エラーハンドリングの欠落。コンテキスト付きで報告。
116+
- **Low** — スタイルの提案、軽微な改善。明確に価値がない限り静かに破棄。
117+
118+
## サブコマンドリファレンス
119+
120+
| コマンド | 目的 |
121+
|----------|------|
122+
| `ocr delegate preview` | レビュー可能ファイル+mode/ref メタデータの一覧 |
123+
| `ocr delegate rule <path...>` | 内容別にグループ化されたレビュールールの解決 |
124+
125+
## 共通フラグ
126+
127+
| フラグ | 説明 |
128+
|--------|------|
129+
| `--from <ref>` | Range モードのソース参照 |
130+
| `--to <ref>` | Range モードのターゲット参照 |
131+
| `-c, --commit <hash>` | 単一コミットモード |
132+
| `--repo <path>` | リポジトリルート(デフォルト:cwd) |
133+
| `--rule <path>` | カスタム rule.json パス |
134+
| `--exclude <patterns>` | カンマ区切りの除外パターン |
135+
| `-b, --background <text>` | ビジネスコンテキスト |
136+
| `-B, --background-file <path>` | Markdown ファイルからビジネスコンテキストを読み込み |
137+
138+
## 他の統合モードとの比較
139+
140+
| モード | LLM を呼ぶのは? | ユースケース |
141+
|--------|-----------------|-------------|
142+
| [Agent Skill](../agent-skill/) | OCR | Agent が `ocr review` を呼び出し、OCR が完全なレビューを駆動 |
143+
| [Command(Claude Code)](../claude-code/) | OCR | Claude Code のスラッシュコマンド、OCR がレビューを駆動 |
144+
| **デリゲーションモード** | ホストエージェント | OCR がスキャフォールディングを提供、Agent がレビューを駆動 |
145+
| [Direct Subprocess](../subprocess/) | OCR | 手動 CLI 呼び出し |
146+
147+
## 関連項目
148+
149+
- [Agent Skill](../agent-skill/) — OCR がエージェントに代わって完全なレビューを駆動。
150+
- [Command(Claude Code)](../claude-code/) — スラッシュコマンド形式、自動修正付き。
151+
- [Direct Subprocess](../subprocess/) — skill/command をバイパスし、CLI を直接呼び出し。

0 commit comments

Comments
 (0)