Back to Claude Scientific Skills

Sessions

skills/pi-agent/references/sessions.md

2.57.02.9 KB
Original Source

Sessions

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.

Session Commands

bash
pi -c                  # continue most recent
pi -r                  # browse and select
pi --no-session        # ephemeral, do not save
pi --name "my task"    # display name at startup
pi --session <path|id> # specific file or partial session ID
pi --fork <path|id>    # fork into a new session file

Interactive: /resume, /new, /name <name>, /session (file, ID, message count, tokens, cost), /tree, /fork, /clone, /compact [prompt], /export [file], /share.

Resuming and Deleting

/resume (and pi -r) opens a picker for the current project. Search by typing; Ctrl+P toggles path display, Ctrl+S cycles sort mode, Ctrl+N filters to named sessions, Ctrl+R renames, Ctrl+D deletes with confirmation. Pi uses the trash CLI when available instead of permanently removing files.

Branching with /tree

Sessions are trees: every entry has id and parentId, and the current position is the active leaf. /tree jumps to any previous point and continues from there without creating a new file.

KeyAction
↑/↓Navigate visible entries
←/→Page up/down
Ctrl+←/→ or Alt+←/→Fold/unfold or jump between branch segments
Shift+LSet or clear a label on the selected entry
Shift+TToggle label timestamps
EnterSelect entry
Escape / Ctrl+CCancel
Ctrl+OCycle filter mode

Filter modes: default, no-tools, user-only, labeled-only, all. Set the default with treeFilterMode.

Selection Behavior

Selecting a user or custom message moves the leaf to that message's parent, puts the message text in the editor, and lets you edit and resubmit — creating a new branch. Selecting an assistant, tool, compaction, or other non-user entry moves the leaf there with an empty editor so you continue from that point. Selecting the root user message resets the leaf to an empty conversation with the original prompt in the editor.

Tree vs Fork vs Clone

/tree/fork/clone
OutputSame session fileNew session fileNew session file
ViewFull treeUser-message selectorCurrent active branch
Typical useExplore alternatives in placeStart a new session from an earlier promptDuplicate current work before continuing
SummaryOptional branch summaryNoneNone

Branch Summaries

When /tree switches away from one branch, Pi can summarize the abandoned branch and attach the summary at the new position, preserving context without replaying the branch. When prompted, choose no summary, the default prompt, or custom focus instructions. Internals and extension hooks: references/compaction.md. File format and SessionManager API: references/session-format.md.