Two small friendly robots one coral and one teal

Review, Fix, Verify: A Repo Workflow for Claude Code and Codex

AI code review is easy to start and hard to trust. Ask an agent to “review my repo” and you get a wall of comments. Some point at the wrong lines, some files get skipped without anyone noticing, and nothing tells you whether the fixes made things better or worse. This post sets out a repeatable workflow inside Claude Code or OpenAI Codex that addresses all three problems. First you make code quality measurable. Then you run a structured review of the whole repository. Then you fix what it finds in small batches, checking each one.

Everything here works the same in both agents. The rules live in AGENTS.md, a file both can read, and the review reports go into a shared folder. So you can run the review in one agent and the fixes in the other.

The workflow is built on Alibaba’s Open Code Review (OCR). It’s an open-source command-line tool that Alibaba used internally for about two years before releasing it under the Apache-2.0 licence in May 2026 (source).

Why OCR, and why delegate mode

OCR’s design splits the work. Ordinary code decides what gets reviewed: it picks the files, groups related files together, and matches review rules to each one. The AI model decides what’s actually wrong. Alibaba’s own benchmark reports better precision than a general-purpose agent using the same model, at about a ninth of the tokens. The stated trade-off is lower recall: fewer false alarms, but more real issues missed (source). Keep that in mind. An OCR report is a high-signal list, not a guarantee that nothing else is wrong.

OCR runs in two modes. Native mode (the open-code-review skill) calls whatever AI provider you’ve configured in OCR, so you need a separate API key. Delegate mode (the open-code-review-delegateskill) is meant for people without a separate key, or who want to use their existing coding-agent subscription. The CLI selects files and resolves rules, and the agent’s own model does the review (source). This workflow uses delegate mode, so the review runs on the Claude Code or Codex plan you already pay for.

One thing often gets misunderstood: delegate mode still needs the ocr CLI installed. What it doesn’t need is a configured AI endpoint (source).

Step 0: Install the pieces

Both agents need the OCR CLI and Git 2.41 or newer (source):

npm install -g @alibaba-group/open-code-review
git --version   # must be 2.41 or newer
ocr --version   # JSON output needs v1.9.0+

Then install the plugin for your agent (source):

Claude CodeCodex
Add the plugin source/plugin marketplace add alibaba/open-code-reviewcodex plugin marketplace add alibaba/open-code-review
Install/plugin install open-code-review@open-code-reviewRun codex, open /plugins, install and enable Open Code Review
Start a delegate review/open-code-review:delegate-review or a plain-English prompt@Open Code Review delegate review ...

Whichever agent you use, always ask for the delegate review. In Codex, the default review skill runs ocr review, which calls OCR’s own configured model rather than your Codex session. You only get the review on your Codex quota by asking for the delegate skill (source).

Step 1: Make quality measurable in AGENTS.md

Do this before any review or fix. Without it, “the fix works” just means the agent thinks it looks right.

Put the guardrails in AGENTS.md at the repo root. Codex reads AGENTS.md before doing any work, and can combine a global file with a project-level one (source). Claude Code reads CLAUDE.md instead, so create a CLAUDE.md containing the single line @AGENTS.md. This uses Claude Code’s import syntax to pull in the same rules, giving you one source of truth for both agents. If you already have a detailed CLAUDE.md, move the shared rules into AGENTS.md and keep only Claude-specific notes in CLAUDE.md.

Run this once per repository, in either agent:

Audit this repository's verification setup (linting, formatting, type-checking, testing and build), and write measurable engineering guardrails into ./AGENTS.md. Create the file if it doesn't exist. If it does exist, add to it without overwriting existing rules.

Step 1 — Inspect. Check package.json, pyproject.toml, requirements*.txt, Cargo.toml, go.mod, Makefile, tsconfig.json and the CI configs (e.g. .github/workflows/) to find every configured linter, formatter, type-checker, build command and test runner. Run each one now and record a baseline: exact commands, exit codes and any failures that already exist.

