What are agent sessions? Claude Code, Codex, Cursor and Grok

By

A session is a saved coding-agent conversation you can resume later. How Claude Code, Codex, the Cursor CLI and Grok Build store, name, resume and fork one.

A session is one saved conversation with a coding agent, tied to a project. You can quit, come back later, and resume it with the history intact. You can also fork a copy when you want to try a second approach without losing the first.

How sessions work

The tool writes the conversation as you go. Prompts, replies, and tool calls are in that record. When you resume, the agent continues from what was saved, including a summary if the session was compacted to free the context window.

Resume continues the same session. Fork, or branch, copies the conversation up to that point and leaves the original on disk. Two terminals that resume the same session without forking write into one transcript.

Resume or fork a saved sessionThe tool saves the conversation as you work. Later you resume that session, or fork a copy so the original stays as it was.ResumeForkYou work in asessionThe tool saves theconversationYou come backThe same sessioncontinuesA copy continues andthe original stays

Checkpoints are the file snapshots inside a session. They are a different control from resume.

Sessions in each tool

Claude Code Codex Cursor Grok Build
Resume the latest claude --continue codex resume --last agent resume or --continue grok -c or grok --resume
Pick one claude --resume or /resume codex resume or /resume agent ls, or --resume with an id /resume, or grok sessions list
Name it claude -n, or /rename /rename Not documented /rename or /title
Fork /branch, or --fork-session /fork, or codex fork Not documented /fork, or --fork-session
Where it lives ~/.claude/projects/ as JSONL Not documented Not documented ~/.grok/sessions/

Claude Code

Claude Code stores a session per project directory and saves it continuously, so you can return after you exit or after /clear. claude --continue reopens the most recent session in the current directory. claude --resume opens a picker. Pass a name or a session id to resume that one directly. Inside a session, /resume switches to another one.

Name a session at launch with claude -n auth-refactor, or later with /rename auth-refactor. You can also rename from the picker with Ctrl+R. A session you never name still gets a generated title from the first prompt, and that title works as a resume handle. The default display name, the folder name plus a short suffix, does not.

/branch try-streaming-approach copies the conversation so far into a new session and switches you into it. From the shell, claude --continue --fork-session does the fork in a new process. The original stays in the picker.

Transcripts are JSONL files under ~/.claude/projects/, in a directory derived from the working directory path. CLAUDE_CONFIG_DIR moves that storage. The line format is internal and changes between releases, so the docs say to use /export or the script interfaces instead of parsing the files.

claude -p and Agent SDK sessions stay out of the picker and out of claude --continue. You resume one by passing its id to claude --resume. See Claude Code sessions.

OpenAI Codex

codex resume continues an interactive session. With no id it can resume the most recent chat. --last scopes that to the current working directory unless you pass --all. If the current directory differs from the session’s saved directory, Codex asks which one to use. tui.resume_cwd set to "current" or "session" skips that prompt. An explicit --cd wins over that setting.

Inside the TUI, /resume opens the saved chats. /new starts a fresh chat in the same CLI process. /rename names the current chat. /fork branches the current chat into a new one. codex fork opens a picker for a previous session, and codex fork --last forks the most recent one. codex fork --worktree needs an explicit session id and local execution.

/clear resets the visible UI and the chat context together. /archive drops the session from active lists and keeps the transcript. /delete removes the transcript.

For a non-interactive follow-up, codex exec has a resume subcommand. --last picks the most recent session in the current directory, and --all searches further. See the Codex CLI commands.

Cursor

The Cursor CLI resumes a thread with --resume and a thread id. agent resume, --continue, and /resume continue the most recent conversation. agent ls opens previous chats so you can resume one.

The CLI docs don’t say where those threads are stored, and they don’t describe a fork command. The editor’s agent overview documents conversation search in the Agents Window, with Cmd+K on macOS or Ctrl+K on Windows and Linux, which is search rather than resume.

See Using Agent in the CLI.

Grok Build

Grok saves every conversation under ~/.grok/sessions/, keyed by working directory. The record includes prompts, responses, tool calls, and file snapshots. The same sessions work in the TUI, in headless mode, and over ACP.

/resume opens a picker for the current workspace. grok --resume with no id continues the most recent session for this directory, and grok -c is the short form. grok --resume plus a session id opens that session. grok sessions list lists recent sessions for the directory, and grok sessions search searches titles and prompts.

-s or --session-id names a new session with a UUID you supply. The sessions page says it does not resume an existing one. --fork-session on a resume branches a copy instead of continuing the original. Inside the TUI, /fork does the same, and you can pass --worktree or --no-worktree.

/rename names the current session. /sessions switches, renames, or closes active ones. See Grok Build sessions.

Details checked against each vendor’s documentation in October 2026.

A real example

You are halfway through adding a “Last updated” line to a blog’s post layout, and you have to stop. In Claude Code, name the session before you quit:

claude -n last-updated-date

Later, from that repo:

claude --resume last-updated-date

Codex, from the same repo, is codex resume --last. The Cursor CLI is agent resume. Grok Build is grok -c.

If you want to try a different layout without losing this attempt, fork instead of resume. Claude Code uses /branch. Codex uses /fork. Grok Build uses /fork.

When to resume

Resume when the next step depends on what the agent already read and decided. A follow-up like “also skip drafts” belongs in the session that just edited the layout.

Start a new session when the task is unrelated. The old transcript still costs context, and Claude Code can warn that resuming a long conversation uses a share of your usage limit before you send the next message. Compact or clear when you need the decisions but not the full tool output. Put anything you can’t afford to lose in a file, because a summary replaces the earlier messages in the context.

Fork when you want two approaches in flight. Resume when you want one.

Pitfalls

Claude Code restores a lot of session state, and not every launch flag. If the original run depended on --mcp-config, --settings, --plugin-dir, or --add-dir, pass those again. Directories you added mid-session with /add-dir are not restored either. Settings files such as settings.json are read again at launch.

A resumed Claude Code session continues on the model it was using, with exceptions the model docs spell out. The permission mode it comes back in depends on how you resume. Pass --permission-mode when you need a specific one.

Two Claude Code terminals that resume one session without forking interleave messages into a single transcript. Fork when the second terminal is an experiment.

Codex will ask which directory to use when your shell isn’t in the session’s saved directory. Set tui.resume_cwd if you always want the same answer.

Grok’s --session-id does not mean resume. Use --resume for a saved session. /rewind is also not resume. It restores files and truncates the conversation, which the checkpoints entry covers.

  • How to use the Codex CLI shows codex resume, --last, and codex fork for coming back to a session.
  • How to use Grok Build covers grok -c, /resume, and the difference between --session-id and --resume.
  • What is headless mode? is the script form. claude -p --resume and codex exec resume continue a saved session without the chat UI.
  • Work Tracebook is my Mac app that turns the one-line reports agents leave into a timeline of the day, so the work is still readable after the sessions are closed.
  • Checkpoints: Checkpoints let you undo a coding agent's edits inside a session. How rewind works in Claude Code, Cursor and Grok Build, and what Codex documents instead.
  • Context window: The context window is everything a coding agent can see at once. How to check it, free it and keep it small in Claude Code, Codex, Cursor and Grok Build.
  • Headless mode: Headless mode runs a coding agent from a script, with no chat UI. How claude -p, codex exec, the Cursor CLI and grok -p differ on permissions.

All AI glossary entries →

Want me to talk about your product? You can sponsor this site.