> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tokenfactory.nebius.com/llms.txt
> Use this file to discover all available pages before exploring further.

# session - Manage sessions, branches, history

Manage session branches and history. Sessions track the image state as you
run commands, with support for branching and rollback.

## Examples

```bash theme={null}
# Show current session
contree session

# List all sessions
contree session list

# Show full history
contree session show

# Create and switch to a branch
contree session branch experiment
contree session checkout experiment

# Switch back
contree session checkout main

# Create a branch from another branch
contree session branch hotfix --from main

# List branches (* marks active)
contree session branch

# Undo last operation
contree session rollback

# Undo last 3 operations (`--` stops argparse from eating `-3` as a flag)
contree session rollback -- -3

# Forward one entry
contree session rollback +1

# Absolute jump to a specific history id (use `session show` first)
contree session rollback 42

# Import image from another session
contree session use other-session

# Delete a session
contree session delete my-old-session
contree session rm my-old-session -y
```

## Help output

<div className="contree-terminal" style={{"border":"1px solid rgba(255,255,255,0.15)","borderRadius":8,"overflow":"hidden","margin":"1rem 0"}}><div style={{"background":"#292929","height":24,"display":"flex","alignItems":"center","padding":"0 12px","position":"relative"}}><div style={{"display":"flex","alignItems":"center","flexShrink":0}}><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#ff5f57","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#febc2e","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#28c840"}} /></div><div style={{"position":"absolute","left":0,"right":0,"textAlign":"center","fontFamily":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif","fontWeight":"bold","color":"#999"}}>\$ contree session --help</div></div><pre style={{"margin":0,"borderRadius":0,"padding":"8px 10px","background":"#1e1e1e","overflowX":"auto"}}><code style={{"fontFamily":"JetBrains Mono, SF Mono, SFMono-Regular, Menlo, Monaco, Cascadia Mono, Segoe UI Mono, Roboto Mono, Oxygen Mono, Ubuntu Monospace, Source Code Pro, Fira Mono, Droid Sans Mono, Consolas, Courier New, monospace","color":"#c5c8c6","whiteSpace":"pre-wrap"}}><span style={{"color":"#61afef","fontWeight":"bold"}}>usage: </span><span style={{"color":"#c678dd","fontWeight":"bold"}}>contree session</span><span style={{"color":"#c5c8c6"}}> \[</span><span style={{"color":"#98c379"}}>-h</span><span style={{"color":"#c5c8c6"}}>]</span><br /><span style={{"color":"#c5c8c6"}}>                       </span><span style={{"color":"#98c379"}}>\{list,ls,use,branch,br,checkout,co,rollback,rb,show,wait,delete,rm,del} ...</span><br /><br /><span style={{"color":"#c5c8c6"}}>Manage session branches and history.</span><br /><br /><span style={{"color":"#c5c8c6"}}>Without a subcommand, shows the current session info (key, branch,</span><br /><span style={{"color":"#c5c8c6"}}>image, last operation).</span><br /><br /><span style={{"color":"#c5c8c6"}}>Subcommands:</span><br /><span style={{"color":"#c5c8c6"}}>  list (ls)       List all sessions</span><br /><span style={{"color":"#c5c8c6"}}>  use KEY         Import another session's current image</span><br /><span style={{"color":"#c5c8c6"}}>  branch (br)     List or create branches (--from to fork)</span><br /><span style={{"color":"#c5c8c6"}}>  checkout (co)   Switch active branch</span><br /><span style={{"color":"#c5c8c6"}}>  rollback (rb)   Navigate history: N=absolute, -N=back, +N=forward</span><br /><span style={{"color":"#c5c8c6"}}>  show            Display the session history DAG</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>positional arguments:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>\{list,ls,use,branch,br,checkout,co,rollback,rb,show,wait,delete,rm,del}</span><br /><span style={{"color":"#c5c8c6"}}>    </span><span style={{"color":"#98c379","fontWeight":"bold"}}>list (ls)</span><span style={{"color":"#c5c8c6"}}>           List all sessions</span><br /><span style={{"color":"#c5c8c6"}}>    </span><span style={{"color":"#98c379","fontWeight":"bold"}}>use</span><span style={{"color":"#c5c8c6"}}>                 Import another session's image</span><br /><span style={{"color":"#c5c8c6"}}>    </span><span style={{"color":"#98c379","fontWeight":"bold"}}>branch (br)</span><span style={{"color":"#c5c8c6"}}>         List, create, delete, or prune branches</span><br /><span style={{"color":"#c5c8c6"}}>    </span><span style={{"color":"#98c379","fontWeight":"bold"}}>checkout (co)</span><span style={{"color":"#c5c8c6"}}>       Switch active branch</span><br /><span style={{"color":"#c5c8c6"}}>    </span><span style={{"color":"#98c379","fontWeight":"bold"}}>rollback (rb)</span><span style={{"color":"#c5c8c6"}}>       Navigate history: N=absolute, -N=back, +N=forward</span><br /><span style={{"color":"#c5c8c6"}}>    </span><span style={{"color":"#98c379","fontWeight":"bold"}}>show</span><span style={{"color":"#c5c8c6"}}>                Show session history</span><br /><span style={{"color":"#c5c8c6"}}>    </span><span style={{"color":"#98c379","fontWeight":"bold"}}>wait</span><span style={{"color":"#c5c8c6"}}>                Drain detached ops in the current session</span><br /><span style={{"color":"#c5c8c6"}}>    </span><span style={{"color":"#98c379","fontWeight":"bold"}}>delete (rm, del)</span><span style={{"color":"#c5c8c6"}}>    Delete sessions by key</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>options:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-h</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--help</span><span style={{"color":"#c5c8c6"}}>            show this help message and exit</span><br /><br /><span style={{"color":"#c5c8c6"}}>for coding agents:</span><br /><span style={{"color":"#c5c8c6"}}>  session (no subcommand) is read-only</span><br /><span style={{"color":"#c5c8c6"}}>  branch/checkout/rollback/session use mutates local session pointers</span><br /><span style={{"color":"#c5c8c6"}}>  \`session show\` defaults to last 20 history entries; pass -a/--all for full DAG</span><br /><span style={{"color":"#c5c8c6"}}>  use \`session show\` to inspect history DAG before destructive navigation</span><br /><span style={{"color":"#c5c8c6"}}>  \`session wait \[OPS...]\` waits for active or specified operations</span><br /><br /><span style={{"color":"#c5c8c6"}}>agent note:</span><br /><span style={{"color":"#c5c8c6"}}>  Before using this command in an automated workflow, read:</span><br /><span style={{"color":"#c5c8c6"}}>    contree agent</span></code></pre></div>

