Skip to main content

How to get Claude Code and Codex to review each other's code

Summary

  • Claude Code and Codex each have a non-interactive mode that accepts piped input, so a script can pass one agent's diff to the other: claude -p and codex exec. Each also has a built-in review command: /code-review and /review.
  • Omnigent, an open-source meta-harness (alpha upstream, Beta on Databricks), can run the cross-vendor loop: one agent implements, a different agent reviews, and a person merges.
  • Keep the reviewer read-only, share standards in AGENTS.md or CLAUDE.md, cap the rounds, and keep a person as the final approver.
  • On Databricks, Unity Gateway can route both agents through governed model services, with permissions, rate limits, budgets, and a usage table that records the coding agent behind each request.

How to get Claude Code and Codex to review each other's code

Run each agent in its non-interactive mode against the other agent's diff, send the findings back to the author, and stop after a fixed number of rounds so that a person decides. You can do this with two shell commands, with each tool's built-in review command, or with an orchestrator such as Omnigent.

Which review path should I use?

Path Claude Code reviews Codex's work Codex reviews Claude Code's work Good for
Built-in review command /code-review with a branch or ref range such as main...codex-feature /review against a base branch A second opinion while you work
Scripted claude -p with the diff piped in codex exec with the diff piped in CI jobs and repeatable checks
Orchestrated Omnigent Polly /cross-review Omnigent Polly /cross-review Parallel tasks that each open a pull request

For the scripted path, pipe the diff into each tool:

# Codex changed the code on a branch: ask Claude Code to review it
git diff main...codex-feature | claude -p "Review this diff for bugs, security issues and missing tests. List findings by severity."

# Claude Code changed the code on a branch: ask Codex to review it
git diff main...claude-feature | codex exec "Review this diff for bugs, security issues and missing tests. List findings by severity."

claude -p prints its answer and exits. codex exec streams progress to stderr and prints only the final agent message to stdout, so you can save the findings or pass them to the author agent.

How do I keep the loop safe?

  • Make the reviewer read-only. codex exec runs in a read-only sandbox by default. For Claude Code, start in plan mode with --permission-mode plan, which researches and proposes changes without making them.
  • Share one set of standards. Codex reads AGENTS.md files before doing any work, and Claude Code can read an existing AGENTS.md in place of a CLAUDE.md. Keep your review criteria in one file.
  • Cap the rounds. A loop that runs until the reviewer is satisfied needs a stop condition. Set a maximum in your script, then hand off to a person.
  • Let tests decide. Treat findings as advice and re-run your tests after every fix.

How does Omnigent run the loop for me?

Omnigent gives you "a common orchestration layer over Claude Code, Codex, Cursor, OpenCode, Hermes, Pi, and the agents you write yourself", and its README says you can ask one agent to review another's work. Its built-in Polly agent is a supervisor that writes no code itself. It splits a goal into sub-tasks, runs each in its own sub-agent and git worktree, and each implementer opens its own pull request. The /cross-review skill "sends an implementer's diff to a different-vendor reviewer", and blocking issues loop back as fixes until clean. Polly never merges, so the human decides. Start it with omni polly.
Omnigent is marked "Status: alpha" in its repository. On Databricks it is in Beta and needs the Omnigent preview enabled for your workspace.

How does Unity Gateway fit in?

Unity Gateway governs the model calls that the agents make. It does not run the review loop. The Unity Gateway CLI (ug) is an open-source launcher: ug claude and ug codex send each agent's requests through a Unity Gateway model service using your Databricks credentials, with no provider API key on the developer's machine.

  • Who can use the models: grant EXECUTE on the model service to users or groups.
  • How much they can use: set rate limits in requests or tokens per minute, and create budgets that alert or block.
  • What happened: query system.ai_gateway.usage. By default you need both the account admin and metastore admin roles; admins can grant others access. Usage tracking is a billed Unity Gateway feature.
SELECT session_metadata.coding_agent AS coding_agent,
       destination_model,
       COUNT(*) AS requests,
       SUM(total_tokens) AS total_tokens
FROM system.ai_gateway.usage
WHERE service_type = 'MODEL_SERVICE'
GROUP BY session_metadata.coding_agent, destination_model
ORDER BY total_tokens DESC;

The coding_agent column holds values such as claude-code or codex. To keep a reviewer from changing a repository, the built-in system.ai.github MCP service has a GitHub service policy with a "Disallow writes" option that blocks tools that create, modify, or delete data on GitHub while allowing read-only tools. Service policies are in Beta and need the Unity Gateway beta features enabled for your account.

FAQs

Which agent should write and which should review?

Either can play either role. Polly sends each diff to a reviewer from a different vendor than the one that wrote it. Pick a pairing by running both on your own repositories and counting the findings that tests or reviewers confirm.

How many review rounds should I allow?

/cross-review loops blocking issues back as fixes until clean, so add your own limit if you want a bounded loop. Escalate to a person when the cap is reached or a blocking finding keeps coming back.

Can the reviewer see more than the diff?

Yes. Run the reviewer inside a repository checkout so it can read the surrounding files, and send only what the question needs.

The information provided herein is for general informational purposes only and may not reflect the most current product capabilities or configurations.