Connect Claude Code with Codex CLI — share context, switch tools mid-thought, never lose your session
Claudex is a local, open-source session bridge that lets Claude Code and OpenAI Codex CLI talk to each other without losing context. When Claude Code hits its rate limit you jump to Codex, and Codex already knows what you were working on. When you have a better idea while in Codex you switch back to Claude Code, and it picks up exactly where you left off.
claude-code · codex · codex-cli · mcp-server · agents.md · session-bridge · context-handoff · agentic-cli
You pay for both Claude Code (Anthropic) and OpenAI Codex CLI. You're deep in a debug session and one of these happens:
- Claude Code hits its session limit mid-task. Pro users hit it after ~20–30 minutes of agent work; even Max 20x users routinely report session and weekly caps after a few heavy days.
- You want a second opinion from a different model on a tricky bug.
- Codex's repo-scoped memory is better for one part of the job, Claude's interactive feel is better for another.
So you switch tools — and the new one has no idea what you were doing. You paste a summary, the new tool half-understands, momentum dies. Two $200/month subscriptions and you're still copy-pasting context.
Claudex fixes this by tailing both tools' transcript files in real time, maintaining a rolling context per project folder, and injecting it into whichever tool you open next. No API keys, no cloud, no proxy, no subscription tampering. Each tool keeps using its own auth and its own backend. Claudex just makes them share notes.
┌─────────────────┐ ┌────────────────────┐ ┌─────────────────┐
│ Claude Code │ ───► │ Claudex daemon │ ◄─── │ Codex CLI │
│ writes JSONL │ │ │ │ writes JSONL │
└─────────────────┘ │ - watches both │ └─────────────────┘
▲ │ transcript dirs │ ▲
│ │ - normalises + │ │
│ │ interleaves │ │
│ SessionStart │ chronologically │ AGENTS.md │
│ + UserPrompt │ - rolling 2K-tok │ managed │
│ Submit │ context.md / │ block │
│ hooks │ plan.md per │ + MCP │
│ │ project │ │
└─── context.md ─┴────────────────────┴── context.md ┘
If you arrived here from a Google or HN search, this project is the answer to:
- "How do I connect Claude Code with Codex CLI?"
- "How do I share context between Claude Code and Codex?"
- "Claude Code keeps hitting its rate limit — what's the alternative?"
- "Can I use Claude Code and Codex CLI side by side without losing context?"
- "Persistent memory across Claude Code and Codex sessions"
- "How to switch from Claude Code to Codex without re-explaining everything"
- "Smart session sharing between Codex application and Claude Code application"
- "Linking Claude Code application and Codex application"
- "Dual wielding Claude Code and Codex"
- "Cross-tool agent memory MCP server"
- "AGENTS.md / CLAUDE.md auto-sync"
- "Switch AI coding tools mid-task"
- "Codex CLI plugin for Claude Code (session sharing)"
- Seamless connection between Claude Code and Codex CLI. Both tools' transcripts (
~/.claude/projects/*.jsonland~/.codex/sessions/*.jsonl) are watched in real time, normalised to a canonical schema, and merged by working directory. - Switch tools mid-thought. Start in Claude Code, finish in Codex (or the reverse). The receiving tool already knows your plan, recently touched files, and the last 2,000 tokens of conversation.
- Three layers of context refresh so you never have to repeat yourself:
- Session start — Claude Code
SessionStarthook injects context. Codex reads project-localAGENTS.md. - Every user prompt (Claude) —
UserPromptSubmithook re-injects rolling context, gated by mtime so token cost is zero when nothing has changed. - On-demand mid-session — built-in MCP server (
claudex_get_context,claudex_get_plan,claudex_recent_files) registered into both Claude Code'smcpServersand Codex'smcp_servers. The model can pull fresh state any time a user references something it doesn't see.
- Session start — Claude Code
- Auto-discovers every project. On install, Claudex scans your entire
~/.claude/projectsand~/.codex/sessionshistory and builds a context for every folder you've ever opened in either tool. Zero per-project setup. Ever. - Packaged desktop app.
claudex appopens the bundled Claudex desktop window: all Claude Code + Codex sessions, local usage signals, token/cache observations, and one-click resume / cross-tool launch actions. - Project keying by working directory. Both tools' transcripts merge automatically as long as they were opened in the same folder. SHA-256 hash of the cwd is the join key.
- Rolling 2,000-token context window per project. Token-counted with
cl100k_base, configurable budget. Designed to fit comfortably inside any model's context with room to spare. - Active plan extraction. Detects "the plan is…" / numbered steps / markdown checklists from recent assistant turns and surfaces them at the top of the injected context.
- Recent files tracker. Pulls file paths out of recent tool calls so the receiving tool knows what you've been editing.
- Daemon autostart on every OS. Windows Startup
.vbs, macOS LaunchAgent, Linux systemd-user. Survives reboots. You install once and forget it exists. - Pure local. Pure private. No API keys, no cloud, no telemetry, no proxy. Your transcripts never leave your machine.
- Zero native dependencies. No
node-gyp, no Visual Studio Build Tools, no Xcode CLT.npm install -g claudexand you're done. - MIT licensed. Use it, fork it, ship it inside your own product.
Requires Node.js 20+, plus at least one of Claude Code or Codex CLI installed.
npm install -g claudex
claudex initThat single command:
- Patches
~/.claude/settings.jsonto add theSessionStart,UserPromptSubmit, andStophooks + registers Claudex as an MCP server. - Patches
~/.codex/config.tomlto add thenotifyhook + registers Claudex as an MCP server. - One-shot ingests every existing session from both tools (in real-world testing: 36,300 turns across 25 projects from 1,008 JSONL files in under 30 seconds).
- Registers the background daemon to autostart on user login.
- Spawns the daemon now.
Open any project in either tool. Claudex is already working.
claudex status # daemon + tracked projects
claudex projects # full project list
claudex app # packaged desktop app + one-click resume
claudex install-app # Start Menu + Desktop shortcuts on Windows
claudex context # what the next session in this folder will see
claudex log # tail the daemon log| Tool | What it does | How Claudex is different |
|---|---|---|
| claude-mem | Persistent memory plugin for Claude Code (also supports Codex, Gemini). Compresses past sessions with AI and re-injects them. | claude-mem is single-tool focused (per-agent memory). Claudex is purpose-built for the Claude Code ↔ Codex CLI handoff — both tools see the same canonical conversation graph, no compression model in the loop, lossless within the rolling window. |
| hydra | Unified wrapper around Claude Code, Codex, OpenCode, Pi with automatic fallback when one hits a rate limit. | Hydra is a launcher that switches for you. Claudex assumes you choose when to switch and just keeps both tools' state aligned. The two are complementary — you can run them together. |
| context-mode | Sandbox tool output to compress context window usage. | Different problem. Context-mode optimises within a session. Claudex bridges across sessions and across tools. |
claude --resume |
Built-in: lets you resume your own previous Claude Code session by id. | Same-tool only. Claudex carries state cross-tool, including across claude → codex → claude chains. |
/compact command in Claude Code |
Built-in: compresses current conversation. | Reactive and same-tool. Claudex is proactive and cross-tool. |
Manual AGENTS.md / CLAUDE.md files |
Hand-authored shared instructions. | Static. Claudex auto-writes a managed <!-- claudex:start --> block into AGENTS.md that updates as you work. |
- A small daemon (using
chokidarfor filesystem watching) tails~/.claude/projects/**/*.jsonland~/.codex/sessions/**/*.jsonl. - Every new turn from either tool is parsed, normalised into a canonical
Turnschema (role, text, thinking, tool calls, timestamps), and appended to~/.claudex/mirror/<project-hash>/timeline.jsonl. - For each project (keyed by SHA-256 of the cwd) Claudex maintains:
~/.claudex/shared/<hash>/context.md— rolling 2,000-token window of the last turns from both tools, chronologically interleaved.~/.claudex/shared/<hash>/plan.md— extracted active plan / open todos.~/.claudex/shared/<hash>/recent-files.txt— recently touched files.
- The receiving tool loads this context via three mechanisms:
- Claude Code —
SessionStarthook injects context via the documentedadditionalContextmechanism;UserPromptSubmithook re-injects on every prompt (mtime-gated so it's free when nothing changed). - Codex CLI — a managed
<!-- claudex:start --> ... <!-- claudex:end -->block is written into<project>/AGENTS.md. Codex auto-loadsAGENTS.mdon every session. - Both tools, mid-session — the built-in MCP server exposes
claudex_get_context,claudex_get_plan,claudex_recent_files. TheAGENTS.mdblock instructs the model to callclaudex_get_contextwhenever the user references state the local view doesn't have.
- Claude Code —
Claudex is 100% local. The daemon reads files your tools already write (~/.claude/projects and ~/.codex/sessions) and writes derived files under ~/.claudex/ plus a managed block in each project's AGENTS.md. No telemetry. No cloud. No external API calls. Your transcripts never leave your machine. Treat ~/.claudex/ as you would treat your shell history.
You should install Claudex if:
- You hit Claude Code's session or weekly rate limit mid-task and want to keep working without losing your place.
- You dual-wield Claude Code and Codex CLI on the same repository and want them aware of each other.
- You switch between projects often and want every folder to remember what the last AI session there was working on.
- You work across machines or sessions and want a persistent rolling context without paying for cloud memory tools.
- You're building or maintaining an AI coding agent workflow and need a normalised view of activity across multiple agents.
- You've used
claude-mem,hydra,aider, orcontinue.devand want specifically the Claude Code ↔ Codex bridge that none of them quite solve.
You probably don't need Claudex if:
- You only ever use one of these tools.
- Your sessions are short and contextless.
- You're fine pasting summaries by hand.
Install Claudex (npm install -g claudex && claudex init). It patches both tools' configs, registers the bridge daemon to autostart, and pre-ingests every existing session. Open any project in either tool — the bridge runs in the background and the context follows you.
You quit Claude Code, open Codex CLI in the same folder, and start typing. Codex auto-loads the project's AGENTS.md which Claudex has populated with the rolling 2K-token context window — so it already knows what you were doing. No re-explanation, no re-summarisation.
No. Claudex never makes API calls. It only reads local transcript files that both tools already write to disk, and writes derived markdown files locally. Your existing Claude Code and Codex CLI subscriptions handle all the actual model traffic.
No. If you have an existing AGENTS.md in a project, Claudex appends a managed <!-- claudex:start --> ... <!-- claudex:end --> block to it (or refreshes that block in place if it already exists). Everything outside the markers is untouched. If you delete the markers, Claudex respects that.
v0.1 is single-machine. Cross-machine encrypted sync via Syncthing/iCloud/Git is on the roadmap for v0.4. The daemon state under ~/.claudex/mirror/ is pure JSONL and trivially syncable today if you want to roll your own.
Not yet, but adding a parser for any agentic CLI is ~1 hour of work and a great first contribution. See CONTRIBUTING.md and the parser layout in src/parsers/.
Within the 2,000-token window, yes — exact user and assistant text from both tools, in chronological order. Outside the window, older turns live in ~/.claudex/mirror/<hash>/timeline.jsonl and can be queried via the MCP server. Full session forgery (lossless across the whole conversation, not just the rolling window) is the headline feature of v0.2 — see ROADMAP.md.
Yes — everything is local. No network calls. No telemetry. Redaction rules to auto-strip API keys / secrets before they enter context.md are on the roadmap (v0.4). For now, treat ~/.claudex/ as you would treat your shell history.
| Command | Description |
|---|---|
claudex init |
One-shot install: patches both tools' configs, bulk-ingests history, registers autostart, spawns the daemon. |
claudex sync |
Re-ingest every existing Claude Code + Codex CLI session (idempotent). |
claudex status |
Show daemon status and recently tracked projects. |
claudex projects |
Full list of projects the bridge knows about. |
claudex app [--dev-tools] |
Open the packaged desktop app for all Claude Code + Codex sessions, usage signals, and one-click resume / cross-tool handoff. |
claudex install-app |
Install Windows Start Menu and Desktop shortcuts that launch claudex app without exposing package .js internals. |
claudex ui [--web] [--port 37373] [--no-open] |
Alias for claudex app; use --web for the old localhost dashboard fallback. |
claudex context [--cwd <path>] |
Print the rolling context for a project. |
claudex rebuild [--budget 2000] |
Force-rebuild the context for the current working directory. |
claudex log [-n 60] |
Tail the daemon log. |
claudex daemon |
Run the daemon in the foreground (for debugging). |
claudex autostart {enable,disable} |
Manage daemon-on-login registration. |
| Variable | Default | Purpose |
|---|---|---|
CLAUDEX_HOME |
~/.claudex |
Where all daemon state lives. |
Per-project overrides via .claudex/config.yml are on the roadmap (v0.4).
The two highest-leverage areas to help:
- Parsers for more agentic CLIs — Aider, Cursor CLI, Cline, Continue.dev, Gemini CLI, Goose, OpenCode, Q CLI. Each is ~1 hour: drop a file in
src/parsers/, wire it intosrc/daemon.ts, add a redacted fixture. - The lossless v0.2 features — synthetic resume file forgery, full tool-call schema translation, Ollama-assisted plan extraction. See ROADMAP.md.
Read CONTRIBUTING.md for dev setup and the design principles (no native deps, no telemetry, never write outside managed markers).
See ROADMAP.md for the full list. Highlights coming next:
- Synthetic resume files — translate a Claude Code session into a forged Codex
rollout-*.jsonl(and vice versa), exec--resume <id>so the receiving tool loads it as native history. Fully lossless cross-tool handoff. - Tool-call schema translation between Anthropic and OpenAI formats.
- Local LLM plan extractor (Ollama).
- Parsers for Aider, Cursor CLI, Cline, Continue.dev, Gemini CLI, Goose, OpenCode, Q CLI.
- Live dashboard at
localhost:7711showing the merged timeline.
- Claude Code documentation
- OpenAI Codex CLI
- Model Context Protocol (MCP)
- AGENTS.md spec — Codex's project-local instruction file
- CLAUDE.md spec — Claude Code's project memory file
MIT — see LICENSE. Use it however you want.
If Claudex saves you from one rate-limit-induced rage moment, please ⭐ the repo so others can find it.