Skip to Content

CLI

Sign in and run sandboxes from the command line, open SSH to an agent, and run Docker, Docker Compose, and Kubernetes in sandboxes.

Install

The npm package sandcovery holds the TypeScript client and five commands: sandcovery, sandcovery-docker, sandcovery-kubectl, sandcovery-run, and sandcovery-t3. It needs Node.js 24.14 or later. Install it globally and sign in:

npm install --global sandcovery
sandcovery login

Sign in

sandcovery login signs your computer in to Sandcovery as you. It shows a code and opens a page in the dashboard that shows the same code, where you choose Approve Sign-In. The page waits 10 minutes.

  • Once you approve, the command keeps a key for this computer in ~/.config/sandcovery/credentials.json, or in sandcovery/credentials.json under XDG_CONFIG_HOME when that is set, readable only by you. sandcovery, sandcovery-docker, sandcovery-kubectl, sandcovery-run, and sandcovery-t3 all use it.
  • The key acts as you, with your role in the organization the dashboard has open, so it reaches what you reach there. It stops working once you leave that organization.
  • SANDCOVERY_API_KEY, when set, takes the place of that key, as in CI.
  • API Keys in the dashboard lists the key as a CLI sign-in named CLI on and the computer's name, and Revoke there signs that computer out. When the organization already has a key with that name, such as from an earlier sign-in or another computer with the same name, the new key's name ends in the next free number, such as (2).
  • sandcovery logout revokes the key and deletes it from the computer. sandcovery login on a computer that is signed in replaces its key and revokes the one before.

The sandcovery command

Each operation in the OpenAPI document is one command, sandcovery <group> <operation>, named as the document names it, and each of its parameters and body fields is a flag of the same name.

id=$(sandcovery sandboxes createSandbox --slug sandcovery/2x4:cheapest --ttl_seconds 600 | jq -r .id)
sandcovery sandboxes execSandbox --sandbox_id "$id" --command 'npm test'
sandcovery sandboxes destroySandbox --sandbox_id "$id"
  • A command prints the API's answer body on stdout. An error answer goes to stderr as the API sent it, and the command exits 1.
  • It sends SANDCOVERY_API_KEY, or the key sandcovery login keeps, as the key, and calls SANDCOVERY_BASE_URL when it is set, or https://www.sandcovery.com.
  • A flag for a body field that is not text, such as a number, a list, or an object, takes JSON, either as the flag value or as @ and a path relative to the current directory to a file inside it, such as --env @env.json. Every other flag takes its value as text as written, so --command @run.sh sends the text @run.sh. An operation whose body is a file, such as sandboxes uploadFile, reads that body from stdin.
  • --help works on every command.

SSH to an agent

sandcovery agents ssh opens SSH to an always-on agent, and a shell joins the agent's session. It needs OpenSSH's ssh and ssh-keygen on your PATH.

sandcovery agents ssh <agent_id>
sandcovery agents ssh <agent_id> -- -N -L 8080:127.0.0.1:8080
sandcovery agents ssh <agent_id> -- uptime
  • On a computer that isn't signed in, it signs in first, as sandcovery login does.
  • Arguments after -- go to ssh: options such as -L forward the agent's ports, and a command runs on its own instead of the shell.
  • Each connection signs in with a new key that the command makes in a folder only you can read, and deletes when ssh exits. The agent's host key is new each time too, so the command keeps it out of your known_hosts.
  • The command exits with ssh's exit code.

Docker in a sandbox

sandcovery-docker takes the same arguments as docker and runs them in a sandbox on a provider that runs Docker, so a computer with no Docker can build images and run containers. It streams Docker's output, adds nothing to Docker's stdout or stderr, and exits with Docker's exit code, so it can stand in for docker:

