codex resume and claude --resume: getting a session back
Reopen a Codex or Claude Code session: the commands, why a session is missing from the list, what a resume restores, and keeping history past 30 days on a server.
In Codex, codex resume --last reopens the most recent session from the folder you are in, and codex resume opens a picker. In Claude Code the same two are claude --continue and claude --resume, or /resume from inside a running session. Both start a new process on the conversation saved on the machine where it ran, so a resume gets the history back, not a process that died; Claude Code’s docs say a command cut off mid-run is not rerun. When a session you expect is missing, it is usually one of three things: the list is filtered to the current folder, it was a scripted run, which both agents leave out by default, or, in Claude Code, it is older than the 30 days Claude Code keeps transcripts by default.
The commands, side by side
| To | Codex | Claude Code |
|---|---|---|
Reopen the latest session here | codex resume --last | claude --continue (-c) |
Choose from a list | codex resume, or /resume inside | claude --resume (-r), or /resume inside |
Open one by ID or name | codex resume <id or name> | claude --resume <id or name> |
See sessions from other folders | codex resume --all | Ctrl+A in the picker |
Include scripted runs | --include-non-interactive | By ID only, or claude -p --continue |
Continue a scripted run | codex exec resume --last "…" | claude -p --resume <id> "…" |
Try another way, keeping the original | codex fork, or /fork inside | claude --continue --fork-session, or /branch inside |
The commands are from OpenAI’s Codex command reference and Claude Code’s page on managing sessions, as of October 23, 2026. A name works as a handle once you have given one: in Codex the help text for codex resume takes a session ID or a session name, and in Claude Code you name a session with claude -n auth-refactor at the start or /rename during it. An unnamed Claude Code session can still be resumed by the title it generates from your first prompt.
Why the session you want isn’t in the list
- You are in a different folder. Both agents list sessions by the directory they ran in.
codex resume --lastlooks only at the current one “unless you pass--all,” andclaude --continuereopens the most recent session in the current directory or printsNo conversation found to continue. Claude Code’sclaude --resume <session-id>searches every project on the machine, so an ID works from anywhere. - It was a scripted run. Codex leaves
codex execsessions out of its picker and--lastuntil you add--include-non-interactive. Claude Code leaves sessions started withclaude -por the Agent SDK out of the picker and out ofclaude --continue, and hides sessions whose first prompt was/loop; pass the session’s ID toclaude --resume, or runclaude -p --continue, which includes them. - It aged out. Claude Code deletes transcripts older than
cleanupPeriodDays, 30 days by default, and with them the ability to resume, continue or rewind those sessions. How to keep them longer is below. - It was never saved.
codex exec --ephemeralwrites no session files; on the Claude side,--no-session-persistencewith-pand theCLAUDE_CODE_SKIP_PROMPT_HISTORYvariable do the same.
What a resume brings back, and what it doesn’t
A resume reloads the conversation, not the process. Codex “reloads the selected chat’s transcript so you can pick up where you left off, keeping the original history intact,” and codex resume accepts model and sandbox overrides on the command line. Claude Code’s list of what a resumed session restores is longer and has the edges worth knowing:
- The messages, tool calls and results come back; a session that was compacted reopens at its last summary and the messages after it.
- A tool that was still running when the process ended is not finished or rerun. Claude sees it marked as cut off and is told to check whether it took effect before running it again.
- Background shell commands and monitors are not restored; background subagents and workflows that ended with the process show up as a note that they didn’t finish.
- The model carries over, and from a terminal
--continueor--resume <id>restores the permission mode, except that a session that ended in bypass mode starts in the mode a new session would. - Launch flags such as
--mcp-config,--settingsand--add-dirare not restored; pass them again. What lives in the settings files is read fresh at launch.
Resuming one session in two terminals at once, without forking, makes the messages from both “interleave into one transcript,” by Claude Code’s docs. Fork or branch when you want two lines of work.
On a server: tmux for a dropped connection, resume for a reboot
The two tools answer different losses. When an SSH connection drops, a session started inside tmux keeps running on the server, mid-task, and you reattach to the same live process from any device; the tmux guide has the commands. tmux does not survive the machine restarting, and that is where resume comes in: after a reboot, a crash or an update, the process is gone, and codex resume --last or claude --continue, run in the same folder, starts a new process on the saved conversation.
The history lives on the machine where the session ran: Claude Code’s under ~/.claude/projects/, one file per session, and Codex’s under ~/.codex (or wherever CODEX_HOME points). So a session started on a server is resumed on that server, from whatever you SSH in with, and does not appear in the agent on your laptop. OpenCode documents a way to carry one session to another machine: opencode export writes it as JSON and opencode import reads it back. Claude Code’s --resume also accepts the absolute path of a transcript file, but its docs call the format internal and liable to change between versions.
In Claude Code, a session you sent to the background keeps running after you leave, and claude --resume on one that is still running opens the running session itself rather than reloading its transcript. Steering a session on a server from your phone is a different route, covered in the Remote Control guide.
Keeping sessions longer than 30 days
On a machine you keep working on for months, Claude Code’s default sweep deletes every transcript older than 30 days. Raise it in ~/.claude/settings.json:
{
"cleanupPeriodDays": 365
}The minimum is 1, and 0 is refused with a validation error rather than read as “keep forever.” Weigh it against what the transcripts hold: Claude Code’s docs say they are plaintext, protected only by file permissions, and that anything a tool read or printed, a .env file or a credential included, is written into them. A longer history on a server is a longer record of everything the agent saw there.
Codex’s docs give no age limit for its saved sessions.
OpenCode and Pi
OpenCode continues the last session with opencode -c and a given one with opencode -s <id>, adds --fork to either to branch instead, and takes the same flags on opencode run; opencode session list prints the IDs. Pi saves sessions by folder: pi --continue in the same folder reopens the most recent, /resume opens another, and /tree, /fork and /clone try another approach without losing the first. The rest of Pi’s command line is in the Pi guide.