spwn

Command line

Every verb reads the spwn.toml at the git root of the current worktree and acts on that worktree's env. Hosts call these; so can you.

Global behaviour

Env verbs

VerbWhat it doesFlags
spwn upCreate or resume the env for this worktree. Idempotent: completed steps are no-ops, so it also recovers a failed env. Builds a missing or stale golden snapshot first.--profile name (repeatable; replaces SPWN_PROFILE; with neither, the env's recorded selection), --no-wait (park instead of waiting for the env lock), --timeout 10m, --foreground, --detach, --json
spwn downRun teardown hooks, stop services, destroy children, free the port block, remove the env's volumes.--force, --remove-worktree, --env id, --foreground, --detach, --json
spwn forkFork the running world into a child env: volumes copied copy-on-write, a new port block and URL, and by default a cloned worktree on a new branch. Prints the child's id, worktree path, ports and URLs.--name label, --worktree clone|shared, --env id, --foreground, --detach, --json
spwn resetReturn the env's volumes to the snapshot they started from, or to a named one, then run post_reset hooks. Services keep running.--to id, --env id, --foreground, --detach, --json
spwn snapshot [name]Capture the env's volumes as a golden snapshot, after pre_snapshot hooks. Prints the snapshot id. --list shows the snapshots this repo has.--list, --env id, --json
spwn statusThe env's state, services and their health, ports, URLs, volumes, snapshot id and secret names (never values).--env id, --json
spwn logsTail service logs from .spwn/logs/.
spwn listList every env on this machine, across repos.--json

Env lock

These exist when the repo sets [limits] active ≥ 1. See the env lock.

VerbWhat it doesFlags
spwn lockTake this repo's env lock for the current env, waiting in the queue if another env holds it. Resumes a parked env. spwn lock status shows the holder and the queue.--timeout 10m, --no-wait, --env id, --detach, --json
spwn unlockGive the lock back. The env is parked (services stopped, volumes kept) when someone is waiting, or stays running otherwise unless --keep-running=false.--keep-running=false, --force, --env id, --detach, --json

Repo and machine verbs

VerbWhat it doesFlags
spwn checkValidate spwn.toml (with its include bases and spwn.local.toml merged in) and report every error and warning with file and line, naming the layer that set the value. Unknown keys, unresolved template names and dangling references all fail here, never at runtime. A file in the earlier [ports.*]/[data.*] shape gets one error per old key naming its replacement.--json
spwn initDraft a spwn.toml from an existing Compose file. Planned (PRD 011); the verb is listed but not implemented yet.--json
spwn doctorCheck and repair spwn's state on this machine: runtime, filesystem and fork strategy, *.localhost resolution, port range, and leaked processes, containers, ports or volume directories after a crash.--fix, --yes, --json
spwn installWire spwn into an agent host. Idempotent; edits only its own entries in the project's config. --dry-run prints the diff.--host claude-code, --dry-run, --json
spwn mcpServe the env-scoped MCP server on stdio. Hosts start it from .mcp.json. --enable-destroy exposes env_destroy.--enable-destroy
spwn daemonRun, stop or inspect the per-user daemon. It is started on demand by any verb that needs it, so you rarely call this.
spwn job list|attach|cancelList recent jobs, follow a job's progress, or cancel one.
spwn worktree create|removeThe Claude Code hook entry points: create a worktree under the worktree root and bring its env up, printing the path; or bring an env down and remove its worktree.--no-wait
spwn proxyManage the *.localhost reverse proxy. It listens on 8642 by default; binding port 80 is planned.

Variables hooks and services see

Host hooks and run services get everything below on top of the caller's environment. A container gets only the automatic variables, the ports its own service declares (container-side values), its service's environment and listed secrets, as in Compose.

VariableValue
SPWN_ENV_ID, SPWN_ENV_SLUGThe env's id (a ULID) and its URL-safe slug.
SPWN_PARENT_IDThe parent env's id when this env is a fork; empty otherwise. Services use it to idle in a fork, for example a load generator.
SPWN_PHASEThe hook point a hook runs at.
SPWN_WORKTREEAbsolute worktree path.
SPWN_PORT_<NAME>The host port for each named port, plus the port's own env name (<NAME>_PORT by default).
SPWN_URL_<ROUTE>The preview URL of each http port with a route, when the proxy is on. Containers get it too, for links a browser will follow.
SPWN_CONTEXTPath to a JSON file with the full resolved context (hooks only).
Everything in [env_file]Your own environment entries, rendered, and the secrets its secrets list names. Host hooks and run services only.

User configuration

Machine-wide settings live in ~/.config/spwn/config.toml, never in the repo:

port_range = "41000-49999"   # the pool every env's block comes from
data_root = "~/.local/state/spwn/data"   # one filesystem for every env's volumes and snapshots
worktree_root = "~/.local/state/spwn/worktrees"   # where spwn worktree create puts worktrees

Per-repo, per-machine overrides go in a gitignored spwn.local.toml next to spwn.toml; it merges last, like compose.override.yml, and services.<name> = false there disables a service.