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 / attach"]
        SUSPEND["suspend"]
        RESTART["restart"]
        EXEC["exec"]
        RUN["run"]
        LIST["list / ls"]
        INFO["info"]
        LOGS["logs"]
        DELETE["delete / rm"]
        FORK["fork"]
        PURGE["purge"]
    end

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

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

Create and boot a new session from a profile. Use -n <name> for a retained, named VM that can be stopped, resumed, forked, and inspected later.

Terminal window
capsem create # unnamed session
capsem create -n mybox # named retained session
capsem create -n 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
-n, --name <NAME>Name for the session
--ram <GB>4RAM in GB
--cpu <CORES>4CPU cores
-e, --env <KEY=VALUE>Environment variables (repeatable)
--from <NAME>Clone state from an existing retained session/template (alias: --image)

Open an interactive shell. With no arguments, creates an unnamed session for the shell and cleans it up when the shell exits.

Terminal window
capsem shell # unnamed shell session
capsem shell mybox # attach to existing session
capsem shell -n mybox # find by name
capsem shell abc123 # find by ID
FlagDescription
-n, --name <NAME>Find by name
[SESSION]Name or ID of an existing session

Resume a suspended session or attach to a running one.

Terminal window
capsem resume mybox
capsem attach mybox # alias
ArgDescription
<name>Name of the session

Suspend a running retained session to disk. Saves RAM and CPU state.

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

Restart a session.

Terminal window
capsem restart mybox
ArgDescription
<name>Name of the session

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 one-shot session. The session is 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.

Terminal window
capsem list
capsem ls # alias
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
capsem rm mybox # alias
ArgDescription
<SESSION>Name or ID of the session

Fork a session into a retained VM/template. 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>.

Destroy disposable sessions. Use --all to include retained sessions.

Terminal window
capsem purge # disposable sessions only
capsem purge --all # everything (requires confirmation)
FlagDefaultDescription
--allfalseAlso destroy retained 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

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 VM, runs the capsem-doctor test suite, and reports results.

Terminal window
capsem doctor

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 --> Stopped: stop
    Suspended --> [*]: delete
    Running --> Forked: fork
    Forked --> Running: resume / create --from
ConceptDescription
ProfileThe VM contract: assets, rules, detection, MCP, plugins, VM defaults, name, description, and icon
Named retained VMA VM with a stable name and retained state
One-shot runA disposable VM used by capsem run for one command
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.