## Concepts

Each non-disposable `contree run` creates a new history entry and advances
the branch pointer. Branches share the underlying history – creating a
branch just adds a new pointer at the current position.

Rollback moves the branch pointer backwards. History entries are preserved
and can be recovered by creating a new branch.

## Subcommands

### `session list`

`contree session list` (alias `ls`) prints every session known to the
current profile, with the active session marked. The optional
`--filter` flag narrows the list by substring match against the session
key, which is handy when you keep many disposable sessions named after
features or tickets.

<div className="contree-terminal" style={{"border":"1px solid rgba(255,255,255,0.15)","borderRadius":8,"overflow":"hidden","margin":"1rem 0"}}><div style={{"background":"#292929","height":24,"display":"flex","alignItems":"center","padding":"0 12px","position":"relative"}}><div style={{"display":"flex","alignItems":"center","flexShrink":0}}><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#ff5f57","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#febc2e","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#28c840"}} /></div><div style={{"position":"absolute","left":0,"right":0,"textAlign":"center","fontFamily":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif","fontWeight":"bold","color":"#999"}}>\$ contree session list --help</div></div><pre style={{"margin":0,"borderRadius":0,"padding":"8px 10px","background":"#1e1e1e","overflowX":"auto"}}><code style={{"fontFamily":"JetBrains Mono, SF Mono, SFMono-Regular, Menlo, Monaco, Cascadia Mono, Segoe UI Mono, Roboto Mono, Oxygen Mono, Ubuntu Monospace, Source Code Pro, Fira Mono, Droid Sans Mono, Consolas, Courier New, monospace","color":"#c5c8c6","whiteSpace":"pre-wrap"}}><span style={{"color":"#61afef","fontWeight":"bold"}}>usage: </span><span style={{"color":"#c678dd","fontWeight":"bold"}}>contree session list</span><span style={{"color":"#c5c8c6"}}> \[</span><span style={{"color":"#98c379"}}>-h</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#56b6c2"}}>--filter </span><span style={{"color":"#e5c07b"}}>FILTER\_TEXT</span><span style={{"color":"#c5c8c6"}}>]</span><br /><br /><span style={{"color":"#c5c8c6"}}>List locally known sessions and their current branch/image.</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>options:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-h</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--help</span><span style={{"color":"#c5c8c6"}}>            show this help message and exit</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--filter</span><span style={{"color":"#c5c8c6"}}> </span><span style={{"color":"#e5c07b","fontWeight":"bold"}}>FILTER\_TEXT</span><span style={{"color":"#c5c8c6"}}>  Filter session keys containing this text</span><br /><br /><span style={{"color":"#c5c8c6"}}>for coding agents: read-only command</span></code></pre></div>

