← Back to all posts

engineering

Codex Cross-Session: Moving an AI Coding Session Between Macs

A repo-backed session migration tool that keeps Codex handoffs explicit, non-secret, and fail-closed.

27 Apr 20263 min read
  • #codex
  • #cli
  • #tooling
  • #macos

The problem

AI coding sessions are valuable because they accumulate context: the repo state, the current branch, recent decisions, and the thread of work in progress. Losing that context when moving between machines turns a simple handoff into a reconstruction exercise.

My actual pain point was simple: I use two machines. Sometimes the real work is active on Machine A, but I am back home on Machine B and want to keep moving without rebuilding the whole Codex session from memory.

Codex Cross-Session is my small answer to that problem. It is a macOS-only CLI for moving one selected Codex session between Macs by exporting non-secret session state into a repo-owned .codex-session/ bundle, transporting it through git, and restoring it on the destination machine.

Codex Cross-Session workflow from Machine A to Machine B

The product boundary

The scope is intentionally narrow:

  1. One explicit session id per run.
  2. Single-user workflow.
  3. macOS only for the first version.
  4. Repo-backed transport through .codex-session/sessions/<session-id>/.
  5. Compatibility checks that refuse unsafe restores instead of trying to be clever.

That boundary matters. Session migration is not just file copying; it is a trust problem. If the destination repo, branch, commit, or expected Codex layout does not line up, the import path should stop and tell the operator what is wrong.

How the workflow works

The operator loop is deliberately boring:

codex-session export <session-id>
git add .codex-session
git commit -m "Export Codex session"
git push

Then on the second Mac:

git pull
codex-session import <session-id>
codex resume <session-id>

The exported bundle lives with the repo that gives the session meaning. That keeps transport auditable and avoids a hidden global sync layer.

The important part is not only that files move. The useful part is that the work resumes with the right repository context, compatibility checks, and enough session state for Codex to continue from the same thread of work.

Engineering choices

The implementation is split around clear ownership:

  • src/cli/ owns the user-facing command surface.
  • src/session/ discovers Codex home and session artifacts.
  • src/bundle/ owns manifest, inventory, and bundle schema logic.
  • src/export/ and src/import/ own the two operational flows.
  • src/git/ keeps git-aware workflow helpers separate from migration logic.

The important design choice is that restore compatibility is a first-class behavior, not a warning printed after mutation. A migration tool should fail closed before it touches local state.

Current state

The project now has public-facing documentation, usage notes, limitations, security notes, and MIT licensing. It exposes a codex-session binary in package metadata, but it is still in public-preparation mode rather than fully published package mode.

That distinction is useful. It keeps the README honest: the tool is real and documented, while npm-style distribution remains a separate release step.

What I like about this project

This is the kind of tool that earns its keep by removing one repeated tax from serious AI-assisted development. It does not try to become a cloud sync product. It makes the handoff explicit, versioned, reviewable, and tied to the repository where the work actually happens.

Related posts

Continue with articles that overlap in category or shared tags.