Skip to content

CLI Reference

The capsem CLI manages sessions, the background service, and system configuration. All session operations route through the service daemon over a Unix Domain Socket.

graph TD
    subgraph "Session Commands"
        CREATE["create"]
        SHELL["shell"]
        RESUME["resume"]
        SUSPEND["suspend"]
        RESTART["restart"]
        EXEC["exec"]
        RUN["run"]
        LIST["list"]
        INFO["info"]
        LOGS["logs"]
        DELETE["delete"]
        FORK["fork"]
        PERSIST["persist"]
        PURGE["purge"]
    end

    subgraph "Service Commands"
        INSTALL["install"]
        STATUS["status"]
        START["start"]
        STOP["stop"]
    end

    subgraph "Misc Commands"
        SETUP["setup"]
        UPDATE["update"]
        DOCTOR["doctor"]
        COMPLETIONS["completions"]
        VERSION["version"]
        UNINSTALL["uninstall"]
    end

Create and boot a new session. Sessions are ephemeral by default. Pass a positional name to make it persistent.

Terminal window
capsem create # ephemeral session
capsem create mybox # persistent session
capsem create mybox --ram 8 --cpu 4 # custom resources
capsem create --from template # clone from existing session
capsem create -e API_KEY=sk-... # with environment variables
FlagDefaultDescription
[NAME]Name for the session (makes it persistent)
--ram <GB>4RAM in GB
--cpu <CORES>4CPU cores
-e, --env <KEY=VALUE>Environment variables (repeatable)
--from <NAME>Clone state from existing persistent session

Open an interactive shell. With no arguments, creates a temporary session that is destroyed on exit.

Terminal window
capsem shell # temp session (destroyed on exit)
capsem shell mybox # attach to existing session
capsem shell abc123 # find by ID
ArgDescription
[SESSION]Name or ID of an existing session

Resume a suspended session or attach to a running one.

Terminal window
capsem resume mybox
ArgDescription
<name>Name of the persistent session (required)

Suspend a running session to disk. Saves RAM and CPU state. Only persistent sessions can be suspended.

Terminal window
capsem suspend mybox
ArgDescription
<SESSION>Name or ID of the session

Restart a persistent session (reboot).

Terminal window
capsem restart mybox
ArgDescription
<name>Name of the persistent session (required)

Execute a command in a running session.

Terminal window
capsem exec mybox "ls -la /root"
capsem exec mybox "pip install numpy" --timeout 120
Arg/FlagDefaultDescription
<SESSION>Name or ID of the session
<command>Command to execute
--timeout <SECS>30Timeout in seconds

Run a command in a fresh temporary session. The session is auto-provisioned and destroyed after the command completes.

Terminal window
capsem run "python3 -c 'print(1+1)'"
capsem run "npm test" --timeout 120
capsem run "pytest" -e API_KEY=sk-...
Arg/FlagDefaultDescription
<command>Command to execute
--timeout <SECS>60Timeout in seconds
-e, --env <KEY=VALUE>Environment variables (repeatable)

List all sessions (running + suspended persistent).

Terminal window
capsem list
capsem list -q # IDs only (for scripting)
FlagDescription
-q, --quietPrint only IDs, one per line

Output columns: NAME, STATUS, RAM, CPUs, UPTIME.

Show detailed information about a session, including telemetry.

Terminal window
capsem info mybox
capsem info mybox --json # machine-readable
Arg/FlagDescription
<SESSION>Name or ID of the session
--jsonOutput as JSON (for scripting)

The default output shows a rich formatted view with session config, status, and telemetry summary (network requests, model calls, tokens, cost).

Show serial console and process logs from a session.

Terminal window
capsem logs mybox
capsem logs mybox --tail 50
Arg/FlagDescription
<SESSION>Name or ID of the session
--tail <N>Show only the last N lines

Delete a session and all its state permanently.

Terminal window
capsem delete mybox
ArgDescription
<SESSION>Name or ID of the session

Fork a session into a new persistent session. Creates a point-in-time copy of the disk state.

Terminal window
capsem fork mybox template
capsem fork mybox template -d "Clean Python env with numpy"
Arg/FlagDescription
<SESSION>Name or ID of the session to fork
<name>Name for the new session
-d, --description <TEXT>Optional description

The forked session can be booted with capsem resume <name> or used as a template with capsem create --from <name>.

Promote a running ephemeral session to persistent.

Terminal window
capsem persist abc123 mybox
ArgDescription
<SESSION>Name or ID of the running ephemeral session
<name>Name to assign

Destroy all temporary sessions. Use --all to also destroy persistent sessions.

Terminal window
capsem purge # temp sessions only
capsem purge --all # everything (requires confirmation)
FlagDefaultDescription
--allfalseAlso destroy persistent sessions

The background service (capsem-service) runs as a daemon. It auto-starts on login via LaunchAgent (macOS) or systemd (Linux).

CommandDescription
capsem installInstall as a system service (LaunchAgent / systemd)
capsem statusShow service installation and runtime status
capsem startStart the background service
capsem stopStop the background service

Run the first-time setup wizard. Auto-runs on first CLI use if not previously completed.

Terminal window
capsem setup
capsem setup --non-interactive --preset medium
capsem setup --corp-config https://internal.corp/capsem.toml
FlagDescription
--non-interactiveRun without prompts (accept defaults)
--preset <PRESET>Security preset: medium or high
--forceRe-run all steps even if previously completed
--accept-detectedAuto-accept detected credentials
--corp-config <URL|FILE>Provision corporate config

Check for updates and install the latest version.

Terminal window
capsem update
capsem update -y # skip confirmation

Run diagnostic tests in a fresh session. Boots a temporary VM, runs the capsem-doctor test suite, and reports results.

Terminal window
capsem doctor
capsem doctor --fast # skip slow network tests

Generate shell completions.

Terminal window
capsem completions bash > ~/.bash_completion.d/capsem
capsem completions zsh > ~/.zfunc/_capsem
capsem completions fish > ~/.config/fish/completions/capsem.fish

Show version and build information.

Terminal window
capsem version

Uninstall capsem completely — removes service, binaries, and data.

Terminal window
capsem uninstall
capsem uninstall -y # skip confirmation
stateDiagram-v2
    [*] --> Running: create / shell / run
    Running --> Suspended: suspend
    Suspended --> Running: resume
    Running --> Running: restart
    Running --> [*]: delete (ephemeral)
    Running --> Persistent: persist
    Suspended --> [*]: delete
    Running --> Forked: fork
    Forked --> Running: resume / create --from
ConceptDescription
EphemeralDefault. Destroyed on delete. Created by create (no name) or shell (no args)
PersistentSurvives suspend/resume. Created by create <name> or persist
SuspendedRAM + CPU state saved to disk. Resume with resume
ForkedPoint-in-time copy. Use as template with create --from

The same session operations are available to AI agents via the capsem-mcp server. See Guest MCP Endpoint for the full tool registry.