# How to run your test suite in a clean microVM with sandscale sandbox run

> Use the Sandscale CLI to send a project folder to a fresh sandbox, run its tests there and get the exit code back: what gets sent and what never does, dry runs, keeping the box for debugging, and using it in scripts and CI.

Use the Sandscale CLI to send a project folder to a fresh sandbox, run its tests there and get the exit code back: what gets sent and what never does, dry runs, keeping the box for debugging, and using it in scripts and CI.

November 27, 2026 · 4 min read · The Sandscale team

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](https://sandscale.dev/docs/reference/cli/sandbox), which is generated from the CLI itself.

## Install and sign in

The [CLI page](https://sandscale.dev/cli) lists the install options for macOS and Linux:

```bash
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:

```bash
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:

```bash
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 `.gitignore` leaves out, plus what the CLI’s own ignore file at the top of the folder excludes;
- leaves out `.git`, `node_modules` and 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:

```bash
sandscale sandbox run --sync . -- sh -c "npm ci && npm test"
```

To see exactly what would go up without sending anything:

```bash
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:

```bash
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`:

```bash
sandscale sandbox run --sync . --keep -- make test
```

Then, with the sandbox id from the output:

```bash
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](https://sandscale.dev/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:

```bash
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](https://sandscale.dev/docs/reference/cli) 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](https://sandscale.dev/blog/remote-vs-local-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](https://sandscale.dev/docs/reference/plans).

**On this page**

1. Install and sign in
2. The basic run
3. What gets sent, and what never does
4. Network for installs
5. Use the exit code
6. Keep the box when something fails
7. Run again in the same sandbox
8. In CI and agent loops
9. Cost

**Run your agents in a box of their own**

Each sandbox is a Firecracker microVM. Free includes 100 awake vCPU-hours a month.

[Start free](https://cloud.sandscale.dev/auth/signup)

## Keep reading

- [November 27, 2026 · **A LlamaIndex.TS data agent that runs its Python in a Sandscale sandbox** · Use LlamaIndex.TS's agent workflow with tools that write and run Python in a Firecracker sandbox, built per sandbox so a run can only reach its own box. Upload data files, answer with the numbers, clean up. Type-checked.](https://sandscale.dev/blog/llamaindex-ts-agent-with-sandscale)
- [November 27, 2026 · **A sandbox for Claude Code: running it headless in a cloud workspace** · Run Claude Code with claude -p inside a Sandscale workspace, a persistent Firecracker microVM, so its Bash tool works on a cloud disk instead of your laptop. Setup, permission flags and what stays where.](https://sandscale.dev/blog/claude-code-headless-in-a-cloud-workspace)

---
Source: https://sandscale.dev/blog/how-to-run-tests-in-a-sandbox-with-the-sandscale-cli
