Shabash
Blog · Claude Code guides

How do I resume a Codex CLI session or see its history?

Short answer

To resume a Codex session, run codex resume --last, or codex resume --all to pick from every folder. Sessions stay in ~/.codex/sessions/ until you delete them. codex delete leaves what you typed, pasted keys included, in ~/.codex/history.jsonl.

By Robin Mehta · September 27, 2026 · updated October 28, 2026

Run codex resume --last and you're back in your last Codex chat. Codex keeps every session until you delete it yourself, which is why that works months later.

When you do delete one, codex delete removes the session's files but leaves every message you typed in ~/.codex/history.jsonl, including any key you pasted.

codex resume, --last and --all

codex resume            # pick from sessions started in this folder
codex resume --last     # reopen the latest one from this folder
codex resume --all      # pick from sessions in every folder
codex resume <id>       # one session, by its ID or its name

There's no codex continue command: codex resume --last is the one that continues where you left off. To give it a new instruction straight away, put it after the ID or name: codex resume <id> "now add tests".

While the list is open, type to filter it. It matches each session's first message, name, ID, git branch and folder.

Runs you started with codex exec are left out unless you add --include-non-interactive.

Archived sessions only show when you switch the list's Status to Archived. Press Tab until Status is highlighted, then the left or right arrow. Enter on an archived session restores it.

Give a session you'll want again a name with /rename. Next time, codex resume <name> opens it, with no ID to copy.

If you resume from a different folder than the one the session was last working in, Codex asks which folder to use. To skip the question, add this to ~/.codex/config.toml:

[tui]
resume_cwd = "session"   # or "current" to stay in the folder you're in

Inside Codex, /resume opens the same list. codex fork (or /fork inside a session) starts a new session from an old one and leaves the original as it was. To carry on a codex exec run with a new prompt, use codex exec resume --last "now add tests".

Everything here is checked against Codex 0.157.1, released 26 September 2026, and 0.165.0, released 27 October 2026, which still takes the same options.

Provider filter: why codex resume shows no sessions

If the picker comes up empty in a folder where you know you worked, the sessions are almost certainly still on disk.

The picker asks for the sessions recorded under the model provider you're using now, and leaves out the rest (resume_picker.rs). Change model_provider in ~/.codex/config.toml, or take it out, and the sessions recorded under the old provider drop off the list. People hit this: openai/codex #20165, open since 29 April 2026, reports the same empty list after a change of provider.

--all won't bring them back. It turns off the folder filter and nothing else, which its help text says in its own words: "Show all sessions (disables cwd filtering and shows CWD column)". The ID still opens any of them:

codex resume 01a0e472-4f9d-7f43-8b14-0d0f667339d0

To find that ID when the list won't show it, search the session files for words you typed.

Three more reasons a session you had is missing from the list:

Session files in ~/.codex/sessions

Inside ~/.codex, each session file is saved in a folder for the day it was written. A session file's path looks like this:

sessions/2026/09/27/rollout-2026-09-27T21-58-11-01a0e472-4f9d-7f43-8b14-0d0f667339d0.jsonl

The long part after the date and time is the session ID, the one codex resume takes.

Archived sessions move to ~/.codex/archived_sessions/. If you set the CODEX_HOME environment variable, all of this lives there instead of ~/.codex.

Codex also keeps ~/.codex/thread_history_1.sqlite in that folder, and reads it to page through a long chat. An open issue describes it as "a projection replayed from the rollout JSONLs", holding each thread's position in them as a byte offset, and reports that deleting a session's rollout file leaves its row behind. codex migrate-rollouts fills the database in from sessions written before it existed: "Inspect or migrate legacy local sessions to paginated thread history."

~/.codex/history.jsonl is a separate file: one line for every message you typed in the interactive codex, with that session's ID and the time. It's what the up arrow and Ctrl+R search in Codex's message box. Codex's replies and the commands it ran aren't in it; those are in the session files.

Searching old chats with grep

The resume filter won't find it: it only matches the fields above. If what you remember was said halfway through a chat, search the files instead. They're plain text, archived sessions included:

grep -rli "rate limit" ~/.codex/sessions ~/.codex/archived_sessions | sed -E 's/.*rollout-[0-9T-]{19}-([0-9a-f-]{36}).*/\1/' | sort -u

That prints the ID of every session that mentions "rate limit". Paste one into codex resume <id> and you're back in it. Claude Code's transcripts take a different search: how to search your Claude Code history.

codex delete keeps your prompts in history.jsonl

