In the previous Agents & Teams Hands-On Guide , we walked through everything from configuring to triggering Claude Code’s Subagents and Agent Teams. By now, you should know how to make Claude delegate tasks to itself.
But have you noticed a problem? No matter how many Subagents you create or Teammates you spin up, the same Claude model is doing all the work under the hood. It’s like forming a band where the singer, guitarist, and drummer are all the same person — same face, same style, same vibe. No matter how you arrange the setlist, everything comes out sounding identical.
A real band needs musicians with different strengths. AI collaboration works the same way. Claude is great at orchestrating tasks and synthesizing reasoning. OpenAI’s Codex CLI has its own edge in code implementation and pattern analysis. Google’s Gemini CLI benefits from a million-token context window, making it a natural fit for large file analysis and security audits. Pull all three models into one workflow, each doing what they do best, and you’ll get better results than one Claude playing every part.
This article gives you 4 methods, ranging from a single command to a distributed real-time messaging setup. Pick the one that fits your needs.
4 Methods at a Glance
Before we dive in, here’s a quick overview of what each approach offers.
| Method | Core Idea | Difficulty | Best For |
|---|---|---|---|
| MCP Integration | Wrap Codex/Gemini as MCP services, let Claude call them directly | Medium | Daily dev work, getting a quick “second opinion” |
| Custom Subagent | Write an Agent file that calls external CLIs via Bash | Low | Custom review/analysis workflows |
| claude-octopus Plugin | Third-party plugin, install and go | Low | Don’t want to configure anything yourself |
| agent-relay Communication | Independent message layer for real-time AI-to-AI chat | High | Complex distributed multi-Agent projects |
I’d suggest starting with Method 1. If it works well, explore the rest.
Method 1: Plug In External AI With One MCP Command
MCP (Model Context Protocol) is an open protocol built by Anthropic. Its purpose is simple: give AI a standard interface for talking to external tools. Think of it like ordering food delivery — Claude places an order through the menu (MCP protocol), Codex or Gemini cooks the dish in the kitchen (MCP Server), and the result gets delivered back. Claude doesn’t need to know how the kitchen works. Just order and eat.
Connecting Codex CLI
codex-as-mcp is a Python package that wraps Codex CLI into an MCP service. Once installed, Claude Code can call Codex just like one of its built-in tools.
Step 1: Make sure Codex CLI is installed
npm install -g @openai/codex@latest
codex --version
You should see a version number. If not, run codex login to authenticate first.
Step 2: Add the MCP service with one command
claude mcp add codex-subagent -- uvx codex-as-mcp@latest
That’s it. One line. uvx automatically downloads and runs the codex-as-mcp package — no manual pip install needed.
If you prefer manual configuration, edit the .mcp.json file in your project root:
{
"mcpServers": {
"codex-subagent": {
"type": "stdio",
"command": "uvx",
"args": ["codex-as-mcp@latest"]
}
}
}
Step 3: Use it in Claude Code
Restart Claude Code, then just say:
Use the codex-subagent's spawn_agent tool to review src/main.py, focusing on performance and security.
What you should see: Claude invokes the spawn_agent tool from codex-subagent, Codex independently analyzes your code, then returns results to Claude.
codex-as-mcp provides two tools:
| Tool Name | Purpose |
|---|---|
spawn_agent(prompt) | Launch a single Codex Agent to handle one task |
spawn_agents_parallel(agents) | Launch multiple Codex Agents working in parallel |
Want to review multiple files at once? Say this:
Use codex-subagent's spawn_agents_parallel to have one Agent review src/api.py and another review src/database.py.
Two Codex Agents fire up simultaneously, each reviewing their assigned file, results compiled and returned together.
Connecting Gemini CLI
There are several ways to connect Gemini CLI. Let’s start with the simplest.
Option A: Use gemini-mcp-tool (one command)
claude mcp add --transport stdio gemini -- npx -y gemini-mcp-tool
This assumes you already have Gemini CLI installed and authenticated. OAuth login is recommended (included with Google Pro/Plus/Ultra plans), which means no extra API charges.
Option B: Use a Google API Key
If you have a Google API Key, you can configure the official MCP Server directly:
{
"mcpServers": {
"gemini": {
"command": "npx",
"args": ["-y", "@anthropic-ai/gemini-mcp-server"],
"env": {
"GOOGLE_API_KEY": "your-api-key-here"
}
}
}
}
Both options work. The difference: Option A uses OAuth and is free (if you already have a Google subscription), while Option B uses an API Key with pay-per-use billing.
Mixture of Experts Mode: All Three Models Together
Once you’ve configured MCP services for both Codex and Gemini, you can run “mixture of experts mode.” Claude acts as the conductor, Codex handles code implementation, and Gemini manages security reviews and large-file analysis.
Just tell Claude:
Collaborate with GPT and Gemini MCP to solve this problem.
A small tip here: don’t specify model versions in your prompt. Claude sometimes defaults to older versions, and leaving it unspecified actually lets it use the latest model configured in MCP.
What does this look like in practice? Say you ask Claude to refactor an auth module:
- Claude analyzes requirements and breaks down tasks
- Code implementation goes to Codex, since its code generation is more consistent for certain pattern-matching scenarios
- Security review goes to Gemini, leveraging its million-token context window to ingest the entire codebase at once
- Claude synthesizes both results, runs quality gates, and makes the final call
Three models, each owning their lane, covering each other’s blind spots.
Method 2: Custom Subagent Calling External CLIs
In the previous article, you already learned how to create Subagents. This time, instead of having them use only Claude, we’ll have them call Codex CLI or Gemini CLI through the Bash tool.
The advantage is flexibility. What the Agent does first, what it does next, how it handles errors — it’s all in the Agent file, and you’re in control.
Codex Code Review Subagent
Create the file .claude/agents/codex-reviewer.md:
---
name: codex-reviewer
description: >
Uses OpenAI Codex CLI for deep code reviews. Use this agent when you
need an independent third-party review of code changes. Strong at
identifying code pattern issues and architectural flaws.
tools: [Bash, Read, Glob, Grep]
model: sonnet
---
You are a code reviewer agent that delegates review work to the Codex CLI.
## Workflow
1. First, use Read/Glob/Grep to understand the files that need review.
2. Write a detailed review request to a temporary file:
```bash
REVIEW_FILE=$(mktemp)
- Call Codex to perform the review:
codex exec "Review the code changes. Focus on performance, security, and maintainability." - Parse Codex’s response and present a structured review report.
Review Focus Areas
- Code readability and maintainability
- Performance bottlenecks
- Security vulnerabilities
- Error handling completeness
Compared to Method 1's MCP approach, the difference is this: the Subagent does its own analysis first, organizes the material, then hands the key parts to Codex. You wouldn't dump a pile of raw data on an external consultant, right? You'd compile the background info and specific questions first. That way, Codex gets a preprocessed, focused problem, and the review quality goes up accordingly.
### Gemini Architecture Analysis Subagent
Create the file `.claude/agents/gemini-architect.md`:
```markdown
---
name: gemini-architect
description: >
Uses Google Gemini CLI for architecture analysis and design reviews.
Use this agent when you need deep analysis of project architecture,
design patterns, or technology choices.
Strong at global analysis of large-scale codebases.
tools: [Bash, Read, Write]
model: sonnet
---
You are an architecture analyst agent that leverages Gemini CLI.
## Workflow
1. Gather relevant code and documentation using Read tools.
2. Prepare an analysis request with full context.
3. Call Gemini for analysis:
```bash
gemini exec "Analyze the following codebase architecture. Identify potential issues with scalability, maintainability, and security. Suggest improvements."
- Synthesize Gemini’s response into actionable recommendations.
Analysis Dimensions
- System architecture and component boundaries
- Data flow and dependency patterns
- Scalability considerations
- Security architecture review
Gemini's million-token context window really shines here. Analyzing a project with tens of thousands of lines — Claude might need to read it in chunks, but Gemini can swallow it whole.
### Don't Want to Create Files? Use CLI Arguments for a One-Off
The `--agents` parameter from the previous article works here too:
```bash
claude --agents '{
"codex-quick-review": {
"description": "Quick code review using Codex CLI for a second opinion.",
"prompt": "You are a code review agent. Use the Bash tool to call codex exec for an independent Codex assessment. First use Read and Grep to understand the code, then hand key findings to Codex for validation.",
"tools": ["Read", "Grep", "Glob", "Bash"],
"model": "haiku"
}
}'
Use it and toss it. No files left behind.
Method 1 vs. Method 2: Which to Choose
| Dimension | MCP Integration (Method 1) | Custom Subagent (Method 2) |
|---|---|---|
| Setup Speed | Fast, one command | Medium, requires writing an Agent file |
| Flexibility | Low, fixed tool interface | High, workflow defined by you |
| Preprocessing | None, requests forwarded directly | Yes, Subagent organizes before forwarding |
| Maintenance Cost | Low, maintained by package author | Medium, you maintain the Agent file |
| Best For | Quick calls, simple logic | Multi-step workflows, special handling needed |
For everyday use, Method 1 is plenty. Switch to Method 2 when you need fine-grained control.
Method 3: Use the claude-octopus Plugin to Save Yourself Some Work
The first two methods require you to configure MCP or write Agent files yourself. If you’d rather not bother, claude-octopus is a third-party plugin that handles all of that for you.
The three models have clear roles:
| Model | Role |
|---|---|
| Codex (OpenAI) | Code implementation and technical analysis |
| Gemini (Google) | Security audits, alternative exploration, large-context analysis |
| Claude (Anthropic) | Orchestration, quality gates, final synthesis |
Installation
Run this in Claude Code:
/plugin marketplace add nyldn/claude-octopus
/plugin install claude-octopus@nyldn-plugins
/octo:setup
The setup wizard automatically detects which CLI tools you have installed. Only have Codex but not Gemini? Still works — you just lose one perspective in the analysis. If neither is installed, it still has 29 built-in roles and structured workflows, though that’s no longer “multi-AI” per se.
Commonly Used Commands
| Command | What It Does | How It Works |
|---|---|---|
/octo:research | Multi-AI parallel research | Same question sent to all three models, independent analyses combined |
/octo:review | Multi-dimensional code review | Codex checks code quality, Gemini scans for security issues, Claude does final assessment |
/octo:debate | Structured debate | Three models argue different positions on a technical decision, multiple rounds |
/octo:embrace | Full development lifecycle | From requirements discovery to delivery, four phases auto-orchestrated |
The one I use most is /octo:review. After writing a chunk of code, I run it — Codex reviews from a code quality angle, Gemini scans from a security and edge-case angle, Claude synthesizes both opinions for a final assessment. Three reviewers looking at your code simultaneously, each watching from a different direction. The odds of missing something drop significantly.
Note: This is a third-party plugin, not an official Anthropic product. Before using it, check the GitHub Issues and recent commit history to make sure it’s still maintained.
Method 4: Cross-Process Real-Time Communication With agent-relay
In the first three methods, AIs communicate through a “relay” pattern. Claude sends a task to Codex, Codex completes it and returns results to Claude, but Codex never reaches out to Gemini directly. If you need AIs to actually talk in real time — like a group chat where they can message, discuss, and coordinate with each other — you need agent-relay .
What Problem Does It Solve
Imagine you have three projects: an auth service, a frontend app, and an API gateway. Each project has an AI Agent running inside it. When the auth service’s Agent changes an interface, it needs to notify the frontend app’s Agent to update its calls, and simultaneously notify the API gateway’s Agent to update routing rules.
This kind of cross-project, cross-process Agent communication is beyond what the first three methods can do. agent-relay handles exactly this — an independent message layer with sub-5ms latency that any CLI tool’s Agent can plug into.
Installation and Startup
# Install
curl -fsSL https://raw.githubusercontent.com/AgentWorkforce/relay/main/install.sh | bash
# Start with the visual Dashboard
agent-relay up --dashboard
After startup, visit http://localhost:3888 to see a management panel with real-time status and messages for all Agents.
Spawn Agents and Establish Communication
# Spawn three Agents driven by different models
agent-relay spawn Lead claude "Coordinate all development tasks"
agent-relay spawn Implementer codex "Awaiting development instructions"
agent-relay spawn Reviewer gemini "Awaiting review requests"
Then install the MCP Server so Agents can message each other:
npx @agent-relay/mcp install
After installation, each Agent can use tools like relay_send (send messages), relay_inbox (check inbox), and relay_who (see who’s online) to communicate.
Multi-Project Bridging
If you have multiple projects that need cross-project collaboration:
cd ~/auth-service && agent-relay up
cd ~/frontend-app && agent-relay up
agent-relay bridge ~/auth-service ~/frontend-app ~/api-gateway
Agents across all three projects can now communicate with each other.
When do you actually need this? Honestly, most people don’t. Methods 1 through 3 cover 90% of daily scenarios. Only when your project genuinely involves multiple independent services where Agents need real-time coordination is this worth the setup effort.
Advanced: Let Hooks Auto-Trigger Multi-AI Reviews
At the end of the previous article, we mentioned Hooks. Here’s what I think is the most practical Hook use case: automatically running a multi-AI code review every time Claude finishes writing code.
How It Works
Claude Code’s stop Hook fires after Claude completes each task. In this Hook, launch a script that decides the review level based on the size of code changes:
| Change Size | Review Level | What Happens |
|---|---|---|
| Under 500 characters, 1 file | Skip | Too small to bother reviewing |
| 500 - 5,000 characters | Quick Review | 1 Haiku Agent does a scan |
| 5,000 - 20,000 characters | Standard Review | 3 Agents check bugs, security, and test coverage separately |
| Over 20,000 characters or 6+ files | Deep Review | Multiple Sonnet/Opus Agents do architecture-level review |
Configuration
Add this to .claude/settings.json:
{
"hooks": {
"stop": [{
"command": "python .claude/hooks/auto-code-review.py",
"timeout": 300000
}]
}
}
Then write the review logic in .claude/hooks/auto-code-review.py. The approach is straightforward:
- Run
git diffto get the changes - Count characters and files
- Decide review level based on change size
- Invoke the appropriate Agents to do the review
This approach comes from the community project claude-on-rails-review. Once configured, you never have to think about “time to review” again. Every time Claude pauses, the Hook runs automatically. It’s like keeping a snack basket on your coffee table — just grab one whenever, no trips to the kitchen needed.
A Real Case: 16 Agents Refactoring Documentation
After all these methods, let’s look at a real example that actually shipped.
Eugene Petrenko used 16 AI Agents across four phases to refactor an entire project documentation set:
Phase 1 — Interviews (4 Agents): No rushing in. Four Agents role-played as “users,” conducting structured interviews to find out where the docs fell short.
Phase 2 — Parallel Refactoring (5 Agents): Based on interview findings, five Agents simultaneously rewrote different documentation files.
Phase 3 — Validation (4 Agents): This is the most interesting part. A completely fresh set of Agents — ones with zero prior context — validated the results. Why not use the same Agents that wrote the docs? Because when you review your own writing, everything always looks fine. Having “strangers” read it reveals what’s actually confusing.
Phase 4 — Final Review (3 Agents): Wrap-up checks.
Results: Documentation length reduced by 39%, quality scores improved by 15%, navigation speed for key commands increased 5x.
The most valuable lesson from this case isn’t “use more Agents” — it’s Phase 3’s “swap in fresh reviewers.” The same principle applies to code. Having the coding Agent self-review is far less effective than bringing in a fresh Agent. This is exactly why I recommend using different models for reviews: code written by Claude, reviewed by Codex, surfaces problems that Claude would never catch looking at its own work.
Reddit user creegs had a similar experience: they used Claude’s Agent Teams to implement a major feature and were pretty happy with it. Then they had Gemini do a code review, and it found 19 significant issues in one pass. It’s not that Claude wrote bad code — it’s that different models watch for different things. Cross-model review catches more.
Which One Should You Pick
| Your Need | Recommended Method | Why |
|---|---|---|
| Get Codex/Gemini to look at your code | Method 1: MCP Integration | One command, fastest to start |
| Want to control every step of the review process | Method 2: Custom Subagent | Maximum flexibility |
| Don’t want to configure anything, just install and use | Method 3: claude-octopus | Plugin handles everything for you |
| Multiple projects, multiple Agents, need real-time coordination | Method 4: agent-relay | Only option supporting cross-process communication |
| Auto-review after every code change | Hooks + Subagent | Set up once, works forever |
For most people, Method 1 is enough. Configure MCP services for Codex and Gemini, and when you need them, just say “have Codex take a look” or “get Gemini to scan for security issues.”
FAQ
MCP service is configured but Claude isn’t calling the external AI?
Two possibilities. First, you didn’t restart Claude Code, so the new MCP config hasn’t loaded. Second, your prompt doesn’t mention the MCP service by name. Saying “use codex-subagent to…” directly triggers it far more reliably than a vague “review my code.”
Can’t install Codex CLI?
Make sure your Node.js version is 18 or above. npm install -g @openai/codex@latest requires global install permissions — on Mac you might need sudo, or use nvm to manage Node versions and sidestep the issue.
How do I set up Gemini CLI’s OAuth authentication?
Run gemini auth login, a browser window pops up with the Google login page, and you sign in. Make sure you use an account with a Gemini Pro/Plus/Ultra subscription, otherwise you’ll be billed through the API.
Can I afford running three models at once?
Claude’s costs stay the same. Codex and Gemini depend on how you connect them: Gemini via OAuth is covered by your Google subscription with no extra charge; via API Key it’s pay-per-use. Codex currently has a free tier. For typical code review scenarios, each call uses a modest number of tokens, so the additional cost is minimal.
Is claude-octopus safe to use?
It’s a third-party plugin, not an official product. As of this writing, the GitHub repo is still receiving updates. I’d suggest testing it on a side project first before using it in production.
Wrapping Up
No matter how powerful a single AI model is, it has blind spots. Different models are trained on different data, optimized for different goals, and excel at different things. Having them review each other’s output is like having colleagues from different technical backgrounds do peer reviews — they’ll find more issues than self-review ever would.
This article gave you 4 methods. I’d suggest starting with Method 1’s MCP integration — set up one Codex MCP service and let it help review your code. Use it for a few days, feel the difference a “second opinion” makes, then decide whether to bring in Gemini or try more advanced setups.
What have you discovered using multi-AI collaboration? Found certain model combinations that work especially well, or hit some unexpected pitfalls? Let’s talk in the comments.
The next article covers Claude Code’s Hooks and Skills system — how to give your AI assistant “reflexes” and “professional skills.” Bookmark it if you’re interested.
If you haven’t read the previous Agents & Teams Hands-On Guide , I’d recommend going through that first to get the Subagent and Teams basics down. Multi-AI collaboration will go much smoother with that foundation.