### `session use`

`contree session use KEY` imports the **current image** of another
session into the active session as a new history entry. The source
session is not modified; this is a “fork the snapshot, keep working
here” operation, distinct from the top-level `contree use` which starts
or resumes a session against an image reference.

<div className="contree-terminal" style={{"border":"1px solid rgba(255,255,255,0.15)","borderRadius":8,"overflow":"hidden","margin":"1rem 0"}}><div style={{"background":"#292929","height":24,"display":"flex","alignItems":"center","padding":"0 12px","position":"relative"}}><div style={{"display":"flex","alignItems":"center","flexShrink":0}}><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#ff5f57","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#febc2e","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#28c840"}} /></div><div style={{"position":"absolute","left":0,"right":0,"textAlign":"center","fontFamily":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif","fontWeight":"bold","color":"#999"}}>\$ contree session use --help</div></div><pre style={{"margin":0,"borderRadius":0,"padding":"8px 10px","background":"#1e1e1e","overflowX":"auto"}}><code style={{"fontFamily":"JetBrains Mono, SF Mono, SFMono-Regular, Menlo, Monaco, Cascadia Mono, Segoe UI Mono, Roboto Mono, Oxygen Mono, Ubuntu Monospace, Source Code Pro, Fira Mono, Droid Sans Mono, Consolas, Courier New, monospace","color":"#c5c8c6","whiteSpace":"pre-wrap"}}><span style={{"color":"#61afef","fontWeight":"bold"}}>usage: </span><span style={{"color":"#c678dd","fontWeight":"bold"}}>contree session use</span><span style={{"color":"#c5c8c6"}}> \[</span><span style={{"color":"#98c379"}}>-h</span><span style={{"color":"#c5c8c6"}}>] </span><span style={{"color":"#98c379"}}>session\_name</span><br /><br /><span style={{"color":"#c5c8c6"}}>Set current session image to another session's tip image. Accepts exact key or key suffix.</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>positional arguments:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>session\_name</span><span style={{"color":"#c5c8c6"}}>  Session key or suffix to match</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>options:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-h</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--help</span><span style={{"color":"#c5c8c6"}}>    show this help message and exit</span><br /><br /><span style={{"color":"#c5c8c6"}}>for coding agents: mutates current session history</span></code></pre></div>

### `session branch`

`contree session branch` (alias `br`) lists branches with `*` marking
the active one. Pass a name to create a new branch pointing at the
current history position, or combine with `--from BRANCH` to fork off a
different branch. The `-U`/`--prune` flag removes branches that no
longer reference live history.

<div className="contree-terminal" style={{"border":"1px solid rgba(255,255,255,0.15)","borderRadius":8,"overflow":"hidden","margin":"1rem 0"}}><div style={{"background":"#292929","height":24,"display":"flex","alignItems":"center","padding":"0 12px","position":"relative"}}><div style={{"display":"flex","alignItems":"center","flexShrink":0}}><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#ff5f57","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#febc2e","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#28c840"}} /></div><div style={{"position":"absolute","left":0,"right":0,"textAlign":"center","fontFamily":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif","fontWeight":"bold","color":"#999"}}>\$ contree session branch --help</div></div><pre style={{"margin":0,"borderRadius":0,"padding":"8px 10px","background":"#1e1e1e","overflowX":"auto"}}><code style={{"fontFamily":"JetBrains Mono, SF Mono, SFMono-Regular, Menlo, Monaco, Cascadia Mono, Segoe UI Mono, Roboto Mono, Oxygen Mono, Ubuntu Monospace, Source Code Pro, Fira Mono, Droid Sans Mono, Consolas, Courier New, monospace","color":"#c5c8c6","whiteSpace":"pre-wrap"}}><span style={{"color":"#61afef","fontWeight":"bold"}}>usage: </span><span style={{"color":"#c678dd","fontWeight":"bold"}}>contree session branch</span><span style={{"color":"#c5c8c6"}}> \[</span><span style={{"color":"#98c379"}}>-h</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#56b6c2"}}>--from </span><span style={{"color":"#e5c07b"}}>FROM\_BRANCH</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#98c379"}}>-U</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#56b6c2"}}>--prune</span><span style={{"color":"#c5c8c6"}}>] </span><span style={{"color":"#98c379"}}>\[branch\_name]</span><br /><br /><span style={{"color":"#c5c8c6"}}>List branches (no args). Create with NAME (optionally --from). Delete with --delete NAME. Prune</span><br /><span style={{"color":"#c5c8c6"}}>disposable-/detached- branches with --prune.</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>positional arguments:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>branch\_name</span><span style={{"color":"#c5c8c6"}}>         Branch name (create/delete target)</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>options:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-h</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--help</span><span style={{"color":"#c5c8c6"}}>          show this help message and exit</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--from</span><span style={{"color":"#c5c8c6"}}> </span><span style={{"color":"#e5c07b","fontWeight":"bold"}}>FROM\_BRANCH</span><span style={{"color":"#c5c8c6"}}>  Source branch (default: active branch)</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-U</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--delete</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--rm</span><span style={{"color":"#c5c8c6"}}>  Delete the specified branch (NAME required, must not be active)</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--prune</span><span style={{"color":"#c5c8c6"}}>             Prune disposable-/detached- branches (non-active only)</span><br /><br /><span style={{"color":"#c5c8c6"}}>for coding agents: read-only when NAME/--delete/--prune omitted mutating when</span><br /><span style={{"color":"#c5c8c6"}}>creating/deleting/pruning</span></code></pre></div>

### `session checkout`

`contree session checkout BRANCH` (alias `co`) switches the active
branch pointer. Working directory, pending files, and the current
image are all reset to whatever the target branch currently points at,
so it is the safe way to bounce between parallel experiments.

<div className="contree-terminal" style={{"border":"1px solid rgba(255,255,255,0.15)","borderRadius":8,"overflow":"hidden","margin":"1rem 0"}}><div style={{"background":"#292929","height":24,"display":"flex","alignItems":"center","padding":"0 12px","position":"relative"}}><div style={{"display":"flex","alignItems":"center","flexShrink":0}}><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#ff5f57","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#febc2e","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#28c840"}} /></div><div style={{"position":"absolute","left":0,"right":0,"textAlign":"center","fontFamily":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif","fontWeight":"bold","color":"#999"}}>\$ contree session checkout --help</div></div><pre style={{"margin":0,"borderRadius":0,"padding":"8px 10px","background":"#1e1e1e","overflowX":"auto"}}><code style={{"fontFamily":"JetBrains Mono, SF Mono, SFMono-Regular, Menlo, Monaco, Cascadia Mono, Segoe UI Mono, Roboto Mono, Oxygen Mono, Ubuntu Monospace, Source Code Pro, Fira Mono, Droid Sans Mono, Consolas, Courier New, monospace","color":"#c5c8c6","whiteSpace":"pre-wrap"}}><span style={{"color":"#61afef","fontWeight":"bold"}}>usage: </span><span style={{"color":"#c678dd","fontWeight":"bold"}}>contree session checkout</span><span style={{"color":"#c5c8c6"}}> \[</span><span style={{"color":"#98c379"}}>-h</span><span style={{"color":"#c5c8c6"}}>] </span><span style={{"color":"#98c379"}}>checkout\_branch</span><br /><br /><span style={{"color":"#c5c8c6"}}>Move current session to another existing branch tip.</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>positional arguments:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>checkout\_branch</span><span style={{"color":"#c5c8c6"}}>  Branch to switch to</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>options:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-h</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--help</span><span style={{"color":"#c5c8c6"}}>       show this help message and exit</span><br /><br /><span style={{"color":"#c5c8c6"}}>for coding agents: mutates active branch pointer</span></code></pre></div>

