Passing Context from Claude Code to Codex in Long-Term Projects
About This Article
Practical Ways to Save Claude Tokens organized techniques for reducing token consumption. This article focuses on a narrower problem: how I transfer working context from Claude Code to Codex on long-term projects.
The Problem: When Context Breaks, You Start Over
A token is the unit of information an AI can process. The longer a conversation grows, the more tokens are consumed, and eventually older parts of the conversation become inaccessible.
This “context breaking” problem is most noticeable on long-term projects that move from Claude Code to Codex. Codex does not automatically know what was confirmed in the Claude Code session, including decisions, agreed plans, or problems already resolved. Without a handoff, the Codex session has to start with “this project has this structure, and Claude Code completed this much.”
The repetition itself consumes tokens, so the problem compounds.
Approach 1: Write Necessary Information to a Structured File
Information that needs to survive across sessions goes into a file. This is the mechanism described in Designing the agent-handoff Document.
At the end of each work segment, I write the following to a file:
- What I am currently working on
- Changes that are complete
- What needs to happen in the next session
- Decision rationale and things to watch out for
When handing the task to Codex, I provide this file and say, “Treat this as the handoff from Claude Code, read it, and then resume the work.” This shares the current state and remaining tasks without reconstructing the entire conversation.
The key is writing only what is necessary. Long explanations consume tokens when loaded, so I keep things in bullet points covering only the essentials.
Approach 2: Consolidate Shared Rules Under shared/
Rules that both Claude Code and Codex must follow live under shared/.
Claude Code enters through CLAUDE.md, while Codex enters through AGENTS.md; both files point to the same shared/rules/ sources. The entry points differ, but the handoff policy does not need to be maintained twice.
Each entry-point file contains only the required rules and read order. Detailed guidance stays under shared/, so Claude Code and Codex can load the same policy at the scope needed for the task.
In this project, detailed rules live under shared/rules/, and both CLAUDE.md and AGENTS.md reference those paths.
Approach 3: Start a New Session When the Conversation Gets Long
Running the same task through a single long session lets conversation history accumulate, which increases context size. Claude Code has a /compact command that compresses conversation history, but a compressed summary is not the same as the original context, and fine-grained details can be lost in the process.
When the Claude Code work reaches a natural break, I update the agent-handoff document and start the Codex session from that document.
This approach has a cost: switching sessions takes a little time. But when I compare it against the token consumption of continuing a long conversation, switching at appropriate intervals tends to be more economical in my experience.
Summary
- When AI conversations grow long, context breaks and repetitive re-explanation follows
- What I do to address this:
- Write handoff information to an agent-handoff file at each work break
- Consolidate rules shared by Claude Code and Codex under
shared/ - End the Claude Code work at a clear boundary and start Codex from the handoff document
- All three approaches share the same goal: reducing the effort of re-explaining the work to Codex from scratch