codex archive <id> (or /archive) moves a session to archived_sessions/ and out of the default resume list. codex unarchive <id> brings it back.

codex delete <id> removes the session's files for good. It asks you to confirm first; --force skips that, but only with the full ID, not a name.

It doesn't touch history.jsonl, though. Codex only ever adds lines to that file or trims the oldest ones. So if you pasted an API key into a session, the key is still on your disk after you delete that session.

To clear one session's lines from history.jsonl:

  1. Quit Codex, so nothing writes to the file while you edit it.
  2. Find the session's ID. Search for words you typed in it, and the ID is at the start of each matching line:

    grep "words you typed" ~/.codex/history.jsonl
  3. Set the ID, then run all three lines. umask 077 and writing back into the same file keep both copies readable only by you, the way Codex set the file up:

    id=01a0e472-4f9d-7f43-8b14-0d0f667339d0
    (umask 077; grep -v "\"session_id\":\"$id\"" ~/.codex/history.jsonl > ~/.codex/history.tmp)
    cat ~/.codex/history.tmp > ~/.codex/history.jsonl && rm ~/.codex/history.tmp

    Without umask 077, that temporary copy of every message you typed is readable by anyone with an account on the machine until the last line deletes it.

  4. Check the lines went. Run this before and after step 3; the count should drop by the number of messages you typed in that session:

    wc -l ~/.codex/history.jsonl

    If it doesn't move, the ID in your grep -v doesn't match the file, so nothing was removed.

  5. Delete Codex's log file too, while Codex is closed. ~/.codex/logs_2.sqlite can hold what you typed until Codex drops rows older than 10 days. Codex makes a new, empty one next time:

    rm -f ~/.codex/logs_2.sqlite ~/.codex/logs_2.sqlite-wal ~/.codex/logs_2.sqlite-shm
  6. Change the key anyway. It went to OpenAI with your message, and these steps only clean your own disk.

Stop Codex saving history

To stop Codex writing history.jsonl, add this to ~/.codex/config.toml:

[history]
persistence = "none"

Session files are still saved; this setting only covers the typed-message file. For a single task that leaves no session file at all, run it as codex exec --ephemeral "your task". The interactive codex has no switch like that.

To keep the file but cap its size, set max_bytes under [history] instead. Codex drops the oldest lines once the file is bigger than that.

Claude Code and Gemini CLI delete unused sessions

Claude Code deletes terminal sessions you haven't used in 30 days by default. Sessions you started or last continued in Claude Desktop or Cowork are kept. Gemini CLI deletes sessions you haven't touched in 30 days too. The guides for those: keeping Claude Code sessions, where Claude Code stores them and resuming Gemini CLI sessions.

Cursor keeps its chats on your computer too: where Cursor chat history is stored.

Shabash, the Mac app I'm building, reads your Claude Code, Cursor and Codex sessions and sorts them into threads, one for each piece of work. To try it, book a 30-minute call.

Questions

How do I resume a Codex CLI session?

Run codex resume and pick from the list, or codex resume --last for the latest session in the folder you're in. Add --all to see sessions from every folder, or pass a session ID or name: codex resume <id>.

Is there a codex continue command?

No. To continue a Codex session, run codex resume --last for the latest one in the folder you're in, or codex resume <id> for a particular one. codex resume --help lists every option.

Where does Codex CLI store session history?

In ~/.codex/sessions/YYYY/MM/DD/, under the day the file was written. A session is usually one file named rollout-<date and time>-<session ID>.jsonl. Every message you type in the interactive codex also goes in one shared file, ~/.codex/history.jsonl.

Does Codex CLI delete old sessions?

Not by itself. A session stays until you run codex delete <id>, which is permanent. codex archive <id> moves it to ~/.codex/archived_sessions/, and it only shows in the resume list when you switch the list's Status to Archived.

Does codex delete remove my prompts?

No. It deletes the session's files, but the messages you typed in that session stay in ~/.codex/history.jsonl until you remove those lines yourself. Codex's log file, ~/.codex/logs_2.sqlite, can also hold what you typed until Codex drops rows older than 10 days.

How do I stop Codex CLI saving my history?

Set persistence = "none" under [history] in ~/.codex/config.toml. That stops history.jsonl, but session files are still saved. For a one-off task that leaves no session file, run codex exec --ephemeral "...".

Why does codex resume show no sessions?

The picker lists only sessions recorded under the model provider you're on now, so changing model_provider in ~/.codex/config.toml empties it. codex resume --all drops the folder filter, not that one. The files are still in ~/.codex/sessions/, and codex resume <id> opens them.