Adversarial Code Review Architecture Between Claude Code and OpenAI Codex
The adversarial code review architecture in the anthropics/claude-plugins-community repository implements a structured, multi-stage loop where Claude Code serves as the designer and reviewer while OpenAI Codex acts as the independent auditor and implementer, utilizing branch isolation, MCP command routing, and blind validation passes to eliminate model bias.
The anthropics/claude-plugins-community repository contains a sophisticated adversarial code review system that orchestrates complementary AI agents through an iterative workflow. This architecture leverages the unique strengths of both Claude Code and OpenAI Codex to create a self-correcting development pipeline, ensuring high-quality software design through independent auditing and mandatory human gating.
The Claude-Codex Review Loop
The core of the adversarial system is the claude-codex-loop skill defined in .claude-plugin/marketplace.json at line 389. This component orchestrates a two-stage iterative process that separates design from implementation, preventing the cognitive biases that emerge when a single model handles both tasks.
The loop operates through six distinct phases:
- Design Stage: Claude Code drafts a specification document based on user requirements
- Independent Audit: OpenAI Codex critiques the design without prior context, iterating until specification convergence
- Human Gate: The user must approve the converged design before proceeding to implementation
- Code Stage: Codex generates implementation code based on the approved specification
- Diff Review: Claude Code reviews the generated code diffs in multiple rounds (up to five iterations)
- Blind Validation: A fresh Codex instance audits the final implementation with zero prior context to catch group-think errors
MCP Integration and Command Interface
The architecture utilizes the Multi-Tool Control Protocol (MCP) to provide a unified command surface for both agents. The system registers specific slash commands in .claude-plugin/marketplace.json that route requests to the appropriate model based on the current review phase.
Key commands include:
/review-loop <task>: Initiates a new adversarial review session for the specified feature or task/cancel-review: Terminates the current review loop and restores the repository to its original state
These commands abstract the complexity of model routing, allowing you to interact with a single interface while the system coordinates handoffs between Claude Code and Codex.
Branch Isolation and State Management
The adversarial architecture enforces branch isolation to guarantee experimental changes never contaminate the main codebase. When a review loop initiates, the system creates a dedicated temporary branch for all design documents and implementation code.
State persistence occurs through the .ai-sync/ directory, which stores intermediate artifacts including:
- Specification documents from the design phase
- Code diffs from implementation rounds
- Validation reports from audit passes
These files enable context preservation across tool boundaries, allowing each agent to pick up exactly where the previous one left off.
The Adversarial Review Workflow
Design Phase with Independent Auditing
During the design phase, Claude Code generates a specification document. OpenAI Codex then performs a critical audit of this design independently, examining the specification for logical flaws, edge cases, and architectural inconsistencies. This audit repeats in rounds until the design converges to a stable state that satisfies both models.
Implementation and Diff Review
Once you approve the design through the human gate, Codex transitions to the code stage, generating implementation code based on the approved specification. Claude Code then performs a full-diff review, examining the generated code line-by-line across multiple iterations to catch bugs, security issues, and deviation from the specification.
Blind Validation Pass
The workflow concludes with an independent validation pass where a fresh Codex instance—configured with zero prior context from the previous rounds—audits the final implementation. This blind audit prevents group-think and confirmation bias between the collaborating agents.
Quality Gates and Hook System
The architecture implements gate-keeping hooks defined in hooks.json (typically located in .claude/ or .codex/ directories) that enforce quality standards before advancing between stages.
Pre-stage hooks block progression from design to implementation until explicit user approval confirms the specification meets requirements. Post-stage hooks verify that generated code passes automated tests, linting, and security scans before allowing merge operations.
Practical Usage Examples
The following commands demonstrate how developers interact with the adversarial review system. These examples assume the Claude Code plugin is installed and the repository is opened in a compatible environment:
# Start a new adversarial review loop for a feature
/review-loop add-payment-gateway
# Cancel the ongoing review and restore original branch state
/cancel-review
During operation, agents exchange messages automatically through the .ai-sync/ directory. You receive high-level prompts for approval gates while the system handles model coordination transparently.
Summary
- The claude-codex-loop in
.claude-plugin/marketplace.json#L389orchestrates a two-stage adversarial process separating design from implementation - Branch isolation ensures experimental changes remain confined to temporary branches until final validation
- MCP integration provides unified slash commands (
/review-loop,/cancel-review) for routing requests between Claude Code and OpenAI Codex - State persistence through the
.ai-sync/directory maintains context across tool boundaries - Blind validation passes with fresh model instances eliminate group-think and confirmation bias
- Quality gates in
hooks.jsonenforce automated testing and linting before stage advancement
Frequently Asked Questions
How does the adversarial code review prevent model bias?
The architecture prevents bias through independent auditing and blind validation. OpenAI Codex audits Claude Code's designs without prior context, and vice versa during implementation review. A final blind validation pass uses a fresh Codex instance with zero conversation history to catch errors that collaborative models might overlook due to group-think.
What happens if the design and implementation phases disagree?
The workflow includes explicit human gates between phases. If the implementation deviates significantly from the approved design, Claude Code's diff review catches the discrepancy during the code stage. The loop supports up to five review rounds between agents, and you can reject changes or restart the loop using /cancel-review if consensus cannot be reached.
Where are the intermediate artifacts stored during the review process?
Intermediate artifacts including specifications, diffs, and validation reports are stored in the .ai-sync/ directory at the repository root. This state persistence mechanism allows agents to resume work with full context even if the review process spans multiple sessions or requires switching between Claude Code and Codex instances.
Which source files define the adversarial review behavior?
The primary configuration resides in .claude-plugin/marketplace.json, specifically around line 389 where the claude-codex-loop skill is declared. Additional behavior is governed by hooks.json files in .claude/ or .codex/ directories that enforce quality gates, and individual SKILL.md files under skill directories (such as quickdesign/skills/quickdesign/SKILL.md) that provide detailed usage instructions for specific adversarial review commands.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →