> ## 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.

# use - Choose an image for the session

Set the session image or show the current session state.

This is typically the first command you run – it tells contree-cli which
image to use for subsequent commands.

## Examples

```bash theme={null}
# Start a session with an image
eval $(contree use tag:ubuntu:latest)

# Start a session with a specific image UUID
eval $(contree use 3f2a7b...)

# Start or resume a named session
export CONTREE_SESSION=my-session

# Show current session info
contree use

# Start a fresh session (new session key)
eval $(contree use -N tag:python:3.11-slim)
```

The `eval` wrapper exports `CONTREE_SESSION` into your shell so all
subsequent commands share the same session. Without `eval`, contree prints
the export line but your shell doesn’t pick it up.

## 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 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 use</span><span style={{"color":"#c5c8c6"}}> \[</span><span style={{"color":"#98c379"}}>-h</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#98c379"}}>-N</span><span style={{"color":"#c5c8c6"}}>] </span><span style={{"color":"#98c379"}}>\[image]</span><br /><br /><span style={{"color":"#c5c8c6"}}>Set or show the current session image.</span><br /><br /><span style={{"color":"#c5c8c6"}}>With an IMAGE argument, resolves it (UUID or tag:NAME) and sets it as</span><br /><span style={{"color":"#c5c8c6"}}>the active session image. Prints a shell export line so that the</span><br /><span style={{"color":"#c5c8c6"}}>session key can be captured with eval:</span><br /><br /><span style={{"color":"#c5c8c6"}}>  eval \$(contree use tag:ubuntu:latest)</span><br /><br /><span style={{"color":"#c5c8c6"}}>Without arguments, displays the current session info (image, branch,</span><br /><span style={{"color":"#c5c8c6"}}>last operation).</span><br /><br /><span style={{"color":"#c5c8c6"}}>Use -N/--new to start a fresh session instead of resuming the current</span><br /><span style={{"color":"#c5c8c6"}}>one. The new session key is printed as an export line.</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>positional arguments:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>image</span><span style={{"color":"#c5c8c6"}}>       Image UUID or tag</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"}}>-N</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--new</span><span style={{"color":"#c5c8c6"}}>   Start a new session instead of resuming the current one</span><br /><br /><span style={{"color":"#c5c8c6"}}>for coding agents:</span><br /><span style={{"color":"#c5c8c6"}}>  use IMAGE starts/switches a session and prints CONTREE\_SESSION export</span><br /><span style={{"color":"#c5c8c6"}}>  use (without IMAGE) is read-only and prints current session state</span><br /><span style={{"color":"#c5c8c6"}}>  use --new IMAGE creates a fresh session key</span><br /><span style={{"color":"#c5c8c6"}}>  without CONTREE\_SESSION env var, key is auto-generated as \<cwd>+\<8hex></span><br /><span style={{"color":"#c5c8c6"}}>  (derived from profile+ppid+tty); export your own for stability</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>

## Behavior

**With an image argument**: resolves the image (UUID or `tag:NAME`), sets it
as the session’s current image, and prints a shell export statement.

**Without arguments**: displays the current session info – session key,
active branch, current image, and last operation.

**With `--new`**: generates a new random session key instead of resuming the
existing one. Useful when you want a clean slate in the same terminal.

## Shell detection

The output format adapts to your shell:

* **bash / zsh**: `export CONTREE_SESSION=<key>`
* **fish**: `set -gx CONTREE_SESSION <key>`

Detection uses the `$SHELL` environment variable.

## See also

* [Your First Sandbox](../tutorial/first-steps) – starting your first session
* [Sessions, Branches & Rollback](../tutorial/sessions) – branching and rollback
