Running two AI coding assistants in the same terminal workflow sounds like overkill until you experience what it catches. Claude might write a clean solution; Codex might spot a race condition or a subtle API misuse that Claude glossed over, and vice versa. This guide wires both CLIs into Git Bash on Windows, then gives you a practical piping workflow so that one model always reviews what the other wrote. The result is a lightweight, no-extra-tooling second opinion baked directly into your git workflow.
Prerequisites
- Git for Windows installed, with Git Bash available
- Node.js (LTS) available in your PATH inside Git Bash
- Python 3.9 or later for the Anthropic SDK
- An Anthropic API key and an OpenAI API key
- Basic comfort with shell scripting and
git diff
Installing Claude Code in Git Bash
Claude Code is Anthropic’s official CLI for agentic coding tasks. Install it globally via npm:
npm install -g @anthropic-ai/claude-codeAuthenticate by exporting your key. Add the following line to your ~/.bashrc or ~/.bash_profile so it persists across sessions:
export ANTHROPIC_API_KEY="sk-ant-..."Reload the shell and confirm the CLI responds:
source ~/.bashrc
claude --versionClaude Code picks up the ANTHROPIC_API_KEY environment variable automatically. No extra config file is needed.
Installing the OpenAI Codex CLI in Git Bash
OpenAI’s Codex CLI is also distributed as an npm package:
npm install -g @openai/codexExport your OpenAI key in the same profile file:
export OPENAI_API_KEY="sk-..."Verify it:
codex --versionBoth CLIs are now available in the same Git Bash session. You can call claude or codex from any directory.
Understanding the Review Workflow
The core idea is simple: one model writes or edits code, you capture a git diff, and you pipe that diff to the other model with a review prompt. You can run this in either direction.
- Claude writes, Codex reviews. Use Claude Code to implement a feature or fix a bug. Stage the changes. Pipe the diff to Codex for an independent review.
- Codex writes, Claude reviews. Let Codex generate or edit code. Stage the changes. Pipe the diff to Claude with a focused review prompt.
Neither model sees its own output in the review step. Each acts as a fresh, independent reader of the patch.
Piping a Git Diff to the Reviewer
The cleanest approach is a short shell function. Add these to your ~/.bashrc:
# Review staged changes with Codex
review_with_codex() {
local prompt="You are a senior code reviewer. Review the following git diff carefully.
Flag bugs, security issues, performance problems, and style violations.
Be concise and specific. Output findings as a numbered list."
git diff --staged | codex --stdin-prompt "$prompt"
}
# Review staged changes with Claude
review_with_claude() {
local prompt="You are a senior code reviewer. Review the following git diff carefully.
Flag bugs, security issues, performance problems, and style violations.
Be concise and specific. Output findings as a numbered list."
git diff --staged | claude --print "$prompt"
}After staging your changes with git add, run either function:
review_with_codex
# or
review_with_claudeThe --print flag on Claude Code and --stdin-prompt on Codex tell each CLI to read from stdin and print a non-interactive response. Check each tool’s --help output if the flag names shift across versions, as CLIs evolve quickly.
Reviewing an Entire Pull Request Diff
For PR-level review, fetch the diff between your branch and main and pipe it directly:
# Claude reviews everything between your branch and main
git diff main...HEAD | claude --print \
"Review this pull request diff as a senior engineer.
Identify any logic errors, missing edge case handling,
or security concerns. Be specific about file and line context."
# Codex reviews the same diff
git diff main...HEAD | codex --stdin-prompt \
"Review this pull request diff as a senior engineer.
Identify any logic errors, missing edge case handling,
or security concerns. Be specific about file and line context."Large diffs benefit from Claude’s 1M-token context window, available on claude-fable-5, claude-opus-4-8, and claude-sonnet-4-6. For smaller, faster reviews on a budget, claude-haiku-4-5 offers a 200K context window and lower latency. You can pass a model flag to Claude Code to select explicitly:
git diff main...HEAD | claude --model claude-haiku-4-5 --print "Review this diff briefly."A Complete End-to-End Example
Here is what a full two-model review session looks like in practice:
# Step 1: Use Claude Code to implement a feature interactively
claude "Add input validation to the user registration endpoint in src/auth.py"
# Step 2: Review Claude's changes with Codex before committing
git add src/auth.py
review_with_codex
# Step 3: Address any findings, then commit
git commit -m "feat: add input validation to user registration"
# Step 4: Later, use Codex to refactor a module
codex "Refactor the database connection pooling in src/db.py for better error handling"
# Step 5: Review Codex's output with Claude
git add src/db.py
review_with_claudeEach review is independent. The reviewing model has no memory of writing the code and no incentive to defend its own choices.
Practical Tips for the Workflow
Keep prompts focused
Generic prompts return generic feedback. Tailor the review prompt to the kind of change you made. A database migration diff needs a different prompt than a UI component refactor. A few extra words in the prompt consistently improve the quality of findings.
Use adaptive thinking for complex diffs
When sending a large or architecturally complex diff to Claude via the Python SDK rather than the CLI, enable adaptive thinking on Claude 4.6 and later models. This replaces the old fixed budget approach:
import anthropic
client = anthropic.Anthropic()
with open("review.diff") as f:
diff_content = f.read()
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=4096,
thinking={"type": "adaptive"},
messages=[
{
"role": "user",
"content": f"Review this diff thoroughly:\n\n{diff_content}"
}
]
)
print(response.content)Adaptive thinking lets the model allocate its own reasoning depth based on the complexity of the input, which works especially well for subtle security or concurrency issues in a diff.
Limit diff size when needed
Even with a million-token context, extremely large diffs reduce review quality because the model has to spread attention across too much surface area. For PRs over a few thousand lines, split the diff by directory:
git diff main...HEAD -- src/api/ | claude --print "Review the API layer changes only."Save reviews to a file for tracking
git diff --staged | claude --print "Review this diff." >> .reviews/$(date +%Y%m%d_%H%M%S)_claude.txtThis gives you a lightweight audit trail of what each model flagged before you committed.
Do not treat either model as the final authority
The goal of cross-model review is diversity of perspective, not automation of judgment. Both models can miss things and both can hallucinate issues that do not exist. Read the output critically. The workflow surfaces things worth checking, it does not replace engineering judgment.
Takeaway
A two-model code review workflow in Git Bash is straightforward to set up and pays for itself quickly. Install both CLIs, export your keys in your shell profile, and write two small functions that pipe git diff output to the non-authoring model. Use Claude’s large context window for PR-level reviews and model-specific flags to tune cost versus depth. The second opinion you get is genuinely independent, and independence is exactly what makes it valuable.
