GUIDE

How to Use Codex Inside Claude Code (MCP Setup)

Install OpenAI Codex as an MCP server inside Claude Code with one command. Get a second opinion on code reviews, architecture, and bugs without leaving your terminal.

Lenny Rachitsky comparing AI model personalities: Claude as the creative partner, GPT as the generalist, Gemini as the research assistant, and Codex as the autistic senior engineer

via @lennysan

Most people think of Codex and Claude Code as competitors. Pick one, ignore the other. I use Codex inside Claude Code every day, and it's one of the best setups I've found for shipping reliable software fast.

Why You'd Want This

A second model with a totally different training set catches things the first model misses. I've seen Codex flag race conditions, missing error boundaries, and subtle type mismatches that Claude Code sailed past. And I've seen Claude Code catch UX issues and architectural problems that Codex would never notice.

The stereotype about Codex being the "autistic senior engineer" is honestly pretty accurate. Extremely thorough on architecture, bug detection, and code review. Less personality, less fun to talk to. But when you want someone to tear apart your code looking for problems? That's exactly what you want.

Setup: One Command

Install Codex as an MCP server in Claude Code:

claude mcp add --scope user --transport stdio codex -- codex mcp-server

That's it. The --scope user flag means it's available in every project, not just the current one. You'll need codex installed globally first (npm install -g @openai/codex) and an OpenAI API key configured.

To verify it's working, start a new Claude Code session and type:

review this file with codex

Claude Code will call out to Codex through the MCP connection and relay the response back to you. You stay in one terminal, one conversation, one context window.

Where Codex Shines (Inside Claude Code)

After months of using this setup, clear patterns emerge in where the second opinion actually changes outcomes.

Code Review

This is the killer use case. You build something with Claude Code, then say "have Codex review this." Codex will catch things like missing null checks, potential memory leaks, incorrect error handling, and edge cases in your logic. It's thorough in a way that's almost annoying (in a good way).

Review the changes I just made with Codex. Focus on correctness and edge cases.

Architecture Decisions

When you're building something new and Claude Code proposes an architecture, bounce it off Codex. "Ask Codex if this database schema makes sense for our read patterns." Codex tends to think in terms of systems, scalability, and failure modes. It'll flag things like "this will require a full table scan at 100k rows" before you've written a line of code.

Bug Hunting

Got a bug that Claude Code can't find? "Show Codex the error and the relevant code, ask what's causing it." Different model, different reasoning chains, different blind spots. I've had Codex spot the issue on bugs where I'd been going back and forth with Claude Code for 20 minutes.

Sanity Checks on Complex Logic

Any time you're dealing with auth flows, payment logic, data migrations, or anything where being wrong costs real money, get the second opinion. "Have Codex verify this Stripe webhook handler is correct." Takes 30 seconds. Could save you hours of debugging in production.

Where Codex Doesn't Help

Codex inside Claude Code isn't magic for everything. Knowing its weaknesses saves you time.

  • Frontend and UI work. Codex is weaker at visual design, CSS nuance, and UX decisions. If you're building a landing page or tweaking a component's look and feel, Codex's feedback will be generic at best. Claude Code is significantly better here.
  • Creative decisions. Naming things, writing copy, designing user flows. Codex gives you technically correct but lifeless suggestions. Don't ask it to name your product.
  • Conversational iteration. Codex responds are more terse and functional. It's not going to riff with you on ideas or explore possibilities. It answers the question and stops.

My Actual Workflow

Here's how this looks in practice on a typical day:

  1. Build with Claude Code. I write features, debug, iterate, all in the conversational flow that makes Claude Code great.
  2. Review with Codex. Before committing anything non-trivial, I say "have Codex review the changes." This is my automated second pair of eyes.
  3. Resolve disagreements. Sometimes Claude Code and Codex disagree. When they do, I read both arguments and make the call myself. The disagreement itself is valuable because it highlights where reasonable people (or AIs) could go either way.

The whole cycle adds maybe 2-3 minutes per commit. For the bugs it catches, that's an absurd ROI.

Getting Started

The setup takes under a minute. The first time Codex catches a bug that Claude Code missed, you'll understand why this combo works.

# Install Codex globally
npm install -g @openai/codex

# Add it as an MCP server in Claude Code
claude mcp add --scope user --transport stdio codex -- codex mcp-server

If you're already using Claude Code, this is one of the highest-leverage things you can add. Two models, one terminal, better code.

Want to learn the full Claude Code workflow? Check out ClaudeFluent where we cover MCP servers, agents, skills, and everything else you need to ship real software. And if you want to see how Codex compares to Claude Code as a standalone tool, read our Claude Code vs Cursor comparison.

Related Guides

WANT MORE LIKE THIS?

Learn to build with Claude Code

6 hours of hands-on training. Build real projects. Ship without waiting on engineering.

View Class Details