How Claude Code and Codex store sessions, and how to hand a task from one to the other
说明与用途
通过基于游标的同步和本地 JSONL 文件实现 Claude Code 与 Codex 之间的任务交接,已在 ccx macOS 应用中实现。
问题
Switching between Claude Code and Codex leaves each side unaware of the other's progress, making task handoff difficult.
结果
The handoff between Claude Code and Codex is automated, reducing token usage to a few thousand per update and eliminating the need for manual exports.
工作流
- 1. Read Claude Code session JSONL from ~/.claude/projects/
<project>/<session-id>.jsonl - 2. Condense tool results: keep messages verbatim, summarize tool calls, add current todo list and git status
- 3. Store condensed progress in a cursor file
- 4. On switch, send only the delta after the cursor to Codex via its app‑server thread
- 5. Codex receives the delta, updates its thread, and writes back progress
- 6. Claude receives Codex’s new progress via UserPromptSubmit hook and prepends it to the next user message
- 7. Repeat steps 4‑6 whenever switching
证据
Every Claude Code session is a JSONL file under ~/.claude/projects/<escaped-project-path>/<session-id>.jsonl.
I packaged all of this as ccx, an open-source macOS menu bar app. Click ⇄ to hand off.
One Claude session is paired with one Codex thread. Each side keeps a cursor: the last event already synced.
- 记录日期: 2026-10-23T10:26:25.050Z