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
--jsonprints machine-readable output on stdout. Hosts and the Herdr plugin consumestatus --json,list --json,up --jsonand the job stream.- Env verbs accept
--env <id|slug>to address a specific env, which is how a shared-worktree fork is reached. - Mutating verbs run as jobs in the per-user daemon.
--detachreturns as soon as the daemon has the job;--foregroundruns the verb in the calling process instead (no daemon is started).spwn job attachfollows a detached job. - Exit status is non-zero when the verb fails; the env is left in place with its logs for inspection.
Env verbs
| Verb | What it does | Flags |
|---|---|---|
spwn up | Create 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 down | Run teardown hooks, stop services, destroy children, free the port block, remove the env's volumes. | --force, --remove-worktree, --env id, --foreground, --detach, --json |
spwn fork | Fork 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 reset | Return 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 status | The env's state, services and their health, ports, URLs, volumes, snapshot id and secret names (never values). | --env id, --json |
spwn logs | Tail service logs from .spwn/logs/. | |
spwn list | List every env on this machine, across repos. | --json |
Env lock
These exist when the repo sets [limits] active ≥ 1. See the env lock.
| Verb | What it does | Flags |
|---|---|---|
spwn lock | Take 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 unlock | Give 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
| Verb | What it does | Flags |
|---|---|---|
spwn check | Validate 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 init | Draft a spwn.toml from an existing Compose file. Planned (PRD 011); the verb is listed but not implemented yet. | --json |
spwn doctor | Check 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 install | Wire 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 mcp | Serve the env-scoped MCP server on stdio. Hosts start it from .mcp.json. --enable-destroy exposes env_destroy. | --enable-destroy |
spwn daemon | Run, 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|cancel | List recent jobs, follow a job's progress, or cancel one. | |
spwn worktree create|remove | The 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 proxy | Manage 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.
| Variable | Value |
|---|---|
SPWN_ENV_ID, SPWN_ENV_SLUG | The env's id (a ULID) and its URL-safe slug. |
SPWN_PARENT_ID | The 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_PHASE | The hook point a hook runs at. |
SPWN_WORKTREE | Absolute 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_CONTEXT | Path 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.