Dev Tooling

Open Code Review

open-code-review

Run Alibaba's `ocr` CLI over a diff, commit, branch comparison or whole file and get line-level review comments — a deterministic pipeline picks files and matches rules, then an LLM agent reads the surrounding code. Needs its own model endpoint configured.

code-reviewclisecuritystatic-analysis
Install
mkdir -p ~/.claude/skills && curl -fsSL https://skill.metacog.co.kr/dist/open-code-review.zip \
  -o /tmp/open-code-review.zip && unzip -oq /tmp/open-code-review.zip -d ~/.claude/skills
Files2
Size23.4 KB
Bundled foldersnone
LicenseMIT

Authored by jeonck (MIT) · Browse files on GitHub · Download zip

When Claude uses it

Performs AI-powered code review on Git changes using the `ocr` CLI from alibaba/open-code-review. Use when the user asks to review code, review a pull request, review staged/unstaged changes, review a commit, or compare branches for code quality issues. Produces line-level review comments and can automatically apply fixes when requested. With appropriate review rules, can detect various types of issues including bugs, security vulnerabilities, performance problems, and code quality concerns.

SKILL.md

Open Code Review

A skill for invoking open-code-review (ocr) — an open-source AI code review CLI that reads Git diffs and generates structured, line-level review comments.

Workflow

Step 1: Gather Business Context

Analyze the review target (commits, branch, or changes) to extract concise business context. Pass this context via --background to improve review quality.

Step 2: Run Code Review

Do not pre-check whether ocr is installed — skip probes like command -v ocr or ocr --version. Assume the CLI is available and run the review directly; that saves a tool call on the common path. Only if the review fails with command not found should you install it per Troubleshooting.

Run the OCR command with appropriate flags. Always pass business context via --background when available:

ocr review --audience agent --background "business context here" [user-args]

Argument handling:

Common invocation patterns:

| User says | Command to run | |-----------|---------------| | "review my changes" / "review the working copy" | ocr review --audience agent -b "context" | | "review this PR" / "review feature branch" | ocr review --audience agent -b "context" --from main --to <branch> | | "review commit abc123" | ocr review --audience agent -b "context" --commit abc123 | | "what would be reviewed?" (dry-run) | ocr review --preview |

Output mode:

On failure: If ocr review exits non-zero (e.g. an LLM connection error), do not retry blindly — consult the Troubleshooting section below for the matching fix before re-running.

Step 3: Report

OCR output includes structured severity (critical / high / medium / low) and category (bug / security / performance / maintainability / test / style / documentation / other) on each comment. Present results grouped by severity, discarding low severity items that are likely false positives or nitpicks.

Step 4: Fix

Before applying fixes, check whether the user requested automatic fixes:

When fixing issues and suggestions:

Output Format

Each comment in OCR's output contains:

Present results grouped by severity using this template:

## Code Review Results

**Files reviewed**: N
**Issues found**: X critical, Y high, Z medium

### Critical

- **`path/to/file.java:42`** [bug] — Brief description
  > Recommendation: How to fix

### High

- **`path/to/file.java:26`** [bug] — Brief description
  > Recommendation: How to fix

### Medium

- **`path/to/file.ts:88`** [performance] — Brief description
  > Recommendation: How to fix (if applicable)

If no critical, high, or medium severity issues remain after filtering, state: "Review complete — no critical, high, or medium issues found in N files."

Handling mispositioned comments:

When start_line and end_line are both 0, the comment failed to locate the exact position in the file. In such cases:

  1. Read the comment content to understand the issue
  2. Examine the target file mentioned in the comment
  3. Identify the relevant code section based on the comment's context
  4. Apply the fix or suggestion to the correct location

Custom Review Rules

If the user wants project-specific rules, OCR resolves them in this priority order:

  1. --rule <path> flag (highest)
  2. <repo>/.opencodereview/rule.json
  3. ~/.opencodereview/rule.json
  4. Built-in system defaults (lowest)

By default, the first matching user rule replaces the built-in system rule. Set merge_system_rule: true on a rule entry when the matched system rule and user rule should both be included.

Rule file format:

{
  "rules": [
    {
      "path": "**/*.java",
      "rule": "All new methods must validate required parameters for null",
      "merge_system_rule": true
    },
    {
      "path": "**/*mapper*.xml",
      "rule": "Check SQL for injection risks and missing closing tags"
    }
  ]
}

To preview which rule applies to a file before reviewing:

ocr rules check src/main/java/com/example/Foo.java

Advanced Review Options

Beyond the common flags above, ocr review exposes a few groups of controls. Run ocr review --help for the complete list.

Scoping

Output

Model

Budget

Gotchas

Validation

After the review completes, verify success by checking:

  1. The command exited with code 0
  2. Comments were generated (or "No comments generated" message appears)
  3. Warnings (if any) are displayed in stderr

If errors occurred, check the stderr warnings for details about which files failed and why.

Troubleshooting

ocr: command not found

Install the CLI:

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

unknown flag: --output

The CLI is older than v1.10.0. Do not continue the review with plain stdout. Ask the user whether to upgrade (npm i -g @alibaba-group/open-code-review@latest) and wait for the answer before proceeding. After the user confirms and the upgrade succeeds, rerun with --output.

ocr review fails with LLM connection error

Prompt the user to configure an LLM provider.

Interactive setup (recommended):

ocr config provider

Manual setup (alternative):

ocr config set llm.url https://api.anthropic.com/v1/messages
ocr config set llm.auth_token <api-key>
ocr config set llm.model claude-opus-4-6
ocr config set llm.use_anthropic true

Verify connectivity with ocr llm test. Stop here and ask the user to provide credentials — never invent or hardcode API keys.

References