OpenAI Codexcodex-cli 0.154 · macOS, Linux, WSL, Windows
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
26 small wins to finish your pathNext lesson

Sessions: resume, fork and queue

Work that takes longer than one sitting needs a way back in. Codex saves sessions, and the table below is everything you can do with a saved one.

CommandWhat it does
codex resumePick a previous session, or --last for the most recent
codex forkCopy a session into a new one, leaving the original alone
codex queueAdd a message to a session that is already running
codex archive, codex deletePut one away, or remove it for good

Resume continues the same conversation. Fork branches it, which is what you want before trying a second approach: the first one is still there if the second is worse.

The same from a script

codex exec has both as subcommands, so a pipeline can continue a thread rather than starting from nothing every time.

bash
codex exec resume --last "now add tests for what you just changed"

That is the cheap version of context: the second command does not have to re-explain the first, because it is the same thread.

Queueing while it works

codex queue puts a message in front of a session that is mid-run. It is the scripted version of typing while the agent is busy: the instruction waits, and is read when the current step finishes.

Sessions and directories
A session is tied to the directory it started in. Two pieces of work in the same folder share a place, which is the argument for worktrees in lesson 12.
Try it yourself
  • Run codex resume and look at how your own sessions are listed.
  • Fork a session before trying something you might regret, and compare the two.

Every expert started right here.