Code review is the step everyone agrees matters and nobody has time for. On a solo WordPress plugin, review usually means re-reading your own diff ten minutes after writing it, which is to say, not review at all.
I spent a day setting up Open Code Review (OCR) on a WordPress plugin I maintain, one with a JavaScript front end, a PHP back end, and a test suite. This is the workflow I ended up with: how to install it, how to point it at a model (in my case, an Ollama Cloud model through the local Ollama daemon), and how to use its two modes without wasting tokens.
What Open Code Review actually is
OCR is not a thin wrapper that pastes your diff into a chat model. Its architecture is deliberately split in two:
- A deterministic pipeline decides which files to review, groups related files into a review unit, matches rules to file types, and post-processes every comment for accurate line positioning.
- An agent does the dynamic part: reading surrounding code, searching the repository, and deciding what is worth reporting.
The tool ships with a multi-language ruleset covering things like null-pointer risks, thread-safety, XSS, and SQL injection, and it speaks both OpenAI- and Anthropic-compatible APIs. It is Apache-2.0 licensed and installs as a single ocr command.
Two modes matter:
| Command | Input | Use it for |
|---|---|---|
ocr review | A diff (workspace, commit, or branch range) | Pre-merge review of a change |
ocr scan | Entire files | Auditing code that has no diff to review |
That distinction is the whole mental model. Once it clicks, the rest is flags.
Step 1: Install
Prerequisites are modest but real:
- Node.js >= 14 (only to run the launcher)
- Git >= 2.41. This is a hard requirement, because OCR leans on Git for diffs, code search, and repository plumbing
npm install -g @alibaba-group/open-code-review
ocr --version
Watch the package name. It is scoped: @alibaba-group/open-code-review. The unscoped open-code-review does not exist on npm, so that install simply fails.
The npm package is a small launcher plus a platform-specific binary pulled in as an optional dependency (@alibaba-group/ocr-linux-x64, ocr-darwin-arm64, and so on). There is no Go toolchain, no compilation, and no build step.
If you are on npm 11 or newer, you will see a warning:
npm warn allow-scripts 1 package has install scripts not yet covered by allowScripts:
npm warn allow-scripts @alibaba-group/open-code-review@1.13.3 (postinstall: node scripts/install.js)
That postinstall is a fallback downloader for the case where the optional platform package is missing. When the platform package installs correctly, which is the normal case, it never runs, and the warning is harmless. Verify with ocr --version; if it prints a version, you are done.
The nvm gotcha
If you install Node through nvm, the global ocr shim lives inside that Node version’s bin directory. Switch Node versions and the command disappears. Pin a default:
nvm alias default 26
If you would rather not depend on Node at all, the project also ships an install script that drops a checksum-verified binary into /usr/local/bin:
curl -fsSL https://open-codereview.ai/install.sh -o /tmp/ocr-install.sh
less /tmp/ocr-install.sh
sudo sh /tmp/ocr-install.sh
I went with npm: updates and rollbacks are one command, and I already live inside nvm.
Step 2: Point it at a model
Interactive setup is the friendly path:
ocr config provider # choose a provider, paste your key
ocr config model # pick a model, runs a connectivity test
ocr llm test
I wanted to route reviews through Ollama’s cloud models rather than run inference on my own machine. The local Ollama daemon exposes an OpenAI-compatible API at /v1; after you sign in with ollama signin, it forwards requests for :cloud models to Ollama’s servers. Custom providers are configured with dotted keys:
ocr config set provider ollama
ocr config set custom_providers.ollama.url http://localhost:11434/v1
ocr config set custom_providers.ollama.protocol openai
ocr config set custom_providers.ollama.api_key ollama
ocr config set custom_providers.ollama.model deepseek-v4.1-flash:cloud
ocr config set custom_providers.ollama.models '["deepseek-v4.1-flash:cloud","glm-5.3-flash:cloud"]'
Cloud or local: same setup, one different tag. The :cloud suffix is the only thing that makes this a cloud configuration. It tells Ollama to run the model on Ollama’s servers instead of yours. If your machine has enough RAM or VRAM, you can run the same workflow entirely locally: pull a model that fits your hardware with ollama pull <model>, then use its name, without :cloud, in the same custom_providers.ollama.model setting. The /v1 endpoint, the placeholder API key, and every OCR command in this post stay exactly the same. Only the model tag changes, along with where inference happens.
Three details that cost me time:
- The
/v1suffix is required. A barehttp://localhost:11434is Ollama’s native API, not the OpenAI-compatible one. OCR will fail with a confusing 404. - The API key is a placeholder. The local daemon ignores the token for localhost requests, whether the model runs locally or in the cloud. Cloud models authenticate through the Ollama account you signed in with (
ollama signin), not through this value. - Model tags are server-side aliases. A tag I had used before started failing with retired on September 25, 2026. Try … instead. The model name in your config is not guaranteed to exist forever.
Everything lands in ~/.opencodereview/config.json. If you prefer environment variables over a config file, OCR honors OCR_LLM_URL, OCR_LLM_TOKEN, OCR_LLM_MODEL, and OCR_LLM_PROTOCOL.
A successful ocr llm test looks like this:
Source: provider:ollama
URL: http://localhost:11434/v1
Model: deepseek-v4.1-flash
The self-test returned "ocr_selftest ok," and I'm open-code-review, a code review assistant developed by Alibaba, running in your command-line environment.
✓ Connection test successful
✓ Tool-call round trip verified
That second check matters. OCR is an agent. If the model cannot call tools, the review will silently degrade into a chat completion over a diff.
Step 3: Review a branch before merging
Branch review uses merge-base semantics: --from is the base, --to is the branch. This reviews exactly what the branch adds since it diverged from the base, the same thing a pull request would show.
ocr review --from main --to feature/harden-input-validation
Branch names are illustrative here; substitute your own. A fuller command, with context and machine-readable output, looks like this:
ocr review --from main --to feature/harden-input-validation
--background "Harden input validation: reject malformed identifiers, require arrays of integers where expected, and keep error messages specific"
--effort high
--format json
--output /tmp/ocr-review.json
And the same shape for a second example, a branch that validates parser output before it reaches a scoring layer:
ocr review --from main --to fix/validate-parser-output
--background "Validate parser output before scoring: reject non-finite values, validate identifiers before using them as map keys, and keep each pooled score attributed to the record it came from"
--effort high
--format json
--output /tmp/ocr-review-2.json
That --background flag is not decoration. Without it, the model does not know which behaviors are intentional (for example, that sparse input entries and objects created in another realm are expected), so it reports them as oddities. With it, the review is about whether the implementation actually honors those requirements.
Some useful flags:
--effort highpays for more reasoning. Worth it on small, dense changes such as security gates, validation, and state machines.--format json --output file.jsonkeeps findings. Progress still prints to stderr, so the terminal stays readable.--previewlists the files that would be reviewed without calling the LLM. Run this first, every time.--resume <session-id>continues an interrupted run;ocr session listfinds past ones.
One useful implementation detail: in range mode, OCR reads file contents with git show <ref>:<path>, not from your working tree. You can review a branch while checked out on another one. The diff and the context both come from the refs you named.
Step 4: Review entire files with scan
review needs a diff. scan does not. It reads every reviewable file under the path you give it (the repository root by default) and reviews each file in full. --path includes, for example, means every reviewable file inside includes/, not just that directory. That is what you want when auditing a codebase or checking a branch you have not touched.
ocr scan --preview # free: list files and line counts
ocr scan # the real run
One catch: scan reads the working tree. There is no --branch flag. To scan main, check it out first:
git switch main
ocr scan
If the checkout is a live dev site you do not want to disturb, use a throwaway worktree instead:
git worktree add /tmp/ocr-main main
ocr scan --repo /tmp/ocr-main
Scope is everything
For illustration, take a mid-sized plugin with roughly 150 reviewable files and 30,000 lines. A full scan at that size is a lot of tokens and wall-clock time. The preview tells you exactly what you are buying, and --path narrows it:
ocr scan --path includes,src --preview
A production-only subset is usually less than half the file count and covers the code you actually ship. Other controls worth knowing:
ocr scan --exclude 'tests/**,tools/**,third-party/**'
ocr scan --max-tokens-budget 3000000 # hard cap; partial results still publish
ocr scan --no-plan --no-summary # faster, less thorough
ocr scan --resume <session-id>
third-party/, vendor/, and node_modules/ are the things I exclude without hesitation. You cannot fix vendored code, and reviewing it is pure cost.
Step 5: Should you exclude tests?
Not automatically. The trade-off is real, and it is measurable. For the same illustrative 150-file plugin, a breakdown might look like this:
| Scope | Files | Lines |
|---|---|---|
| Whole repo (reviewable) | 150 | 30,000 |
| Production code | 60 | 14,000 |
tests | 35 | 8,000 |
tools (including its tests) | 25 | 5,000 |
| Config, assets, root files | 30 | 3,000 |
Tests and tooling would be about 40% of the review surface. Excluding them roughly halves runtime and removes a class of false positives: fixtures with deliberately malformed JSON, dummy credentials, sleep() calls, and intentionally broken payloads all trip security rules that were written for production code.
But tests are also where bugs hide best:
- assertions that can never fail
catchblocks that swallow failures- mocks that no longer match the real contract
- order- or time-dependent tests that make CI flaky
- tests that encode the wrong expected behavior, thereby proving a production bug is fine
My rule: do not skip tests on code you did not write. On your own pull requests, the marginal value is lower, but it is not zero. When I want both, I run two passes with separate budgets:
ocr scan --path includes,src,my-plugin.php
--format json --output /tmp/ocr-production.json
ocr scan --path tests/phpunit
--max-tokens-budget 2000000 --format json --output /tmp/ocr-tests.json
There is one place I never exclude tests: ocr review. Diffs bundle related files (implementation plus its tests) for context. Dropping half the bundle degrades the review of the other half.
The workflow I actually use now
- Preview.
ocr review ... --preview. If it says zero files, stop; you are reviewing the wrong range. - Review the branch, not the merge.
--from main --to <branch>before opening the PR. - Give it context. A sentence of
--backgroundfrom the issue cuts noise dramatically. - Keep the output. JSON into
/tmp, or useocr session exportfor a self-contained HTML report you can share. - Browse sessions.
ocr viewerstarts a local web UI on port 5483 to replay findings and mark comments as fixed or ignored. - Budget the big scans.
--max-tokens-budgetand--pathare the difference between a focused audit and an expensive crawl.
For CI, --format sarif produces SARIF that GitHub code scanning understands, and --audience agent reduces output to a summary for machine consumption.
Gotchas I hit, so you do not have to
- The package name is scoped.
@alibaba-group/open-code-review, notopen-code-review. $OLLAMA_API_BASEalone is not a command. Typing a variable name by itself makes zsh try to execute its value. Useecho "$OLLAMA_API_BASE", and remember OCR wants the value with/v1appended.- A no files review usually means the branch is already merged. Check
git merge-base,git rev-list --left-right --count, andgit diff --statbefore blaming the tool. --from main --to developwill not show main-only commits. That is correct merge-base behavior, not a bug, but it surprises people.- Retired model tags fail at request time, not install time. If a provider starts erroring, test the endpoint with
curlbefore touching OCR’s config. - Scans read the working tree. Range reviews read refs. Two different rules; mixing them up produces confusing results.
Closing thoughts
What sold me on OCR is not that it finds bugs a general-purpose agent would miss. It is that the deterministic half removes the failure mode I hate most in AI review: position drift and selective coverage. The tool decides which files to review and where a comment belongs; the model supplies judgment. That division is why the output is usable without a second pass of manual re-anchoring.
It is not a replacement for a human reviewer, and its own benchmark is candid that it trades recall for precision: fewer findings, more of them real. For a solo developer shipping a plugin, that is exactly the right trade.
If you try it, start with --preview, review one branch you were about to merge anyway, and see whether the comments land where the code actually is.
- Repository: github.com/alibaba/open-code-review
- Docs: open-codereview.ai/docs
- CLI reference: open-codereview.ai/docs/cli-reference
Leave a Reply