### `session rollback`

`contree session rollback [TARGET]` (alias `rb`) navigates the history
of the current branch. With no argument it steps back one entry; a
positive number jumps to that absolute history index, `-N` steps back
`N` entries, and `+N` steps forward. History entries are preserved –
rollback only moves the branch pointer.

<div className="contree-terminal" style={{"border":"1px solid rgba(255,255,255,0.15)","borderRadius":8,"overflow":"hidden","margin":"1rem 0"}}><div style={{"background":"#292929","height":24,"display":"flex","alignItems":"center","padding":"0 12px","position":"relative"}}><div style={{"display":"flex","alignItems":"center","flexShrink":0}}><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#ff5f57","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#febc2e","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#28c840"}} /></div><div style={{"position":"absolute","left":0,"right":0,"textAlign":"center","fontFamily":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif","fontWeight":"bold","color":"#999"}}>\$ contree session rollback --help</div></div><pre style={{"margin":0,"borderRadius":0,"padding":"8px 10px","background":"#1e1e1e","overflowX":"auto"}}><code style={{"fontFamily":"JetBrains Mono, SF Mono, SFMono-Regular, Menlo, Monaco, Cascadia Mono, Segoe UI Mono, Roboto Mono, Oxygen Mono, Ubuntu Monospace, Source Code Pro, Fira Mono, Droid Sans Mono, Consolas, Courier New, monospace","color":"#c5c8c6","whiteSpace":"pre-wrap"}}><span style={{"color":"#61afef","fontWeight":"bold"}}>usage: </span><span style={{"color":"#c678dd","fontWeight":"bold"}}>contree session rollback</span><span style={{"color":"#c5c8c6"}}> \[</span><span style={{"color":"#98c379"}}>-h</span><span style={{"color":"#c5c8c6"}}>] </span><span style={{"color":"#98c379"}}>\[target]</span><br /><br /><span style={{"color":"#c5c8c6"}}>Move branch pointer in session history. Supports absolute ID, relative backward (-N), and forward</span><br /><span style={{"color":"#c5c8c6"}}>(+N).</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>positional arguments:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>target</span><span style={{"color":"#c5c8c6"}}>      History target: ID (absolute), -N (back), +N (forward) — use \`-- -N\` for negative</span><br /><span style={{"color":"#c5c8c6"}}>              values</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>options:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-h</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--help</span><span style={{"color":"#c5c8c6"}}>  show this help message and exit</span><br /><br /><span style={{"color":"#c5c8c6"}}>for coding agents: mutates active branch history pointer</span></code></pre></div>

### `session show`

`contree session show` prints the session history DAG with one row per
entry, including operation IDs, image UUIDs, branch pointers, and
relative timestamps. Use `-a` to include hidden entries, `-k KIND` to
filter by entry kind (e.g. `run`, `cd`), and `-l LAST` to show only the
last N rows.

