Guide · Aider
Is Aider safe? How do I run Aider in a sandbox?
Updated
Aider edits files in your repository and, by default, commits each change to git, so /undo can take back its last commit. It also runs shell commands: the ones you give with /run and /test, a lint command after each edit (tests too, if you turn them on), and commands it suggests, which is on by default. Git undoes file edits, not what a command did to the rest of the machine, so run Aider in a container or virtual machine that has only the project folder and a limited network.
01Steps
Start from a clean commit. Keep auto-commits on (the default). Aider also commits your own uncommitted changes before it edits, keeping them separate from its edits;
--no-dirty-commitsturns that off.git add -A && git commit -m "before aider"Turn off what you do not need.
--no-suggest-shell-commandsstops Aider proposing shell commands. Avoid--yes-always, which answers yes to every confirmation.aider --no-suggest-shell-commandsRun it in a container. Aider publishes Docker images. The container sees the folder you mount at
/app. Aider's docs note that/runthen runs inside the container, and that the container lacks your global git config, so setuser.nameanduser.emailin the repository.docker run -it --user $(id -u):$(id -g) --volume $(pwd):/app paulgauthier/aider --openai-api-key $OPENAI_API_KEYOr run it in a VM with a kit you write. kosa8 has no built-in Aider kit, and this one has not been separately tested. It gives Aider one folder, reaches only PyPI by name, and keeps your OpenAI key on your computer: the sandbox gets a placeholder and the egress broker adds the real key for
api.openai.com.name: aider description: Aider with one project folder and a brokered OpenAI key image: python:3.12 setup: - python -m pip install aider-chat command: [aider] egress_allow: - pypi.org - files.pythonhosted.org credentials: - name: openai upstream: https://api.openai.com secret: OPENAI_API_KEY header: Authorization scheme: "Bearer " env: OPENAI_API_BASE: "{{url}}/v1" OPENAI_API_KEY: "{{placeholder}}" cpus: 2 mem_mb: 4096
Read the plan, then run it. kosa8 refuses a kit whose setup runs an unpinned
pip installunless you pass--allow-unpinned; pin a version you have reviewed in the setup line.--dry-runprints what the sandbox may see and reach without starting it. Flags go before the kit file.curl -fsSL https://kosa8.com/install.sh | sh export OPENAI_API_KEY=sk-… kosa8 agent run --dry-run --allow-unpinned -w ~/code/api ./aider.yaml kosa8 agent run --allow-unpinned --keep --name aider -w ~/code/api ./aider.yaml
Checkpoint the machine before a risky step. From another terminal, save the whole sandbox, then rewind if a command breaks it. The shared folder is not rolled back, which is what Aider's git commits are for.
kosa8 checkpoint aider --label "before migration" kosa8 rewind aider
02Is Aider safe to run on my own machine?
Aider runs with your user account's permissions, so any shell command it runs can read or change anything you can. Its edits are committed to git, but a command it runs, a test suite or a package install acts on your machine directly.
By default it lints files it edits, suggests shell commands and offers to add URLs it finds to the chat. Each is useful; each is also a way for text in a repository or web page to influence what runs. A container or VM limits that to the folder and hosts you chose.
03Is Aider's git auto-commit enough to undo what it did?
It undoes file edits in the repository and nothing else. /undo undoes the last git commit if Aider made it. Git does not restore packages a command installed, files outside the repository, ignored files such as .env, database contents or processes left running.
A whole-machine checkpoint covers the rest inside a sandbox: disk, memory and running processes. See how to undo what an AI coding agent did.
04What does the closed network add?
It decides where a command can send your code. In the kit above, the sandbox reaches PyPI and the model API through the broker, by name, and every other request is refused before it leaves your computer and written to the audit log.
Read refusals with kosa8 audit ls. If Aider needs another host, add it to egress_allow deliberately rather than opening the network.
05Other options
- Aider's own Docker images.
paulgauthier/aiderandpaulgauthier/aider-full; the simplest container route. - Docker or Docker Sandboxes with
--network noneplus a local model, for work that should not reach the internet. - gVisor or Kata Containers. A stronger boundary under the same container workflow on Linux.
- A full VM in UTM or Lima. A long-lived development machine with Aider installed in it.
- Cloud sandboxes such as E2B, Daytona or Modal. Fit when you want the work off your machine entirely.