Run Codex and Claude Code Side by Side
Why run two coding agents at once?
Codex and Claude Code are most useful together when they have different responsibilities. For example, let Codex implement a feature in one branch while Claude Code writes tests, reviews the diff, or investigates edge cases in another. The important rule is simple: never point both agents at the same working directory. Concurrent edits to the same files create noisy diffs, overwritten changes, and hard-to-debug conflicts.
A practical low-cost setup is 59API. It provides pay-as-you-go access to native official-quality Claude and GPT models through one relay, while remaining compatible with Claude Code, Codex, and OpenAI SDK tooling. That means you can use an appropriate model for each task without maintaining separate billing setups or accepting downgraded model quality.
1. Create isolated Git worktrees
Start with a repository that has one initial commit. Then create one branch and worktree for each assistant. Run this from your project root:
git init; printf "# Dual agent demo\n" > README.md; git add README.md; git commit -m "Initial commit"; git worktree add ../dual-agent-codex -b codex/feature; git worktree add ../dual-agent-claude -b claude/review
You now have three directories: the original repository, ../dual-agent-codex, and ../dual-agent-claude. Each worktree has its own checked-out branch, so Codex can modify implementation files without colliding with Claude Code’s test or review work.
2. Configure Codex with the 59API OpenAI-compatible endpoint
Open a terminal in the Codex worktree. Create an API key in your 59API dashboard, store it in an environment variable, and point Codex to the OpenAI-compatible API base URL:
cd ../dual-agent-codex; export OPENAI_API_KEY="$API59_KEY"; export OPENAI_BASE_URL="https://api.59api.com/v1"; codex --model YOUR_59API_GPT_MODEL
Replace YOUR_59API_GPT_MODEL with a GPT model identifier available in your 59API account. Keeping credentials in environment variables avoids committing keys into .env files, shell history, or repository configuration. For a quick connection check, ask Codex a read-only question first: codex "Read README.md and summarize the project. Do not change files."
3. Configure Claude Code in its own terminal
In a second terminal, enter the Claude worktree. Claude Code commonly uses an Anthropic-compatible base URL and authentication token for relay providers:
cd ../dual-agent-claude; export ANTHROPIC_AUTH_TOKEN="$API59_KEY"; export ANTHROPIC_BASE_URL="https://api.59api.com"; claude --model YOUR_59API_CLAUDE_MODEL
Select a Claude model available through 59API. A capable Sonnet or Opus option fits architecture review and difficult debugging, while a smaller model can be economical for repetitive test generation or documentation checks. Verify the exact supported model names in the 59API dashboard before scripting them into team tooling.
4. Give each agent a narrow, non-overlapping task
Clear task boundaries are more valuable than simply running two agents. In the Codex terminal, use a feature-focused request such as: “Implement CSV export for completed orders. Modify only files under src/. Add no tests. Explain the changed files before editing.”
In the Claude Code terminal, assign a validation-focused request: “Inspect the existing order logic and add tests for CSV escaping, empty values, and Unicode names. Work only under test/. Do not modify src/.”
The directory constraints reduce overlap, while the branch separation makes any remaining conflict easy to resolve. Ask both agents to show a plan before writing files when the change is larger than a small bug fix.
5. Review and merge deliberately
After each agent finishes, inspect the work rather than merging automatically. Useful commands include: git -C ../dual-agent-codex diff; git -C ../dual-agent-claude diff; git -C ../dual-agent-codex status; git -C ../dual-agent-claude status.
Commit each completed branch, then cherry-pick the commits into your main branch one at a time. Run your formatter, unit tests, and integration tests after every cherry-pick. If both branches touched a shared interface, merge the implementation first and ask Claude Code to re-run or update tests against that final state.
Keep the workflow fast and affordable
Use the stronger model only where it changes the outcome: design decisions, complex refactors, and security-sensitive review. Use lower-cost models for test scaffolding, straightforward edits, and repeated checks. 59API’s pay-as-you-go pricing makes this mixed-model workflow practical, and its referral rebate can further reduce costs for teams that share it. If you want one compatible endpoint for both tools, sign up for 59API and begin with a small read-only task before moving to production changes.
¿Listo para empezar?
Conecta Claude y GPT en minutos a los precios más bajos, sin recortes. Regístrate para obtener tu clave API.
Registro gratis