Resuming the last Codex session restores the most recent conversation state for a project, keeping prior decisions and task context available after closing a terminal or reconnecting to a workstation.
The codex resume command reattaches to a locally stored session and loads the session associated with the current working directory. Using the --last flag selects the most recent session for that directory without prompting, and sessions live under /~/.codex/sessions/.
Sessions are scoped by local state, so changing directories or switching machines can load a different session than expected or make older sessions unavailable. Resumed transcripts may include sensitive prompts, file paths, or logs, so confirming the restored context helps prevent continuing the wrong thread.
Related: How to start a Codex interactive session
Related: How to run Codex exec with a prompt
Steps to resume the last Codex session:
- Change to the working directory associated with the session.
$ cd ~/projects/example-app
- Confirm the current directory matches the intended project.
$ pwd /home/user/projects/example-app
Resuming from the wrong directory can attach to a different session and lead to edits or commands being applied to an unintended project.
- Resume the most recent session for the current directory.
$ codex resume --last Resuming session 1f2e3d4c-5678-90ab-cdef-1234567890ab
Running codex resume without --last typically shows a selector for older sessions when available.
Use --all to list sessions outside the current working directory.
- Review the restored transcript to confirm the expected context loaded.
Checking the last few messages helps confirm the correct task and repository are active before continuing.
- Review the working tree for unexpected changes before continuing.
$ git status -sb ## main...origin/main M README.md
- Enter a new prompt to continue the conversation.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
