codex-handoff

A command for transferring an active coding session between Claude and Codex, including returning to an earlier handoff.

In plain words
What is it for?
Handing a session to Codex, bringing Codex's work back to Claude, and selecting a specific saved handoff.
Why use it?
It provides a way to continue work with another coding agent when the current model has limited tokens or is not the best fit.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/cbmono/ai-setup/codex-handoff
Clone the repo
git clone --depth 1 https://github.com/cbmono/ai-setup

Made for: Claude Code.

Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,661 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.02661
Opus 5 $0.00000 $0.01331
Sonnet 5 $0.00000 $0.00532
Haiku 4.5 $0.00000 $0.00266

Measured 2d ago against content hash 4fe9abd87014, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade B, and why

codex-handoff scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

[ -n "$BASE" ] && [ "$BASE" != none ] || BASE="$(cat "$ROOT/.claude/codex-baseline-head" 2>/dev/null || true)"
.claude/commands/codex-handoff.md · 153 lines

How it starts

The opening of the file, as written. The whole thing — 153 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Hand this session off to Codex — or pull Codex's work back into Claude. One command, both directions.

Use this when Claude tokens are running low (or you want a different model on the problem). It wraps the codex plugin's transfer, fixing the two things that make the raw command awkward: the transcript it can't auto-detect, and the fact that there is no built-in way back.

Requires the opt-in codex plugin (openai/codex-plugin-cc). If it isn't installed, say so and stop: /plugin marketplace add openai/codex-plugin-cc, /plugin install codex@openai-codex, /reload-plugins, then /codex:setup.

Argument: $ARGUMENTS — empty means go to Codex; back means return to Claude, and back <session-id> returns from a specific handoff when the checkout has more than one on record.

Preflight (both directions)

  1. Resolve the companion script, preferring the version this setup pins. Never hardcode a single version — the path contains one and it changes on plugin update — but don't blindly take the newest either, or a freshly-cached release silently supersedes the pinned one:
    CODEX_PIN="v1.0.6"   # keep in step with `ref` in settings.codex.example.json
    CODEX_ROOT="$HOME/.claude/plugins/cache/openai-codex/codex"
    CODEX_COMPANION="$CODEX_ROOT/${CODEX_PIN#v}/scripts/codex-companion.mjs"
    if [ ! -f "$CODEX_COMPANION" ]; then
      CODEX_COMPANION="$(ls -1d "$CODEX_ROOT"/*/scripts/codex-companion.mjs 2>/dev/null | sort -V | tail -1)"
    fi
    
    If the pinned version is absent and a different one is used, say which — the user is running code they didn't pin. If nothing resolves, the plugin isn't installed (see above) — stop.
  2. Confirm Codex is ready: node "$CODEX_COMPANION" setup --json. If ready is not true, report which check failed (node / npm / codex / auth) and stop — auth false means !codex login.
  3. Resolve one state file path, used by both directions. A relative path breaks when the return leg runs from a different directory, so anchor it to the repo root and create the parent:
    ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
    SESSION_LOG="$ROOT/.claude/codex-sessions.log"
    mkdir -p "$(dirname "$SESSION_LOG")"
    
    The log holds one append-only record per handoff, keyed by session id<utc-timestamp>\t<session-id>\t<baseline-head>. Handoff state must never live in a single-slot file: two handoffs from one checkout (a second problem the same afternoon, two agents, two worktrees of the same repo) would overwrite each other's baseline, and back would silently resume whichever was last without saying so. Everything the return leg needs is in the record it selects.

Read the full file on GitHub · 153 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 153 lines · 0 tokens per session scan B 4fe9abd87014

Subscribe to this mod's changes

codex-handoff is a command published in the GitHub repository cbmono/ai-setup (2 stars, last pushed 8d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,661 tokens. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.