Dev.to AI 🤖 Ai 👁 0 📖 6 min read

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

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

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, 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, options reference, linting and testing, installation and API keys pages, and Sandscale's workspaces guide and 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

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:

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:

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:

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.

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.

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:

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:

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

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, 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 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

Runnable examples: sandscale/agent-quickstart.

Originally published on the Sandscale blog.

📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.