# Running Aider in scripted mode on a cloud workspace: --message-file, --test-cmd and what to check afterwards

> Run Aider non-interactively inside a Sandscale workspace, a persistent Firecracker microVM: install, API keys, --message-file with --yes-always, --test-cmd with --auto-test, how Aider commits, and reviewing the result from your own terminal.

Run Aider non-interactively inside a Sandscale workspace, a persistent Firecracker microVM: install, API keys, --message-file with --yes-always, --test-cmd with --auto-test, how Aider commits, and reviewing the result from your own terminal.

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

**Short answer:** Aider can run one instruction and exit, which makes it easy to script. The catch is that a scripted run answers yes to its own prompts and edits and commits in the repository it is pointed at. Run that on a [workspace](https://sandscale.dev/workspaces), a persistent Firecracker microVM with its own kernel and disk, and the repository, the API key and the commits all live there instead of on your laptop. `sandscale workspace ssh NAME -- COMMAND` starts the run from your own terminal.

Sources, read in November 2026: Aider’s [scripting](https://aider.chat/docs/scripting.html), [options reference](https://aider.chat/docs/config/options.html), [linting and testing](https://aider.chat/docs/usage/lint-test.html), [installation](https://aider.chat/docs/install.html) and [API keys](https://aider.chat/docs/config/api-keys.html) pages, and Sandscale’s [workspaces guide](https://sandscale.dev/docs/guides/workspaces) and [pricing](https://sandscale.dev/pricing) page.

## What a scripted Aider run does

Per Aider’s scripting page, `--message` (or `-m`) sends one natural-language instruction, applies the edits to the files and exits. `--message-file` (`-f`) does the same with the instruction read from a file, which is easier to keep in version control than a long shell string. Both disable chat mode.

Two other options from Aider’s reference matter for unattended use:

- `--yes-always` answers yes to every confirmation.
- Auto-commit is on by default (`--auto-commits`), so each accepted change becomes a git commit. `--no-auto-commits` turns that off.

Put those together and a scripted run is a process that edits files and writes commits without asking. That is the point of scripting it, and it is also the reason to give it a repository you can throw away.

## 1. Create a workspace and install Aider

```sh
sandscale login
sandscale workspace templates-list
sandscale workspace create --name aider-box --template-id TEMPLATE_ID --yes
sandscale workspace ssh aider-box
```

`TEMPLATE_ID` is an id from `templates-list` (commands checked against the help text of CLI 1.3.0). Inside the workspace, install Aider the way its install page describes. If a suitable Python is present:

```sh
python -m pip install aider-install
aider-install
```

Aider’s page also lists a one-line installer for Mac and Linux, `curl -LsSf https://aider.chat/install.sh | sh`, which installs Python 3.12 if it is needed. Either way the workspace needs network access to download Aider and, later, to reach your model provider. Network follows your plan and your organization’s policy, so check that yours allows both. Then clone your repository. The disk persists, so you do this once.

For the key, Aider reads provider keys such as `OPENAI_API_KEY` or `ANTHROPIC_API_KEY` from environment variables or from a `.env` file in the git root (its default for `--env-file`). Set the model with `AIDER_MODEL` or `--model`. Keep a `.env` file out of the repository.

## 2. Run one instruction and exit

Write the task down once:

```sh
mkdir -p ~/tasks
cat > ~/tasks/docstrings.md <<'TASK'
Add a short docstring to every public function in the files you are given.
Do not change any behaviour. Do not touch tests.
TASK
```

Then run it on a branch, so the work never lands on your main line by itself:

```sh
cd ~/src/my-service
git switch -c aider/docstrings
aider --yes-always --no-suggest-shell-commands \
  --message-file ~/tasks/docstrings.md \
  src/service/handlers.py
```

Aider’s reference lists `--no-suggest-shell-commands` (suggesting shell commands is on by default). In a run where every confirmation is answered for you, nobody reads a suggested command, so we turn the suggestions off. The files on the command line are the ones Aider is allowed to edit. Aider’s scripting page loops the same call over many files with a plain `for` loop, which works here too.

## 3. Let the tests gate the change

Aider can run your tests itself. From its linting and testing page: `--test-cmd` sets the command, `--auto-test` runs it after each change, and a failing run (the command prints the errors and exits non-zero) makes Aider try to fix them. The command is run without arguments.

```sh
aider --yes-always --no-suggest-shell-commands \
  --test-cmd "pytest -q" --auto-test \
  --message-file ~/tasks/fix-flaky-parser.md \
  src/service/parser.py
```

There is also `--test`, which the options reference describes as “run tests, fix problems found and then exit”. With `--test-cmd` set, that gives you a CI-style job: run the suite, let Aider try to repair what fails, stop.

```sh
aider --yes-always --test-cmd "pytest -q" --test
```

Aider’s page also covers `--lint-cmd` for linters and notes that formatters which exit non-zero when they change files can confuse it, so wrap those in a script that runs twice.

## 4. Read what it did before you trust it

Because Aider commits as it goes, git is your record. From inside the workspace:

```sh
git log --oneline main..HEAD
git diff main --stat
```

Replace `main` with your default branch if it has another name.

Aider’s defaults add attribution: `--attribute-co-authored-by` is on by default, so its commits carry a `Co-authored-by` trailer, and you can use that to find them later. Do not treat a clean exit as a verdict. The documentation describes what each option does, not an exit-code contract for a whole run, so decide success by the diff and by running the tests yourself.

## 5. Start it from your laptop

`sandscale workspace ssh` runs everything after `--` on the workspace, with a short-lived certificate and a checked host key:

```sh
sandscale workspace ssh aider-box -- 'cd ~/src/my-service && git switch -c aider/docstrings && aider --yes-always --no-suggest-shell-commands --message-file ~/tasks/docstrings.md src/service/handlers.py'
```

The words after `--` are joined with spaces, as with ssh itself, so quote the remote command as one string. If the workspace is stopped, start it first with `sandscale workspace start --ws-id WORKSPACE_ID --yes`. For a run that should outlive your SSH session, start it inside `tmux` on the workspace (install it if the template does not have it) and detach. The workspaces docs say a workspace sleeps when nobody is using it and do not say whether a background process counts as use, so check how yours behaves before leaving a long run unattended.

## 6. Stop it when the run is done

```sh
sandscale workspace update --ws-id WORKSPACE_ID --ttl-seconds 28800 --yes
sandscale workspace stop --ws-id WORKSPACE_ID --yes
```

The first stops the workspace 8 hours after each start; the second stops it now. Stopping keeps the disk, so the repository, Aider and the commits are there next time. Per the [pricing page](https://sandscale.dev/pricing), a box counts toward your awake vCPU-hours for the whole time it runs, busy or idle, so stopping when the job is finished matters.

## What a workspace does and does not change

A workspace keeps Aider’s edits, commits and your key off your laptop and inside a microVM with its own kernel. It does not make the model’s output correct, and it does not stop Aider from doing something unwanted inside the repository you gave it, which is why the branch and the review step above are not optional. If you would rather keep Aider on your laptop and send only installs and test runs to a sandbox, see [adding the Sandscale MCP server to Codex](https://sandscale.dev/blog/sandscale-mcp-server-in-codex) for the pattern with a different agent.

## FAQ

### Which Aider option runs one instruction and exits?

`--message` (`-m`) for a string and `--message-file` (`-f`) for a file. Both process the reply and exit, and both disable chat mode.

### How do I stop Aider asking for confirmation?

Pass `--yes-always`, which answers yes to every confirmation. Because it also confirms things you did not think about, run it on a branch in a throwaway clone.

### Can Aider run my tests after each edit?

Yes. Set `--test-cmd` and add `--auto-test`. Aider expects the command to print errors and exit non-zero on failure, and it tries to fix failures. `--test` runs the tests, tries to fix problems and exits.

### Does Aider commit its changes?

By default, yes: `--auto-commits` is on. Pass `--no-auto-commits` if you want to review uncommitted changes instead.

### Does the workspace keep Aider and my clone?

Yes. A workspace keeps its disk when it stops. Deleting it with `sandscale workspace delete` deletes its disks.

## Related

- [A sandbox for Codex: running codex exec in a cloud workspace](https://sandscale.dev/blog/codex-exec-in-a-cloud-workspace)
- [A sandbox for Claude Code: running it headless in a cloud workspace](https://sandscale.dev/blog/claude-code-headless-in-a-cloud-workspace)
- [Gemini CLI in a sandbox: headless runs in a cloud workspace](https://sandscale.dev/blog/gemini-cli-headless-in-a-cloud-workspace)
- [A checklist for reviewing a pull request an AI agent wrote](https://sandscale.dev/blog/reviewing-an-agent-diff-checklist)

**On this page**

1. What a scripted Aider run does
2. 1. Create a workspace and install Aider
3. 2. Run one instruction and exit
4. 3. Let the tests gate the change
5. 4. Read what it did before you trust it
6. 5. Start it from your laptop
7. 6. Stop it when the run is done
8. What a workspace does and does not change
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 29, 2026 · **Browser-free test runs for coding agents: a fast tier to run on every edit, and a browser tier to leave for CI** · How to split a project's tests so a coding agent's loop never needs a real browser: node and DOM-emulated tests first, browser end-to-end tests last. Vitest projects, jsdom and happy-dom limits, pytest markers, Node's test runner, Playwright tags and go test -short, plus how to make a filtered run fail loudly instead of passing by running nothing.](https://sandscale.dev/blog/browser-free-test-runs-for-coding-agents)
- [November 29, 2026 · **Connecting Cline to a remote MCP sandbox: streamableHttp, OAuth sign-in and what autoApprove should list** · Add the remote Sandscale MCP server to Cline so its installs and test runs can go to a Firecracker microVM instead of your machine. The cline_mcp_settings.json entry, sign-in, which tools to auto-approve, a rule that points Cline at the sandbox, and what Cline's settings cannot enforce.](https://sandscale.dev/blog/cline-with-a-remote-mcp-sandbox)

---
Source: https://sandscale.dev/blog/aider-scripted-runs-in-a-cloud-workspace
