skills/pi-agent/references/sessions.md
Source: https://pi.dev/docs/latest/sessions
Pi auto-saves conversations to ~/.pi/agent/sessions/, organized by working directory. Each session is a JSONL tree.
pi -c
pi -r
pi --no-session
pi --name "my task"
pi --session <path|id>
pi --fork <path|id>
Interactive commands: /resume, /new, /name, /session, /tree, /fork, /clone, /compact [prompt], /export [file], /share.
/resume and pi -r open a picker. Search by typing; use Ctrl+P to toggle path display, Ctrl+S sort, Ctrl+N named-only filter, Ctrl+R rename, Ctrl+D delete. Pi uses trash when available.
Sessions are trees with id and parentId. /tree lets you jump to a previous point and continue without creating a new file. Selecting a user/custom message moves to its parent and puts that message in the editor so it can be edited and resubmitted. Selecting assistant/tool/compaction entries moves the leaf there with an empty editor.
/tree: same session file, full tree, optional branch summary./fork: new session file from an earlier user message./clone: new session file duplicating current active branch.When switching branches through /tree, Pi can summarize the abandoned branch and attach that context at the new position. See compaction.md for internals.