Step 2 — Fill gaps. If the main language is missing a fast linter, type-checker or test runner, propose the lightest standard tool for the stack (e.g. ruff + pytest for Python; eslint or biome + tsc --noEmit + vitest for TypeScript). Ask me before installing any new dependency.

Step 3 — Write the rules. Add a ## Verification & Safety Guardrails section to ./AGENTS.md using the template I'll provide, filled in with this project's real commands and baseline.

Step 4 — Link Claude Code. If ./CLAUDE.md doesn't exist, create it with the single line @AGENTS.md. If it does exist, add that line at the top without removing existing content.

Don't change application source code in this pass. Only inspect, run the read-only baseline checks, and update ./AGENTS.md and ./CLAUDE.md.

Here is the template the prompt refers to. The agent should replace the placeholders with your project’s real commands:

## Verification & Safety Guardrails

### Verification commands (must exit 0, or match the baseline)
- Lint:        <e.g. npm run lint | ruff check .>
- Format:      <e.g. npx prettier --check . | ruff format --check .>
- Type-check:  <e.g. npx tsc --noEmit | mypy .>
- Tests:       <e.g. npm test | pytest -q>
- Build:       <e.g. npm run build>

### Baseline (recorded <date>)
- <command>: <pass/fail, counts, known pre-existing failures>

### Rules
1. Baseline first: run all verification commands before editing, so
   pre-existing failures are kept separate from new regressions.
2. Regression tests: every bug fix adds or updates a targeted test
   that fails before the fix and passes after it.
3. Small batches: max 3–5 changes per pass; re-run all checks after
   each batch.
4. Rollback: revert any change that introduces new lint, type or test
   failures that can't be cleanly resolved, and record why.
5. Scope: minimal edits that address the root cause; no unrelated
   refactors.
6. Git safety: work on `dev` or a feature branch off `dev`; never commit
   to or merge into `main` without explicit approval.
7. Workspace: stay inside this project folder; save review artifacts
   under `./.ocr-reports/`.

Step 2: Review the whole repository with OCR in delegate mode

A limitation shapes this step. Delegate mode’s documented commands work only on changes: uncommitted work (ocr delegate preview), a branch range (--from main), or a single commit (-c <hash>) (source). Whole-file auditing is the job of ocr scan, a native-mode command meant for codebases with no meaningful diff (source). On a clean working tree, a standard delegate review has nothing to look at.

You have two honest options. If you’re willing to configure an OCR provider, use native mode with ocr scan, scoped with --path if needed. If you want to stay in delegate mode, which is what this post does, have the agent follow the delegate workflow on whole files. It uses ocr delegate rule to get the rule groups for each source file, then reads each entire file where it would normally read a diff. That’s an adaptation, not an official Alibaba mode, so the prompt states it openly.

Don’t save .diff files. Git already holds your history, and the skill’s own instructions write large diffs to a temporary location outside the repo and delete them afterwards (source). What you keep is a machine-readable JSON file and a human-readable Markdown report. The JSON fields extend the skill’s comment format: path, content, start/end line, category and severity, with severities critical, high, medium and low. The summary must list total, reviewed and skipped files plus a coverage rate, and every skipped file needs a reason (source).

In Codex, run this through the Open Code Review plugin's delegate skill (e.g. start with @Open Code Review delegate review). In Claude Code, use /open-code-review:delegate-review or invoke the open-code-review-delegate skill.

Use the Alibaba Open Code Review skill in delegate mode (open-code-review-delegate). Use the installed ocr CLI only for file selection and rule resolution. Don't run ocr review or ocr scan, and don't ask for an API key. If ocr isn't found, stop and tell me.

This is a full-repository review of all existing source code, not a diff review. Adapt the delegate workflow as follows: build the list of source files yourself (all tracked files from git ls-files), get their rule groups with ocr delegate rule --format json <paths...> in batches, then review each entire file against its rule group in place of a diff. Follow callers, contracts and tests for context where that helps confirm an issue.