alias docker=sandcovery-docker
docker build --tag app .
docker run --rm app
  • It reads your key from SANDCOVERY_API_KEY, or the key sandcovery login keeps, and the API origin from SANDCOVERY_BASE_URL, and every argument goes to Docker. An API error, such as a refused key, passes through unchanged.
  • The first command starts the sandbox, and later commands reuse it until its TTL ends, so images and containers carry over between commands. sandcovery sandboxes destroySandbox ends it sooner.
  • Before Docker runs, the command copies the local files it reads into the sandbox at the same absolute paths, up to 100 MiB packed, and runs Docker in the same working directory there, so relative and absolute paths resolve as they do on your computer. Those files are the build context of build and bake without what .dockerignore leaves out, the files of a build's -f, --build-context, and --secret, the bind mount sources and env files of run and create, the env files of exec, the files that BUILDX_BAKE_FILE and EXPERIMENTAL_BUILDKIT_SOURCE_POLICY name, and the file that cp, load -i, or import reads.
  • The variables Docker reads come from your computer's environment, as with docker: a name given to -e or --env with no value on run, create, or exec, a name alone on a line of their --env-file, a name given to build --build-arg with no value, and the variable an env --secret of build reads. A name unset on your computer stays unset in the container, even where the sandbox sets it. The command sends the sandbox only those names and their values, in the environment of Docker's process and never in its command line.
  • Docker's own variables set on your computer apply in the sandbox too, such as DOCKER_DEFAULT_PLATFORM, BUILDKIT_PROGRESS, and COMPOSE_PROJECT_NAME, taken from Docker's lists for the CLI, Build, and Compose.
  • A variable that picks a daemon, context, config folder, or proxy, such as DOCKER_HOST, DOCKER_CONTEXT, DOCKER_CONFIG, BUILDKIT_HOST, or HTTP_PROXY, is sent only when a command names it, as with -e DOCKER_HOST or --build-arg HTTP_PROXY, and the container or build gets your value while Docker in the sandbox keeps using the sandbox's own daemon and config folder. When the command sends DOCKER_HOST or DOCKER_CONTEXT, Docker gets -H or --context naming the sandbox's daemon, and when it sends DOCKER_CONFIG, Docker gets --config naming the sandbox's config folder, unless you give that flag yourself.
  • Only paths under your home folder or the working directory are copied, so -v /var/run/docker.sock:/var/run/docker.sock mounts the sandbox's own Docker socket. A symlink arrives as the link itself, and a path through a symlinked folder fails.
  • What containers wrote stays in the sandbox and never comes back to your computer, and a file you delete since the last copy is deleted in the sandbox.
  • When stdin is not a terminal and Docker reads it, as with -i on run or exec without -d, start -i, login --password-stdin, load, import -, build -, or cp -, the command streams stdin to Docker as it reads it, so echo "$TOKEN" | sandcovery-docker login ghcr.io --username me --password-stdin and sandcovery-docker load < app.tar work.
  • When stdout is not a terminal and Docker writes an archive there, as with save or export without -o, cp to -, or build -o -, the archive arrives byte for byte, so sandcovery-docker save app > app.tar works. save and export without -o refuse a terminal, as docker does.
  • A TCP or UDP port a container publishes answers on the same address and port of your computer, so after sandcovery-docker run -d -p 8080:80 nginx, http://localhost:8080 reaches nginx. Each UDP datagram arrives whole, and each answer goes back to the program whose datagram it answers, as with -p 5353:53/udp on your own Docker.
  • A container on the host network, from --network host or network_mode: host in Compose, answers on the same port of your computer for each TCP and UDP port it listens on, as it does on Docker on Linux.
  • A process that sandcovery-docker starts in the background forwards each port while a container publishes it or listens on it, until the sandbox ends. When another program on your computer already listens on that address and port, or only an administrator may listen on it, as Linux requires for ports below 1024, the command warns once and the port stays in the sandbox.
  • Docker gets a terminal in the sandbox wherever the command's own stdin, stdout, or stderr is one, so docker run -it, docker exec -it, and docker attach work as they do on your computer. A command runs until it exits or the sandbox reaches the end of its requested TTL, whichever comes first.

Docker Compose in a sandbox

sandcovery-docker compose runs Docker Compose in the same sandbox.

sandcovery-docker compose up --build --detach --wait
sandcovery-docker compose logs
sandcovery-docker compose down
  • compose copies its Compose files and env files and, for commands that build or start containers, each build context without what .dockerignore leaves out and each bind-mounted file or directory, at the same absolute paths. A build context such as ../shared and a Compose file in a parent directory resolve as they do on your computer.
  • ps, logs, down, and other commands that only read the project copy only the Compose files and env files.
  • A bind-mounted directory stays mounted while its files change. A container whose bind mount is a single file sees a changed file after it restarts.
  • Variables in Compose files come from your shell first, then from .env, --env-file, or COMPOSE_ENV_FILES, as with docker compose. The command sends the sandbox only the shell variables that the Compose files and env files name, including a bare environment or build.args entry and a secret's or config's environment.
  • A name given to -e or --env with no value on compose run or compose exec gets its value from your computer, and a name unset there stays unset in the container. compose run --env-from-file copies its file, and a name alone on a line there takes its value only from -e, as Compose reads it.
  • ~ in a Compose file names your home folder, as with docker compose, and the files there that the Compose files name are copied like the rest. Compose gets your HOME, while Docker's login and Buildx state stay the sandbox's.
  • compose up without --detach streams the containers' logs until you stop it or the sandbox reaches the end of its requested TTL, whichever comes first.

