# A Cursor project rule that sends installs and tests to a Sandscale sandbox

> Use a .cursor/rules file (or AGENTS.md) so Cursor's agent runs dependency installs and test suites with sandscale sandbox run instead of on your laptop. What the rule can and cannot enforce, and how to check what gets sent.

Use a .cursor/rules file (or AGENTS.md) so Cursor's agent runs dependency installs and test suites with sandscale sandbox run instead of on your laptop. What the rule can and cannot enforce, and how to check what gets sent.

November 28, 2026 · 6 min read · The Sandscale team

Cursor’s agent runs terminal commands in your project, on your machine. Most of the time that is what you want. The commands that make people nervous are a small, predictable set: `npm install` in a repository you just cloned, a `pip install -r requirements.txt` from a pull request, a test suite whose setup scripts you have not read. Those are the ones worth moving to a separate machine.

There are two ways to do that with Sandscale. One is the [Sandscale MCP server](https://sandscale.dev/blog/sandscale-mcp-server-in-cursor), which gives the agent sandbox tools. This post covers the other, which needs no MCP setup at all: a project rule that tells Cursor’s agent to run those commands through `sandscale sandbox run`, so they execute in a fresh [sandbox](https://sandscale.dev/sandboxes), its own Firecracker microVM, and the agent still reads the output in its terminal.

Sources, read in November 2026: Cursor’s [Rules documentation](https://cursor.com/docs/context/rules) and Sandscale’s [CLI reference](https://sandscale.dev/docs/reference/cli/sandbox).

## What sandscale sandbox run does

```sh
sandscale sandbox run --sync . -- npm test
```

Per the reference: without `--sandbox`, it starts a sandbox, waits until it runs, sends the folder (to `/workspace` unless `--to` says otherwise), runs the command there, streams the output, stops the sandbox afterwards and exits with the command’s own exit code. That last part is what makes it work for an agent: Cursor sees the same output and the same pass or fail it would see locally.

What `--sync` sends matters more here than usual, because the agent is the one typing. It leaves out what `.gitignore` leaves out, `.git`, `node_modules` and symbolic links, and it never sends secret or environment files: `.env*`, keys, credentials, cloud and registry tokens and Terraform state are listed by rule and path, never shown. `--dry-run` lists what would be sent and sends nothing.

## 1. Install and sign in once

```sh
curl -fsSL https://sandscale.dev/install | sh
sandscale login
sandscale sandbox start --options
```

`start --options` shows what you may start now, including template names. Pick a template that matches the project, for example `python-3.12` if your organization has it.

## 2. Check what would be sent

Before the agent ever runs it, run this yourself in the project:

```sh
sandscale sandbox run --sync . --dry-run -- true
```

If something you want is missing, check `.gitignore`. If something is listed that you would rather not send, add it to an ignore file. Do this once per repository; the agent will not.

## 3. Write the rule

Project rules live in `.cursor/rules/` as `.mdc` files with front matter. Cursor’s docs are explicit that a plain `.md` file in that folder is ignored. Create `.cursor/rules/sandbox-runs.mdc`:

```md
---
description: Running dependency installs, test suites and build scripts
alwaysApply: false
---

- Run dependency installs, test suites and project build scripts with the Sandscale CLI, not directly:
  `sandscale sandbox run --sync . -- sh -c "<install> && <command>"`
- node_modules and other ignored folders are not sent, so install dependencies inside the same command,
  for example `sandscale sandbox run --sync . -- sh -c "npm ci && npm test"`.
- The command's exit code is the run's exit code. Read the streamed output to tell a test failure from a CLI error.
  CLI errors use these codes: 2 usage, 3 no session, 4 refused, 5 not found, 6 conflict, 7 rate limited.
- If exit code 3 appears, stop and ask me to run `sandscale login`. Never try to sign in yourself.
- Do not put API keys, tokens or .env contents on the command line.
- Plain file reads, git commands and formatters can run locally.
```

With `alwaysApply: false` and a description, Cursor’s docs say the agent reads the description and pulls the rule in when it is relevant. If you want it on every chat in this project, set `alwaysApply: true` instead. If you would rather not use `.mdc` front matter, the same bullet points work in an `AGENTS.md` at the project root, which Cursor also reads.

Commit the rule. There is no secret in it, and each teammate’s runs use their own `sandscale login`.

## 4. Network for installs

Installs need to reach a package registry. A sandbox gets the network your plan and your organization’s policy allow, and in Sandscale outbound access goes through your organization’s egress allowlist where your plan includes it. If installs fail with network errors inside the sandbox, that is the place to look, not the rule. If your policy gives sandboxes no network, use a template with dependencies already in the image.

## 5. Keep the sandbox when a run fails

By default the sandbox is stopped after the run, and stopping a sandbox deletes its disk. For a failure you want to look at, add a line to the rule telling the agent to rerun with `--keep` and report the sandbox id, then inspect it yourself:

```sh
sandscale sandbox logs sbx_9
sandscale sandbox files get sbx_9 /workspace/test-results.xml --out ./results.xml
sandscale sandbox stop sbx_9
```

`sbx_9` is the placeholder id the reference uses; yours will differ. Stop kept sandboxes when you are done.

## What a rule can and cannot do

Be honest with yourself about this layer. A rule is text at the start of the model’s context. It makes the agent much more likely to route installs and tests through the sandbox, but it does not stop the agent from running `npm install` locally if it decides to. The controls that actually hold are elsewhere:

- **Cursor’s terminal approval settings** decide whether a terminal command runs without asking. If you approve commands one by one, the rule saves you from rewriting them; if you auto-run, review what your allowlist lets through.
- **Sandscale’s side** decides what a sandbox may do: the network your plan and policy allow, and the templates and sizes members may use.

The rule’s job is to make the safe path the default one. It is not a fence.

## Rule or MCP server?

- **This rule** needs only the CLI and works with any agent that runs terminal commands. Each command is a fresh sandbox, synced from your folder, and the agent sees normal terminal output.
- **The [MCP server](https://sandscale.dev/blog/sandscale-mcp-server-in-cursor)** gives the agent explicit tools to create a sandbox, run several commands in it, move single files in and out, and stop it. Each call shows up in Cursor’s approval prompt with its arguments.

They combine fine. Many teams will want the rule for “install and test” and the MCP server for longer, multi-step work in one sandbox.

Note that hosted Cursor Cloud Agents run on Cursor’s machines, not yours, so a rule that calls your locally signed-in CLI applies to the agent in your editor.

## FAQ

### How do I make Cursor run tests somewhere other than my laptop?

Add a project rule in `.cursor/rules/` that tells the agent to run tests with `sandscale sandbox run --sync . -- <command>`. The command runs in a fresh Sandscale sandbox, and the output and exit code come back to Cursor’s terminal.

### Does sandscale sandbox run upload my .env file?

No. Per the CLI reference, `--sync` never sends secret or environment files such as `.env*`, keys, credentials, cloud and registry tokens or Terraform state. It lists them by rule and path without showing them. Run with `--dry-run` to see exactly what would be sent.

### Is a Cursor rule a security boundary?

No. A rule guides the agent; it does not prevent other commands. Use Cursor’s approval settings and Sandscale’s network and policy controls for the parts that must hold.

## Related

- [Connecting Cursor to the Sandscale MCP server](https://sandscale.dev/blog/sandscale-mcp-server-in-cursor)
- [How to run tests in a sandbox with the Sandscale CLI](https://sandscale.dev/blog/how-to-run-tests-in-a-sandbox-with-the-sandscale-cli)
- [Scripting the Sandscale CLI: exit codes and JSON](https://sandscale.dev/blog/scripting-the-sandscale-cli-exit-codes-and-json)

**On this page**

1. What sandscale sandbox run does
2. 1. Install and sign in once
3. 2. Check what would be sent
4. 3. Write the rule
5. 4. Network for installs
6. 5. Keep the sandbox when a run fails
7. What a rule can and cannot do
8. Rule or MCP server?
9. FAQ
10. Related

**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 28, 2026 · **A Codex workspace that keeps your hours: schedules, time zones and overnight codex exec runs** · Set a Sandscale workspace to start with your workday in Tokyo, Taipei or Singapore, keep Codex's config in your dotfiles, and leave a codex exec run going in tmux overnight. Every command is from the CLI reference.](https://sandscale.dev/blog/codex-workspace-on-your-time-zone)
- [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)

---
Source: https://sandscale.dev/blog/cursor-rule-run-tests-in-a-sandbox
