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 loginSign 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 insandcovery/credentials.jsonunderXDG_CONFIG_HOMEwhen that is set, readable only by you.sandcovery,sandcovery-docker,sandcovery-kubectl,sandcovery-run, andsandcovery-t3all 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 onand 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 logoutrevokes the key and deletes it from the computer.sandcovery loginon 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 keysandcovery loginkeeps, as the key, and callsSANDCOVERY_BASE_URLwhen it is set, orhttps://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.shsends the text@run.sh. An operation whose body is a file, such assandboxes uploadFile, reads that body from stdin. --helpworks 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 logindoes. - Arguments after
--go tossh: options such as-Lforward 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
sshexits. The agent's host key is new each time too, so the command keeps it out of yourknown_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 keysandcovery loginkeeps, and the API origin fromSANDCOVERY_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 destroySandboxends 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
buildandbakewithout what.dockerignoreleaves out, the files of a build's-f,--build-context, and--secret, the bind mount sources and env files ofrunandcreate, the env files ofexec, the files thatBUILDX_BAKE_FILEandEXPERIMENTAL_BUILDKIT_SOURCE_POLICYname, and the file thatcp,load -i, orimportreads. - The variables Docker reads come from your computer's environment, as with
docker: a name given to-eor--envwith no value onrun,create, orexec, a name alone on a line of their--env-file, a name given tobuild --build-argwith no value, and the variable an env--secretofbuildreads. 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, andCOMPOSE_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, orHTTP_PROXY, is sent only when a command names it, as with-e DOCKER_HOSTor--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 sendsDOCKER_HOSTorDOCKER_CONTEXT, Docker gets-Hor--contextnaming the sandbox's daemon, and when it sendsDOCKER_CONFIG, Docker gets--confignaming 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.sockmounts 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
-ionrunorexecwithout-d,start -i,login --password-stdin,load,import -,build -, orcp -, the command streams stdin to Docker as it reads it, soecho "$TOKEN" | sandcovery-docker login ghcr.io --username me --password-stdinandsandcovery-docker load < app.tarwork. - When stdout is not a terminal and Docker writes an archive there, as with
saveorexportwithout-o,cpto-, orbuild -o -, the archive arrives byte for byte, sosandcovery-docker save app > app.tarworks.saveandexportwithout-orefuse a terminal, asdockerdoes. - 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:8080reaches nginx. Each UDP datagram arrives whole, and each answer goes back to the program whose datagram it answers, as with-p 5353:53/udpon your own Docker. - A container on the host network, from
--network hostornetwork_mode: hostin 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-dockerstarts 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, anddocker attachwork 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 downcomposecopies its Compose files and env files and, for commands that build or start containers, each build context without what.dockerignoreleaves out and each bind-mounted file or directory, at the same absolute paths. A build context such as../sharedand 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, orCOMPOSE_ENV_FILES, as withdocker compose. The command sends the sandbox only the shell variables that the Compose files and env files name, including a bareenvironmentorbuild.argsentry and a secret's or config'senvironment. - A name given to
-eor--envwith no value oncompose runorcompose execgets its value from your computer, and a name unset there stays unset in the container.compose run --env-from-filecopies 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 withdocker compose, and the files there that the Compose files name are copied like the rest. Compose gets yourHOME, while Docker's login and Buildx state stay the sandbox's.compose upwithout--detachstreams 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, andDOCKER_CERT_PATHkeep the sandbox's values even when a command names one, since Docker turns TLS on forDOCKER_TLS_VERIFYor any--tlsverify, even--tlsverify=false, and reads its certificates fromDOCKER_CERT_PATH, so no flag keeps the sandbox's TLS setting while the variable holds yours.- On
buildandcompose,BUILDX_BUILDERandBUILDX_CONFIGkeep 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. Oncompose, so doesDOCKER_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 keysandcovery loginkeeps, and the API origin fromSANDCOVERY_BASE_URL, and every argument goes tokubectl. 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-forwardorlogs -f, keeps the cluster running.sandcovery sandboxes destroySandboxends it sooner, and after any of these the next command starts a new, empty cluster. - A process
sandcovery-kubectlstarts 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 3600prices the longest a cluster runs, one hour, on Freestyle, and--slug boxd/2x8on boxd. Each refuses as a create would when your key can't create on that provider. kubectlruns on your computer, soapply --filenamereads your local files,port-forwardlistens on your computer'slocalhost, andexec -it,logs -f, andeditwork as they do with a local cluster.kubectlreaches the cluster through the sandbox's port URL with a token that the cluster checks on every request. It reads both from a kubeconfigsandcovery-kubectlkeeps in~/.config/sandcovery/kubeconfig, throughKUBECONFIG.completion,config,help,kustomize,options,plugin,version --client, and--helpstart no cluster, sosource <(kubectl completion bash)in a startup file creates no sandbox.
Where sandcovery-kubectl differs from kubectl against a local cluster
- A
KUBECONFIGyou set is not read,--kubeconfigruns against your own kubeconfig instead, and--context,--cluster, and--userknow only the contextsandcovery. - 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
NodePortorLoadBalancerservice is reachable inside the sandbox, not from your computer, so reach a pod withport-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 tot3on stdin, so other users of your computer can't read it inps. - Each
--envreaches T3 Code and the agents it runs, not the sandbox create, so give the agents their login this way.claude setup-tokenmakes aCLAUDE_CODE_OAUTH_TOKEN. --accesssets what agents on your computer may do there, ast3 environment link --accesstakes it.--providernames a provider to use, once for each, and--ttlsets the sandbox's TTL in seconds. It reads your key fromSANDCOVERY_API_KEY, or the keysandcovery loginkeeps, and the API origin fromSANDCOVERY_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--ttlfor a URL that expires. Any other failed step also destroys the sandbox. - The sandbox runs until its TTL.
sandcovery sandboxes destroySandboxends it sooner, andt3 environment unlinkthen 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 filesgit ls-fileslists, tracked or untracked, without what.gitignoreleaves 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
.gitignoreleaves out, so lockfiles, generated code, and formatter output arrive whilenode_modulesand 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
sudowhere the sandbox's user is not root, or as that user where it has nosudo, insh -c. A single argument runs as a shell script, as insandcovery-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 keysandcovery loginkeeps, and the API origin fromSANDCOVERY_BASE_URL. With neither key, the first run signs this computer in through your browser, assandcovery logindoes, 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 --statusprints the worktree's sandbox and whether it runs, andsandcovery-run --stopdestroys 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.