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.
Command overview
Section titled “Command overview”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
Session commands
Section titled “Session commands”create
Section titled “create”Create and boot a new session. Sessions are ephemeral by default. Pass a positional name to make it persistent.
capsem create # ephemeral sessioncapsem create mybox # persistent sessioncapsem create mybox --ram 8 --cpu 4 # custom resourcescapsem create --from template # clone from existing sessioncapsem create -e API_KEY=sk-... # with environment variables| Flag | Default | Description |
|---|---|---|
[NAME] | — | Name for the session (makes it persistent) |
--ram <GB> | 4 | RAM in GB |
--cpu <CORES> | 4 | CPU 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.
capsem shell # temp session (destroyed on exit)capsem shell mybox # attach to existing sessioncapsem shell abc123 # find by ID| Arg | Description |
|---|---|
[SESSION] | Name or ID of an existing session |
resume
Section titled “resume”Resume a suspended session or attach to a running one.
capsem resume mybox| Arg | Description |
|---|---|
<name> | Name of the persistent session (required) |
suspend
Section titled “suspend”Suspend a running session to disk. Saves RAM and CPU state. Only persistent sessions can be suspended.
capsem suspend mybox| Arg | Description |
|---|---|
<SESSION> | Name or ID of the session |
restart
Section titled “restart”Restart a persistent session (reboot).
capsem restart mybox| Arg | Description |
|---|---|
<name> | Name of the persistent session (required) |
Execute a command in a running session.
capsem exec mybox "ls -la /root"capsem exec mybox "pip install numpy" --timeout 120| Arg/Flag | Default | Description |
|---|---|---|
<SESSION> | — | Name or ID of the session |
<command> | — | Command to execute |
--timeout <SECS> | 30 | Timeout in seconds |
Run a command in a fresh temporary session. The session is auto-provisioned and destroyed after the command completes.
capsem run "python3 -c 'print(1+1)'"capsem run "npm test" --timeout 120capsem run "pytest" -e API_KEY=sk-...| Arg/Flag | Default | Description |
|---|---|---|
<command> | — | Command to execute |
--timeout <SECS> | 60 | Timeout in seconds |
-e, --env <KEY=VALUE> | — | Environment variables (repeatable) |
List all sessions (running + suspended persistent).
capsem listcapsem list -q # IDs only (for scripting)| Flag | Description |
|---|---|
-q, --quiet | Print only IDs, one per line |
Output columns: NAME, STATUS, RAM, CPUs, UPTIME.
Show detailed information about a session, including telemetry.
capsem info myboxcapsem info mybox --json # machine-readable| Arg/Flag | Description |
|---|---|
<SESSION> | Name or ID of the session |
--json | Output 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.
capsem logs myboxcapsem logs mybox --tail 50| Arg/Flag | Description |
|---|---|
<SESSION> | Name or ID of the session |
--tail <N> | Show only the last N lines |
delete
Section titled “delete”Delete a session and all its state permanently.
capsem delete mybox| Arg | Description |
|---|---|
<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.
capsem fork mybox templatecapsem fork mybox template -d "Clean Python env with numpy"| Arg/Flag | Description |
|---|---|
<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>.
persist
Section titled “persist”Promote a running ephemeral session to persistent.
capsem persist abc123 mybox| Arg | Description |
|---|---|
<SESSION> | Name or ID of the running ephemeral session |
<name> | Name to assign |
Destroy all temporary sessions. Use --all to also destroy persistent sessions.
capsem purge # temp sessions onlycapsem purge --all # everything (requires confirmation)| Flag | Default | Description |
|---|---|---|
--all | false | Also destroy persistent sessions |
Service commands
Section titled “Service commands”The background service (capsem-service) runs as a daemon. It auto-starts on login via LaunchAgent (macOS) or systemd (Linux).
| Command | Description |
|---|---|
capsem install | Install as a system service (LaunchAgent / systemd) |
capsem status | Show service installation and runtime status |
capsem start | Start the background service |
capsem stop | Stop the background service |
Misc commands
Section titled “Misc commands”Run the first-time setup wizard. Auto-runs on first CLI use if not previously completed.
capsem setupcapsem setup --non-interactive --preset mediumcapsem setup --corp-config https://internal.corp/capsem.toml| Flag | Description |
|---|---|
--non-interactive | Run without prompts (accept defaults) |
--preset <PRESET> | Security preset: medium or high |
--force | Re-run all steps even if previously completed |
--accept-detected | Auto-accept detected credentials |
--corp-config <URL|FILE> | Provision corporate config |
update
Section titled “update”Check for updates and install the latest version.
capsem updatecapsem update -y # skip confirmationdoctor
Section titled “doctor”Run diagnostic tests in a fresh session. Boots a temporary VM, runs the capsem-doctor test suite, and reports results.
capsem doctorcapsem doctor --fast # skip slow network testscompletions
Section titled “completions”Generate shell completions.
capsem completions bash > ~/.bash_completion.d/capsemcapsem completions zsh > ~/.zfunc/_capsemcapsem completions fish > ~/.config/fish/completions/capsem.fishversion
Section titled “version”Show version and build information.
capsem versionuninstall
Section titled “uninstall”Uninstall capsem completely — removes service, binaries, and data.
capsem uninstallcapsem uninstall -y # skip confirmationSession lifecycle
Section titled “Session lifecycle”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
| Concept | Description |
|---|---|
| Ephemeral | Default. Destroyed on delete. Created by create (no name) or shell (no args) |
| Persistent | Survives suspend/resume. Created by create <name> or persist |
| Suspended | RAM + CPU state saved to disk. Resume with resume |
| Forked | Point-in-time copy. Use as template with create --from |
MCP tools
Section titled “MCP tools”The same session operations are available to AI agents via the capsem-mcp server. See Guest MCP Endpoint for the full tool registry.