<div className="contree-terminal" style={{"border":"1px solid rgba(255,255,255,0.15)","borderRadius":8,"overflow":"hidden","margin":"1rem 0"}}><div style={{"background":"#292929","height":24,"display":"flex","alignItems":"center","padding":"0 12px","position":"relative"}}><div style={{"display":"flex","alignItems":"center","flexShrink":0}}><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#ff5f57","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#febc2e","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#28c840"}} /></div><div style={{"position":"absolute","left":0,"right":0,"textAlign":"center","fontFamily":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif","fontWeight":"bold","color":"#999"}}>\$ contree session show --help</div></div><pre style={{"margin":0,"borderRadius":0,"padding":"8px 10px","background":"#1e1e1e","overflowX":"auto"}}><code style={{"fontFamily":"JetBrains Mono, SF Mono, SFMono-Regular, Menlo, Monaco, Cascadia Mono, Segoe UI Mono, Roboto Mono, Oxygen Mono, Ubuntu Monospace, Source Code Pro, Fira Mono, Droid Sans Mono, Consolas, Courier New, monospace","color":"#c5c8c6","whiteSpace":"pre-wrap"}}><span style={{"color":"#61afef","fontWeight":"bold"}}>usage: </span><span style={{"color":"#c678dd","fontWeight":"bold"}}>contree session show</span><span style={{"color":"#c5c8c6"}}> \[</span><span style={{"color":"#98c379"}}>-h</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#98c379"}}>-a</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#98c379"}}>-k </span><span style={{"color":"#e5c07b"}}>KIND</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#98c379"}}>-l </span><span style={{"color":"#e5c07b"}}>LAST</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#56b6c2"}}>--since </span><span style={{"color":"#e5c07b"}}>SINCE</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#56b6c2"}}>--until </span><span style={{"color":"#e5c07b"}}>UNTIL</span><span style={{"color":"#c5c8c6"}}>]</span><br /><span style={{"color":"#c5c8c6"}}>                            </span><span style={{"color":"#98c379"}}>\[session\_name]</span><br /><br /><span style={{"color":"#c5c8c6"}}>Print session history DAG entries and branch labels. By default shows last 20 entries; use</span><br /><span style={{"color":"#c5c8c6"}}>-a/--all for full history.</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>positional arguments:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>session\_name</span><span style={{"color":"#c5c8c6"}}>     Session key or suffix (default: current session)</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>options:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-h</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--help</span><span style={{"color":"#c5c8c6"}}>       show this help message and exit</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-a</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--all</span><span style={{"color":"#c5c8c6"}}>        Show full history (default: last 20 entries)</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-k</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--kind</span><span style={{"color":"#c5c8c6"}}> </span><span style={{"color":"#e5c07b","fontWeight":"bold"}}>KIND</span><span style={{"color":"#c5c8c6"}}>  Filter history entries by kind (e.g., run, use, cd)</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-l</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--last</span><span style={{"color":"#c5c8c6"}}> </span><span style={{"color":"#e5c07b","fontWeight":"bold"}}>LAST</span><span style={{"color":"#c5c8c6"}}>  Show last N entries after filtering</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--since</span><span style={{"color":"#c5c8c6"}}> </span><span style={{"color":"#e5c07b","fontWeight":"bold"}}>SINCE</span><span style={{"color":"#c5c8c6"}}>    Show entries since. Parse +/- intervals (bare seconds or smhdMy) or ISO/date to</span><br /><span style={{"color":"#c5c8c6"}}>                   UTC datetime.</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--until</span><span style={{"color":"#c5c8c6"}}> </span><span style={{"color":"#e5c07b","fontWeight":"bold"}}>UNTIL</span><span style={{"color":"#c5c8c6"}}>    Show entries before. Parse +/- intervals (bare seconds or smhdMy) or ISO/date</span><br /><span style={{"color":"#c5c8c6"}}>                   to UTC datetime.</span><br /><br /><span style={{"color":"#c5c8c6"}}>for coding agents: read-only command</span></code></pre></div>

### `session wait`

`contree session wait [OP_ID ...]` blocks until the specified operations
reach a terminal state (`SUCCESS`, `FAILED`, or `CANCELLED`). When no
IDs are given it waits for every active operation in the session, which
is the canonical way to drain background `contree run -d` jobs before
moving on.

