ai-setup: Command for Claude Code

.claude/commands/codex-handoff.md

codex-handoff is a command for Claude Code from cbmono/ai-setup. It costs 0 tokens per session (2,661 once invoked), scanned B, original, MIT.

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

Written for Claude Code: $ARGUMENTS substitution. Also seen: positional $N argument; mentions Claude Code; runs codex exec.

This is cbmono/ai-setup's own configuration. It tells Claude Code how to work on ai-setup itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything ai-setup configures →

Reuse

Borrowing it

Nothing to install: this file belongs to cbmono/ai-setup. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/cbmono/ai-setup/main/.claude/commands/codex-handoff.md
Clone the repo
git clone --depth 1 https://github.com/cbmono/ai-setup

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for codex-handoff

README.md
[![agentmods](https://agentmods.dev/badge/commands/cbmono/ai-setup/codex-handoff/github.svg)](https://agentmods.dev/commands/cbmono/ai-setup/codex-handoff)
Your own site
<a href="https://agentmods.dev/commands/cbmono/ai-setup/codex-handoff"><img src="https://agentmods.dev/badge/commands/cbmono/ai-setup/codex-handoff/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for codex-handoff

Your own site · 80×15
<a href="https://agentmods.dev/commands/cbmono/ai-setup/codex-handoff"><img src="https://agentmods.dev/badge/commands/cbmono/ai-setup/codex-handoff.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
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. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00000 $0.02661
Opus 5.5 $0.00000 $0.01064
Sonnet 5.5 $0.00000 $0.00532
Haiku 4.5 $0.00000 $0.00266

Measured 2mo ago against content hash 4fe9abd87014, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 2mo 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. 2mo 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 10d 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.