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 run those commands through sandscale sandbox run, so they execute in a fresh 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 Sandscale’s CLI reference.
What sandscale sandbox run does
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
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:
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:
---
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:
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 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.