Where sandcovery-docker differs from docker

  • Paths outside your home folder and the working directory name files in the sandbox.
  • A container can't publish TCP port 9951 or listen on it on the host network, since Sandcovery uses it in the sandbox.
  • A port a container on the host network starts listening on answers on your computer up to about a second later, and only when it listens on every address, 127.0.0.1, or ::1.
  • On a provider that exposes no ports, which Sandcovery picks only when no provider that exposes ports can take the sandbox, published ports stay in the sandbox, and the first command says so.
  • DOCKER_TLS, DOCKER_TLS_VERIFY, and DOCKER_CERT_PATH keep the sandbox's values even when a command names one, since Docker turns TLS on for DOCKER_TLS_VERIFY or any --tlsverify, even --tlsverify=false, and reads its certificates from DOCKER_CERT_PATH, so no flag keeps the sandbox's TLS setting while the variable holds yours.
  • On build and compose, BUILDX_BUILDER and BUILDX_CONFIG keep the sandbox's values even when a command names one, since Buildx picks its builder and state folder from them with no global flag that outranks them. On compose, so does DOCKER_CONFIG, since Compose hands it to Buildx for a build.

Kubernetes in a sandbox

sandcovery-kubectl takes the same arguments as kubectl and runs your own kubectl against a one-node Kubernetes cluster in a sandbox, so a computer with no cluster can apply manifests, run pods, and reach them. It needs kubectl on your PATH, adds nothing to kubectl's stdout or stderr, and exits with kubectl's exit code, so it can stand in for kubectl:

alias kubectl=sandcovery-kubectl
kubectl apply --filename deployment.yaml
kubectl get pods
kubectl port-forward deployment/app 8080:80
  • It reads your key from SANDCOVERY_API_KEY, or the key sandcovery login keeps, and the API origin from SANDCOVERY_BASE_URL, and every argument goes to kubectl. An API error, such as a refused key, passes through unchanged.
  • The first command that reaches the cluster creates a 2x4 sandbox on Freestyle, or a 2x8 sandbox on boxd when Freestyle cannot create it, starts a k3s cluster in it, and waits until the cluster answers, which takes a few minutes.
  • Later commands reuse that cluster, so what you applied carries over between commands. It stops 15 minutes after the last command that reached it ends, or when its sandbox ends at its TTL, one hour unless your key sets a lower maximum, whichever comes first. A command that keeps running, such as port-forward or logs -f, keeps the cluster running. sandcovery sandboxes destroySandbox ends it sooner, and after any of these the next command starts a new, empty cluster.
  • A process sandcovery-kubectl starts in the background on your computer stops the cluster after 15 idle minutes. While your computer sleeps, it stops the cluster when your computer wakes, and if that process is stopped, the cluster runs until its TTL.
  • The cluster costs what its sandbox costs for as long as it runs, from its start until it stops. sandcovery sandboxes estimateCost --slug freestyle/2x4 --ttl_seconds 3600 prices the longest a cluster runs, one hour, on Freestyle, and --slug boxd/2x8 on boxd. Each refuses as a create would when your key can't create on that provider.
  • kubectl runs on your computer, so apply --filename reads your local files, port-forward listens on your computer's localhost, and exec -it, logs -f, and edit work as they do with a local cluster.
  • kubectl reaches the cluster through the sandbox's port URL with a token that the cluster checks on every request. It reads both from a kubeconfig sandcovery-kubectl keeps in ~/.config/sandcovery/kubeconfig, through KUBECONFIG.
  • completion, config, help, kustomize, options, plugin, version --client, and --help start no cluster, so source <(kubectl completion bash) in a startup file creates no sandbox.

Where sandcovery-kubectl differs from kubectl against a local cluster

  • A KUBECONFIG you set is not read, --kubeconfig runs against your own kubeconfig instead, and --context, --cluster, and --user know only the context sandcovery.
  • The cluster has one node, and it ends with everything on it 15 minutes after the last command or at its sandbox's TTL.
  • Pods pull their images in the sandbox, so an image that exists only in your computer's Docker is not found.
  • A NodePort or LoadBalancer service is reachable inside the sandbox, not from your computer, so reach a pod with port-forward.

