Codex + Claude Code: A Two-Terminal Quick Start
Two coding agents, one repository—without collisions
Running Codex and Claude Code side by side works best when each agent has its own terminal, Git worktree, and assignment. You can parallelize implementation and tests, or ask one agent to review the other’s patch. The important rule: do not let both agents edit the same working directory.
This quick start uses 59API as the shared API relay. Its low-cost, pay-as-you-go access lets you use both tools without managing separate upstream API accounts. Available choices include Claude Sonnet 5.5 and GPT-6.1 Sol; use the exact API model identifiers supplied by 59API, not necessarily those display names.
1. Install both command-line tools
With a supported Node.js release and npm installed, run:
npm install -g @openai/codex @anthropic-ai/claude-code
Check the installations with codex --version and claude --version. Follow each tool’s current runtime requirements if installation fails. Before configuring the relay, save any existing client configuration so you can restore your usual provider setup.
2. Connect each tool to 59API
Create a 59API key and check its client-specific setup instructions. The service base URL is https://api.59api.com. Copy the endpoint recommended for each client, including any required path suffix. An OpenAI-compatible endpoint and an Anthropic-compatible endpoint are not automatically interchangeable.
For Claude Code, set these variables in its terminal, replacing the placeholders:
- export ANTHROPIC_BASE_URL='https://api.59api.com'
- export ANTHROPIC_API_KEY='YOUR_59API_KEY'
- export ANTHROPIC_MODEL='CLAUDE_MODEL_ID_FROM_59API'
Use the relay’s documented Claude Code authentication method if it specifies a different variable. If Claude Code is already signed into another account, resolve that authentication conflict before testing; otherwise, you may accidentally use your existing subscription instead.
For Codex, export FIFTYNINE_API_KEY='YOUR_59API_KEY'. Then merge the following settings into ~/.codex/config.toml, with each item on its own line. Keep the first two settings outside any TOML section:
- model = "CODEX_MODEL_ID_FROM_59API"
- model_provider = "relay59"
- [model_providers.relay59]
- name = "59API"
- base_url = "CODEX_BASE_URL_FROM_59API"
- env_key = "FIFTYNINE_API_KEY"
- wire_api = "responses"
Select a model and endpoint that support Codex’s Responses API requests, not just ordinary chat completions. Follow 59API’s current Codex configuration if its instructions differ. Keep credentials out of source control and avoid exposing them in shared terminal recordings or shell history.
3. Give each agent an isolated worktree
From your repository, start with a clean working tree and run:
- git worktree add -b ai/codex ../project-codex HEAD
- git worktree add -b ai/claude ../project-claude HEAD
In terminal A, run cd ../project-codex, then codex. In terminal B, run cd ../project-claude, then claude. Install project dependencies in each worktree as needed. Give development servers different ports; worktrees do not isolate ports, databases, or external services.
4. Split the work with explicit boundaries
Assign complementary tasks rather than asking both agents to “finish the feature.” For example:
- Codex: “Implement request validation in the API handler. Do not change tests or dependencies. Run the existing validation tests and summarize failures.”
- Claude Code: “Add regression tests for missing and malformed request fields. Do not modify application code. Explain which cases fail before implementation.”
Commit each result separately. Review both diffs, then cherry-pick the relevant commits onto an integration branch. Run the full checks after combining them: independently passing branches can still conflict logically. Keep command approvals enabled until you understand each agent’s behavior.
5. Verify routing and control spending
Before a large task, send one small request through each tool and check 59API’s usage records to confirm routing and billing. Limit parallel sessions, avoid feeding both agents entire logs, and reserve expensive reasoning for difficult work.
59API offers native official-quality models without downgrading, low-cost usage-based pricing, and a referral rebate. Compare actual task costs rather than headline rates alone. If this workflow fits your team, sign up for 59API and try one small, measurable task in each terminal first.
¿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