Six commands from the shell
Rewinding, forking and sharing are things you do inside a session, with
/rewind, /fork and /share. There is no cortex rewind, cortex fork or cortex share command, and the --share flag on cortex run is declared but refused: it stops the run with --share is not supported by the Code service contract. No turn was submitted.List sessions
Resume
--no-session is declared on the same command but cannot be combined with it: resuming with it set fails with --no-session is incompatible with resume. Treat it as a flag for the command reference rather than a daily control.
The picker lists recent sessions with what each one was about; typing filters the list, and the footer strip at the bottom of the screen names the keys that apply to it, including starting a new session instead. Inside a running session, /resume opens the same picker and Ctrl+r searches past sessions.
Non-interactive runs can continue a session too: cortex run --continue picks up the most recent one and cortex run --session <SESSION_ID> continues a named one. A goal comes back with the session it belongs to.
Start fresh, or clear the conversation
/new starts a new session without leaving the TUI. /clear empties the conversation but keeps the session you are in; it asks first and tells you what is dropped and what is kept, because your files and your configuration are untouched either way.
/session prints the details of the session you are in, /rename gives it a name, and /timeline shows its timeline. /favorite and /unfavorite mark and unmark it, and f toggles the mark on the selected row in the sessions panel.
Rewind, undo, fork
PressEsc twice in quick succession to open the rewind overlay, which walks back through the session to an earlier point. The overlay has its own keys and lists them while it is open.
From the composer:
/rewindoptionally takes a number of steps./undoand/redostep the last action back and forward./forkstarts a new session from this one, optionally with a name, leaving the original as it was./ghostmanages ghost commits for undo.
Export
/export offers Markdown, JSON or plain text and writes a file named in the pattern cortex_<title>_<date>.<ext>.
Import
- it composes with anything that can write JSON to a pipe.
Share a link
/share creates a link to the session. It takes a duration, and the values it accepts are 30d, 24h, 60m and never. Sharing is an in-session action only: cortex run --share is refused before the run starts.
Protect a session from cleanup
cortex lock is also available as cortex protect. A locked session survives the cleanup commands below, which makes it the right thing to do to the session you will want to point at in three months. The reason you give with -r is there so the lock explains itself later.
Delete and clean up
-y/--yes skips the confirmation, and -f/--force is accepted as well. Housekeeping across everything the CLI has written is a separate command, cortex compact, also available as cortex gc and cortex cleanup:
logs, vacuum and config subcommands.
Where sessions live
Sessions are files under the Cortex home directory, one directory per session at~/.cortex/sessions/{session-id}/. A session with a goal keeps it alongside as its own file, which is why a goal survives resuming and compaction. ~/.cortex/code-sessions.json is the map from a workspace to the coding session it belongs to.
Two configuration keys govern the history file:
persistence to none is the way to run without a stored history at all. See Data locations for everything the CLI writes and Configuration for where to set these.
Related
- Goals - the objective that rides along with a session
- The TUI - the sessions panel, the resume picker and the rewind overlay
- Headless and one-shot runs - continuing a session from a script
- Data locations - what is on disk, and what
cortex compactreclaims - Code sessions - the same work in the web app