DEV Community

Sandscale
Sandscale

Posted on Edited on Originally published at sandscale.dev

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

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, 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 create a sandbox with the CLI and run those commands there with sandscale sandbox run, so they execute in a sandbox, its own Firecracker microVM, and the agent still reads the output in its terminal.

Sources, read in November 2026: Cursor's Rules documentation and the help text of Sandscale CLI 1.3.0 (sandscale help sandbox <command>), which is the source of truth for the flags below.

What the CLI gives the agent

Four commands cover a test run:

sandscale sandbox create --template-id builtin:python --ttl-seconds 3600 --yes
sandscale sandbox file-write --id SANDBOX_ID --path /workspace/test_example.py --content BASE64 --yes
sandscale sandbox run SANDBOX_ID --workdir /workspace --yes -- python3 -m pytest -q
sandscale sandbox terminate --id SANDBOX_ID --yes
Enter fullscreen mode Exit fullscreen mode

create returns the sandbox id. run executes the command in that sandbox, streams the output, and exits 0 when the command exited 0 and 1 when it exited otherwise, timed out or was killed, with the command's own exit code printed on standard error. That is what makes it work for an agent: Cursor sees the output and the pass or fail it would see locally. terminate ends the sandbox for good and its /workspace goes with it.

State-changing commands ask before they send and need --yes when there is no terminal, which is the case for an agent's shell.

1. Install and sign in once

curl -fsSL https://sandscale.dev/install | sh
sandscale login
sandscale sandbox launch-options
Enter fullscreen mode Exit fullscreen mode

launch-options shows what you may start now, including template names. The built-ins are builtin:base, builtin:go, builtin:minimal, builtin:node and builtin:python. Pick the one that matches the project.

2. Decide how files get in

The agent has two ways to put files in a sandbox. file-write writes one file at a time, with the bytes as base64. For a whole folder, the server takes a gzip-compressed tar archive (sandscale sandbox instances-project); Getting code into a sandbox and results out walks through it. The CLI help does not describe the body of that command, so this post does not give a one-line folder upload for the rule.

What an archive upload leaves out is worth knowing before the agent does it. Per the command's help, files your .gitignore files ignore are left out, and so is a platform deny-list that cannot be overridden: .env files, private keys, cloud credentials, .git and more. Links, devices and pipes are left out and reported. There is no dry run, so check your .gitignore once per repository.

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:

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

- Run dependency installs, test suites and project build scripts in a Sandscale sandbox, not directly.
- Once per task, create a sandbox and remember its id:
  `sandscale sandbox create --template-id builtin:node --ttl-seconds 3600 --yes`
  (use builtin:python for Python projects).
- Put the files you need in it with `sandscale sandbox file-write --id ID --path /workspace/<file> --content <base64> --yes`.
  For a whole project, ask me before uploading it.
- Run commands in that sandbox, installing dependencies in the same command:
  `sandscale sandbox run ID --yes "npm ci && npm test"`
- The run's exit code is 0 when the command passed and 1 when it failed. Read the streamed output to tell a test
  failure from a CLI error. CLI errors use these codes: 2 usage, 3 not signed in, 4 refused, 5 not found,
  6 conflict or precondition, 7 rate limited, 8 plan or usage limit, 9 unavailable now.
- If exit code 3 appears, stop and ask me to run `sandscale login`. Never try to sign in yourself.
- If a run fails, leave the sandbox running and tell me its id. Otherwise end it with
  `sandscale sandbox terminate --id ID --yes` when the task is done.
- Do not put API keys, tokens or .env contents on the command line.
- Plain file reads, git commands and formatters can run locally.
Enter fullscreen mode Exit fullscreen mode

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 create takes --network none|allowlist, with none as the default. allowlist reaches only your organization's egress allowlist and the package registry presets. 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. Look at a failed run

The rule tells the agent to leave the sandbox running when a run fails. You can then look yourself, with the id it reports:

sandscale sandbox runs-list --id SANDBOX_ID
sandscale sandbox file-read --id SANDBOX_ID --path /workspace/test-results.xml
sandscale sandbox terminal SANDBOX_ID
sandscale sandbox terminate --id SANDBOX_ID --yes
Enter fullscreen mode Exit fullscreen mode

runs-list shows the commands run in the sandbox with their status and exit codes, file-read returns a file's content as base64, and terminal opens an interactive shell in your own terminal. Terminate the sandbox when you are done; it also ends by itself when --ttl-seconds runs out.

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. The agent creates a sandbox, puts files in, runs commands and terminates it, and sees normal terminal output.
  • The MCP server 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 create a sandbox with sandscale sandbox create, run tests with sandscale sandbox run SANDBOX_ID <command> and end it with sandscale sandbox terminate. The command runs in a Sandscale sandbox, and the output and pass or fail come back to Cursor's terminal.

Does a project upload send my .env file?

No. Per the help for sandscale sandbox instances-project, .env files, private keys, cloud credentials and .git are on a platform deny-list that is left out and cannot be overridden, along with whatever your .gitignore files ignore.

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

Originally published on the Sandscale blog.

Top comments (0)