Guardrails. Work only inside this approved project folder. Don't modify any source files in this pass. Exclude dependency, build and generated content (node_modules, .git, dist, build, .next, venv, __pycache__, lockfiles, binaries, media and data files). Don't save diff files in the repo. Review in batches grouped by rule group, and don't stop after the first serious finding. Quietly discard likely false positives.

Outputs (create ./.ocr-reports/ if needed):

1. ./.ocr-reports/full-audit.json containing a summary object (review_mode: "delegation (full-file adaptation)", agent (Claude Code or Codex), total_files, reviewed_files, skipped_files with a reason for each, coverage_rate) and a findings array. Each finding has: id, path, start_line, end_line, severity (critical | high | medium | low), category (bug | security | performance | maintainability | test | style | documentation | other), title, content, root_cause, suggested_fix, and status: "open".
2. ./.ocr-reports/full-audit.md, a readable report and fix checklist grouped by severity. It references the finding IDs from the JSON, includes the coverage summary, and flags any modules that look high-risk.

Whether to commit .ocr-reports/ is up to you. Add it to .gitignore to keep audit artifacts out of history, or commit it to dev so the report travels with the branch for future sessions and for whichever agent picks it up next.

Step 3: Fix from the report, with checks after every batch

The skill can fix issues itself. In “review and fix” mode it applies high and critical fixes directly (source). Keeping review and fixing as separate passes gives you a checkpoint where you can read the report before anything changes. When you’re ready, run this in either agent:

Read ./.ocr-reports/full-audit.json and ./.ocr-reports/full-audit.md, and follow every rule in ./AGENTS.md → ## Verification & Safety Guardrails.

1. Setup. Confirm we're on dev, or a feature branch off dev; never main. Run all verification commands from AGENTS.md and compare the results with the recorded baseline. Report any drift before editing anything.

2. Fix order. Work on critical, then high, then medium findings, at most 5 per batch. Skip low unless the fix is trivial. For each finding: (a) write a regression test that reproduces the bug and confirm it fails, wherever that's feasible; (b) make the smallest change that addresses root_cause, without refactoring unrelated code; (c) re-run lint, type-check, tests and build, and confirm they pass or show no new failures compared with the baseline; (d) if new failures can't be cleanly resolved, revert the fix and record why. If a finding turns out to be a false positive, mark it as such and don't change any code. Commit each verified batch separately to the working branch, with the finding IDs in the commit message.

3. Update the reports. In full-audit.json, set each finding's status (fixed | skipped | reverted | false-positive) and add verification_notes (exact commands, exit codes, test names). Update full-audit.md with progress, verification results and the remaining open items. Stop after each batch and summarise before continuing.

Once AGENTS.md holds your real commands, you can end any bug-fix or refactoring prompt, in either agent, with this:

Verification & Safety (mandatory): Follow ./AGENTS.md → ## Verification & Safety Guardrails. Stay on dev inside this project folder; never merge into main. Record baseline lint, type and test results before editing. Work in batches of 5 changes or fewer, with a regression test for each bug fixed, and re-run all checks after each batch. Revert anything that introduces new failures, then summarise the commands run and their results.

Wrapping up

The order matters. AGENTS.md comes first because without a baseline and pass/fail commands, nothing afterwards can be measured. The OCR review comes second and produces a JSON file plus a Markdown report, both tied together by finding IDs, so a fresh session next week can say “fix #4 to #8” without re-scanning the repo. The fix pass comes last, using small batches, regression tests and rollbacks, so each change is checked before the next one starts.

Because the guardrails live in AGENTS.md and the reports live in ./.ocr-reports/, you aren’t tied to one agent. You can run the review in Claude Code and the fixes in Codex, or the other way round. Each agent reads the same rules and the same finding IDs. Re-run Step 2 after major changes, and remember OCR’s precision-over-recall trade-off: a clean report means fewer obvious problems, not zero.