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.
Get back into a chat.
01Resume from the same directory
codex resumeopens a picker over the chats started from the current working directory; pick one and the conversation continues with its full context.codex resume02Skip the picker
--lastreopens the most recent chat from this directory. It is the one to bind to a shell alias.codex resume --last03Find one from somewhere else
--allwidens 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>04Branch instead of continue
codex fork(or/forkinside a session) starts a new thread that inherits the transcript and leaves the original untouched — for trying two approaches from the same point.codex fork05Resume a scripted run
Non-interactive sessions are saved too.
codex exec resume --lastcontinues 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"06Inside a session
/resumeswitches to a saved chat without leaving the TUI,/newstarts a fresh one, and/statusshows the working directory and token use of the one you are in.
Read or export a transcript.
01Find the file
/rolloutprints the path of the current session’s rollout file.02Export as markdown
/exportwrites the conversation as markdown — the form to paste into a pull request or hand to a colleague./copygrabs the last response or code block on its own.03Query the JSONL
The rollout is one JSON object per line, so ordinary tools work on it; the Codex source suggests
jqorfx.jq -C . ~/.codex/sessions/$(date +%Y/%m/%d)/rollout-*.jsonl | less -RPretty-print today’s rollouts. 04Tidy up
/archivemoves the current thread toarchived_sessionsand exits;/deleteremoves it permanently./compactis 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 | shQuestions
- Does Codex CLI save chat history automatically?
- Yes. Every interactive and
codex execsession is written as a JSONL rollout under~/.codex/sessions/from the first turn, unless you set[history] persistence = "none"or runcodex exec --ephemeral. - How do I resume the last Codex session?
codex resume --lastfrom the same directory.codex resumealone opens a picker; add--allto 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?
/deleteinside a session removes that thread;/archivemoves 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.