T3 Code in a sandbox

sandcovery-t3 starts a sandbox, installs T3 Code there, and links it to T3 Code on your computer as an environment, so an agent in T3 Code can delegate work to that sandbox. Each command it runs in the sandbox finishes within 20 seconds, inside every provider's command limit, and the T3 Code install runs in the background there for up to 10 minutes. It needs t3 0.1.11 or later on your PATH and Linked environments turned on in T3 Code under Settings, Labs.

sandcovery-t3 --env "CLAUDE_CODE_OAUTH_TOKEN=$CLAUDE_CODE_OAUTH_TOKEN" --access full-access --ttl 7200
  • The sandbox gets the same version of T3 Code as your t3, and Claude Code where its image has none. T3 Code serves on port 3773 through the provider's URL for that port, behind a pairing code that works once, for 10 minutes. The command hands that code to t3 on stdin, so other users of your computer can't read it in ps.
  • Each --env reaches T3 Code and the agents it runs, not the sandbox create, so give the agents their login this way. claude setup-token makes a CLAUDE_CODE_OAUTH_TOKEN.
  • --access sets what agents on your computer may do there, as t3 environment link --access takes it. --provider names a provider to use, once for each, and --ttl sets the sandbox's TTL in seconds. It reads your key from SANDCOVERY_API_KEY, or the key sandcovery login keeps, and the API origin from SANDCOVERY_BASE_URL.
  • A provider whose port URL needs a header, carries a path or query, such as a signed token, or stops working before the sandbox ends can't serve T3 Code, so the command destroys that sandbox and fails. Pick another provider with --provider, or a shorter --ttl for a URL that expires. Any other failed step also destroys the sandbox.
  • The sandbox runs until its TTL. sandcovery sandboxes destroySandbox ends it sooner, and t3 environment unlink then removes the link on your computer.

Run commands in a sandbox

sandcovery-run runs a command in a sandbox that belongs to the folder you run it from, so a coding agent on your computer can run builds, tests, installs, and scripts there while it edits files on your computer. It streams the command's output, passes on stdin, and exits with the command's exit code:

npx -y -p sandcovery@latest sandcovery-run -- npm test
  • It runs inside a git repository or worktree, and anywhere else it stops with an error. The folder's sandbox belongs to its worktree, the top folder of the git worktree it is in. The first run in a worktree creates its sandbox, and later runs there reuse it. Each git worktree of a repository gets its own sandbox, and runs in different worktrees run in parallel.
  • Runs in one worktree wait for each other, from copying files in to copying them back, so each run sees the files the run before it left.
  • Before each run, the command sends the sandbox the worktree's files that changed since the last run, at the same absolute paths, and runs the command in the same working directory there. Where the sandbox's user is not root and has no sudo, the paths sit under that user's home folder instead. Those are the files git ls-files lists, tracked or untracked, without what .gitignore leaves out, and the same for each checked-out submodule. One upload takes up to 100 MiB packed, so the first run in a large worktree sends the most. A file you delete is deleted in the sandbox too.
  • After the command exits, the files it created, changed, or deleted in the worktree come back to your computer, except paths .gitignore leaves out, so lockfiles, generated code, and formatter output arrive while node_modules and build outputs stay in the sandbox for the next run. A file you changed on your computer during the run keeps your version, and the command says so. Nothing comes back outside the worktree, into .git, or through a symbolic link.
  • The command runs as root in the sandbox, through sudo where the sandbox's user is not root, or as that user where it has no sudo, in sh -c. A single argument runs as a shell script, as in sandcovery-run -- "npm ci && npm test", and several arguments run as one command, each passed as is.
  • It reads your key from SANDCOVERY_API_KEY, or the key sandcovery login keeps, and the API origin from SANDCOVERY_BASE_URL. With neither key, the first run signs this computer in through your browser, as sandcovery login does, once for all the runs that start together, and then runs the command.
  • The sandbox gets the default size, or the size Sandcovery offers instead when your keys can't run the default, and lasts one hour from its creation. A run starts only in a sandbox with at least 15 minutes left, and otherwise replaces it with a new one, so a command can run for at least 15 minutes and at most one hour.
  • sandcovery-run --status prints the worktree's sandbox and whether it runs, and sandcovery-run --stop destroys it and forgets it.

Every command the CLI has, and the SDK method and dashboard page that do the same, are in the REST API feature table.