Codex CLI · September 2026

Save, resume, and export a Codex CLI session

Codex already saves every chat — the questions are where, how to get back in, how to get a transcript out, and what a saved file cannot do: keep the run alive after the terminal closes.

Codex already saves every chat.

There is no save command because there is nothing to save by hand. From the first prompt, Codex streams the session to a rollout file — a JSONL transcript of every turn, tool call, and result — under ~/.codex/sessions/, in a YYYY/MM/DD/ folder for the day the chat started, named rollout-<timestamp>-<thread-id>.jsonl. Older files may be compressed to .jsonl.zst; the CLI reads both. ~/.codex is CODEX_HOME, so setting that variable moves everything. Archived chats go to ~/.codex/archived_sessions/.

Two settings change this. [history] persistence = "none" in config.toml stops transcripts being written at all, and codex exec --ephemeral skips the rollout file for a single scripted run. Everything else is saved, including the chats you abandoned after one message — which is why the picker fills up, and why the directory is worth knowing about when disk space goes missing.

ls ~/.codex/sessions/$(date +%Y/%m/%d)/
Today’s sessions on this machine.

Get back into a chat.

  1. 01Resume from the same directory

    codex resume opens a picker over the chats started from the current working directory; pick one and the conversation continues with its full context.

    codex resume
  2. 02Skip the picker

    --last reopens the most recent chat from this directory. It is the one to bind to a shell alias.

    codex resume --last
  3. 03Find one from somewhere else

    --all widens the picker to sessions started in every directory on the machine; a session id — the UUID in the rollout filename, or the name you gave it with /rename — resumes that thread exactly.

    codex resume --all codex resume <SESSION_ID>
  4. 04Branch instead of continue

    codex fork (or /fork inside a session) starts a new thread that inherits the transcript and leaves the original untouched — for trying two approaches from the same point.

    codex fork
  5. 05Resume a scripted run

    Non-interactive sessions are saved too. codex exec resume --last continues the most recent one with a new prompt, so a pipeline can carry context between steps; see the non-interactive docs.

    codex exec resume --last "now run the tests"
  6. 06Inside a session

    /resume switches to a saved chat without leaving the TUI, /new starts a fresh one, and /status shows the working directory and token use of the one you are in.

Read or export a transcript.

  1. 01Find the file

    /rollout prints the path of the current session’s rollout file.

  2. 02Export as markdown

    /export writes the conversation as markdown — the form to paste into a pull request or hand to a colleague. /copy grabs the last response or code block on its own.

  3. 03Query the JSONL

    The rollout is one JSON object per line, so ordinary tools work on it; the Codex source suggests jq or fx.

    jq -C . ~/.codex/sessions/$(date +%Y/%m/%d)/rollout-*.jsonl | less -R
    Pretty-print today’s rollouts.
  4. 04Tidy up

    /archive moves the current thread to archived_sessions and exits; /delete removes it permanently. /compact is different: it summarises the conversation so the model stops carrying all of it — a context decision, not a storage one.

What a saved session is, and is not.

The file is faithful about the conversation and silent about everything around it.

The conversation — kept

Every turn, every tool call and its output, in order. Resume reads it back into a fresh codex and the model picks up with full context.

Your edits — already on disk

Codex changed real files in a real working tree. Nothing in the rollout needs replaying; git diff is the record of what it did to your code.

The running command — gone

A resumed session is a new process reading an old transcript. A test suite or build that was mid-flight when the terminal closed did not finish and will not be resumed; you ask again.

The machine — fixed

Sessions are files on the disk of the machine that ran them. Nothing syncs ~/.codex/sessions between your laptop and your desktop; the picker on one knows nothing about the other.

Your usage window — account-wide

Limits on a ChatGPT plan are a five-hour window shared across local messages and cloud chats. Resuming an old session spends from the same allowance as starting a new one.

The honest limit: files survive, processes do not.

This is where “save chat” stops meaning what people hope. Codex keeps the transcript; it does not keep the session alive. Close the laptop lid during a long refactor and the process is suspended or killed with the terminal; drop an SSH connection and the remote codex dies with the shell unless you remembered to start it inside tmux; reboot and it is a picker entry. codex resume --last gets you the context back — not the run. From a phone, OpenAI’s route is the cloud, where the run lives in their container against a GitHub repo, not on the box with your checkouts and your services.

spawnd is the version where the session itself lives on the host. Each session’s PTY is owned by a worker process on the machine, so the Codex run — not just its transcript — survives the closed tab, the dropped connection, the laptop lid, and a restart of the daemon itself, scrollback intact. The daemon dials out, so nothing on the host listens and no port opens. Any browser you approve is the console; on a phone it installs to the home screen as a web app, and the session you started at the desk is the same session there, with an attention cue when Codex stops to ask for a yes and a notification to say so. Codex is a built-in shortcut typing codex into a real login shell, so ~/.codex — your sign-in, your config, your rollouts — is exactly where it always was; spawnd holds no provider credentials. Your browser talks to each daemon peer-to-peer, end-to-end encrypted; the server that introduces them never sees session content. The Codex CLI guide covers the whole tool; background agents is the general case.

Start

Sessions that outlive the terminal.

$curl -fsSL https://spawnd.dev/install.sh | sh
Sign up free
Install the daemon

Questions

Does Codex CLI save chat history automatically?
Yes. Every interactive and codex exec session is written as a JSONL rollout under ~/.codex/sessions/ from the first turn, unless you set [history] persistence = "none" or run codex exec --ephemeral.
How do I resume the last Codex session?
codex resume --last from the same directory. codex resume alone opens a picker; add --all to see sessions started elsewhere, or pass a session id to reopen one exactly.
Can I resume a Codex CLI session on another computer?
Not by design — sessions are files on the machine that ran them and nothing syncs them. Resuming gets you the transcript, never the running process. If the goal is one session you can reach from any device while it keeps running, that is what spawnd’s host-owned sessions are for.
How do I delete Codex chat history?
/delete inside a session removes that thread; /archive moves it to ~/.codex/archived_sessions/ instead. To wipe everything, delete ~/.codex/sessions/ — config and sign-in live beside it in ~/.codex, so do not remove the whole directory unless you mean to.