Sometimes you want to know whether your tests pass on a clean machine, not on the laptop that has accumulated three years of global packages. Or you are about to run a test suite an agent changed and would rather it did not run next to your SSH keys. The Sandscale CLI has one command for this: sandscale sandbox run. It sends a folder to a fresh sandbox, runs a command there, streams the output and exits with the command’s exit code.
Everything below is from the sandscale sandbox reference, which is generated from the CLI itself.
Install and sign in
The CLI page lists the install options for macOS and Linux:
curl -fsSL https://sandscale.dev/install | sh
sandscale login
sandscale sandbox commands use your own Sandscale sign-in.
The basic run
From the top of your project:
sandscale sandbox run --sync . -- make test
Without --sandbox, the command starts a new sandbox, waits until it is running, runs your command and stops the sandbox afterwards. --sync . sends the current folder first, to /workspace unless --to says otherwise, and runs the command there. Everything after -- is the command.
To pick the machine, pass a template and options:
sandscale sandbox run --sync . --template python-3.12 -- pytest -q
Template names depend on what your organization has set up. sandscale sandbox start --options shows what you may start now. The same flags as sandscale sandbox start apply: --ttl, --network, --mem, --cpus and --label.
What gets sent, and what never does
This is the part worth reading before you point it at a real repository. Per the reference, --sync:
- leaves out whatever your
.gitignoreleaves out, plus what the CLI’s own ignore file at the top of the folder excludes; - leaves out
.git,node_modulesand symbolic links; - never sends secret or environment files:
.env*files, keys, credentials, cloud and registry tokens, and Terraform state. Those are listed by rule and path so you know they were skipped, and their contents are never shown.
Because node_modules is not sent, install dependencies as part of the command:
sandscale sandbox run --sync . -- sh -c "npm ci && npm test"
To see exactly what would go up without sending anything:
sandscale sandbox run --sync . --dry-run -- true
Run that once on any new project. If a file you expect is missing, check .gitignore. If a file you do not want sent is listed, add it to an ignore file.
Network for installs
A sandbox you start from the CLI takes a --network flag; the reference examples use --network none. A run that installs packages from a registry needs outbound access, which in Sandscale means your organization’s egress allowlist, where your plan includes it. If your plan or policy does not allow that, build a template with dependencies already in the image, or install from files you sync.
Use the exit code
run exits with the command’s own exit code, so it drops into scripts:
if sandscale sandbox run --sync . -- make test; then
echo "clean-machine tests passed"
else
echo "tests failed on a clean machine"
fi
The CLI’s own failures use other codes, listed on the reference page: 1 failed, 2 usage, 3 no session, 4 refused, 5 not found, 6 conflict, 7 rate limited. A command inside the sandbox can also exit 1 or 2, so a nonzero code alone does not tell you whether the tests failed or the CLI did; the streamed output does.
--timeout SECONDS limits how long the command may run. Ctrl+C cancels the run.
Keep the box when something fails
By default the sandbox is stopped after the run, and stopping a sandbox deletes its disk. To look around after a failure, add --keep:
sandscale sandbox run --sync . --keep -- make test
Then, with the sandbox id from the output:
sandscale sandbox connect sbx_9 # a terminal in the sandbox
sandscale sandbox logs sbx_9 # its runs
sandscale sandbox files get sbx_9 /workspace/test-results.xml --out ./results.xml
sandscale sandbox stop sbx_9 # when you are done
connect needs Sandscale to offer a terminal in sandboxes. sbx_9 here is the placeholder id the reference uses; yours will differ.
Run again in the same sandbox
Starting fresh every time is the point of a clean run, but while iterating you can reuse one sandbox:
sandscale sandbox start --template python-3.12 --ttl 1h
sandscale sandbox run --sandbox sbx_9 --sync . -- pytest -q
With --sandbox, the CLI uses that sandbox and leaves it running. --ttl on start sets how long it may live, within your plan. Stop it when you finish.
In CI and agent loops
The same command works in a CI job: install the CLI, give it a Sandscale sign-in (see the CLI reference for the options), and run sandscale sandbox run --sync . -- <your test command>. The job’s exit status follows the tests.
For agents, the CLI is one option. If the agent already speaks MCP, the Sandscale MCP server gives it sandbox tools directly. If you are writing the agent loop yourself, the TypeScript SDK’s sandboxes.run returns the exit code, output, and whether the command timed out or ran out of memory.
Cost
Each run uses awake vCPU-hours from your plan while the sandbox is running: 100 a month on Free, 1,500 on Pro and 2,000 per member pooled on Team. Runs without --keep stop the sandbox when they finish, so nothing is left counting. See plans and limits.