<div className="contree-terminal" style={{"border":"1px solid rgba(255,255,255,0.15)","borderRadius":8,"overflow":"hidden","margin":"1rem 0"}}><div style={{"background":"#292929","height":24,"display":"flex","alignItems":"center","padding":"0 12px","position":"relative"}}><div style={{"display":"flex","alignItems":"center","flexShrink":0}}><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#ff5f57","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#febc2e","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#28c840"}} /></div><div style={{"position":"absolute","left":0,"right":0,"textAlign":"center","fontFamily":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif","fontWeight":"bold","color":"#999"}}>\$ contree session wait --help</div></div><pre style={{"margin":0,"borderRadius":0,"padding":"8px 10px","background":"#1e1e1e","overflowX":"auto"}}><code style={{"fontFamily":"JetBrains Mono, SF Mono, SFMono-Regular, Menlo, Monaco, Cascadia Mono, Segoe UI Mono, Roboto Mono, Oxygen Mono, Ubuntu Monospace, Source Code Pro, Fira Mono, Droid Sans Mono, Consolas, Courier New, monospace","color":"#c5c8c6","whiteSpace":"pre-wrap"}}><span style={{"color":"#61afef","fontWeight":"bold"}}>usage: </span><span style={{"color":"#c678dd","fontWeight":"bold"}}>contree session wait</span><span style={{"color":"#c5c8c6"}}> \[</span><span style={{"color":"#98c379"}}>-h</span><span style={{"color":"#c5c8c6"}}>] </span><span style={{"color":"#98c379"}}>\[UUID\_OR\_REF ...]</span><br /><br /><span style={{"color":"#c5c8c6"}}>Drain detached operations in the current session. With no arguments, reads the session's pending-</span><br /><span style={{"color":"#c5c8c6"}}>ops cache, polls each to a terminal status, and advances the active branch to each non-disposable</span><br /><span style={{"color":"#c5c8c6"}}>result image (recording \`disposable-\<uuid>\` branches for disposable runs). With explicit UUIDs,</span><br /><span style={{"color":"#c5c8c6"}}>this command degrades to a plain polling loop: it prints completion rows but does NOT touch the</span><br /><span style={{"color":"#c5c8c6"}}>active branch, because the pending metadata is not loaded for explicit UUIDs.</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>positional arguments:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>UUID\_OR\_REF</span><span style={{"color":"#c5c8c6"}}>  Operations to wait for (default: all active in this session). Accepts UUIDs and</span><br /><span style={{"color":"#c5c8c6"}}>               session-history references (HEAD, HEAD\~N, @, @N, @-N, @+N, :N, bare N).</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>options:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-h</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--help</span><span style={{"color":"#c5c8c6"}}>   show this help message and exit</span><br /><br /><span style={{"color":"#c5c8c6"}}>for coding agents: no-arg form mutates session history (advances active branch) UUID form is a</span><br /><span style={{"color":"#c5c8c6"}}>pure polling observer if you need result images from explicit UUIDs, use \`op show UUID | jq -r</span><br /><span style={{"color":"#c5c8c6"}}>.image\` and \`contree use\`</span></code></pre></div>

### `session delete`

`contree session delete KEY [KEY ...]` (aliases `rm`, `del`) removes
sessions and all their data – history, branches, pending files, shell
history. The command prompts before deleting unless `-y` is passed.
Use this to garbage-collect throwaway sessions; the disk savings on
the SQLite database can be substantial when many short-lived sessions
accumulate.

<div className="contree-terminal" style={{"border":"1px solid rgba(255,255,255,0.15)","borderRadius":8,"overflow":"hidden","margin":"1rem 0"}}><div style={{"background":"#292929","height":24,"display":"flex","alignItems":"center","padding":"0 12px","position":"relative"}}><div style={{"display":"flex","alignItems":"center","flexShrink":0}}><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#ff5f57","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#febc2e","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#28c840"}} /></div><div style={{"position":"absolute","left":0,"right":0,"textAlign":"center","fontFamily":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif","fontWeight":"bold","color":"#999"}}>\$ contree session delete --help</div></div><pre style={{"margin":0,"borderRadius":0,"padding":"8px 10px","background":"#1e1e1e","overflowX":"auto"}}><code style={{"fontFamily":"JetBrains Mono, SF Mono, SFMono-Regular, Menlo, Monaco, Cascadia Mono, Segoe UI Mono, Roboto Mono, Oxygen Mono, Ubuntu Monospace, Source Code Pro, Fira Mono, Droid Sans Mono, Consolas, Courier New, monospace","color":"#c5c8c6","whiteSpace":"pre-wrap"}}><span style={{"color":"#61afef","fontWeight":"bold"}}>usage: </span><span style={{"color":"#c678dd","fontWeight":"bold"}}>contree session delete</span><span style={{"color":"#c5c8c6"}}> \[</span><span style={{"color":"#98c379"}}>-h</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#98c379"}}>-y</span><span style={{"color":"#c5c8c6"}}>] </span><span style={{"color":"#98c379"}}>KEY \[KEY ...]</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>positional arguments:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>KEY</span><span style={{"color":"#c5c8c6"}}>          Session keys to delete</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>options:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-h</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--help</span><span style={{"color":"#c5c8c6"}}>   show this help message and exit</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-y</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--force</span><span style={{"color":"#c5c8c6"}}>  Do not ask for confirmation</span></code></pre></div>

```bash theme={null}
contree session delete KEY [KEY ...]
contree session rm KEY -y     # skip confirmation
contree session del KEY
```

## See also

* [Sessions, Branches & Rollback](../tutorial/sessions) – full tutorial on sessions, branches, and rollback
* [use - Choose an image for the session](./use) – start or resume a session
