Run an AI coding agent in a sandbox
An AI coding agent runs commands on your machine. Dial can run them inside the operating system's sandbox, so they write only to your project and can't read your SSH keys or cloud credentials. It is off by default; this guide turns it on.
Turn it on
Add this to ~/.dial/config.toml:
[sandbox]
mode = "dev" Dial uses sandbox-exec on macOS and bubblewrap on Linux and WSL2, so on Linux install bubblewrap first:
sudo apt-get install -y bubblewrapThe sandbox fails closed: if it is turned on but missing, Dial refuses to run shell commands rather than running them unprotected.
Modes
off(the default): commands run unconfined, with your user's permissions.dev: commands can read most of the machine but never~/.ssh,~/.aws, cloud and keychain folders, credential files such as~/.netrcor~/.npmrc, or Dial's own state. They write only to the project, plus any folders you list inextra_write, and secret-looking environment variables are dropped.strict: the workspace only, with no network.
Tools that write outside the project, like a package manager's cache, need that folder listed:
[sandbox]
mode = "dev"
extra_write = ["~/.cargo", "~/.npm"] Git metadata stays read-only inside the sandbox on macOS and Linux: commands can run git status, git diff and git log, but can't change hooks, config, refs or the index. Dial's own git tool commits and switches branches, and asks for approval first.
On Windows, dev runs commands, PowerShell included, at Low integrity, so they can write only the project; it doesn't confine reads or network. See Windows security for the stricter AppContainer options.
Network rules
Cut commands off from the network, or allow only the hosts they need:
[sandbox]
mode = "dev"
allow_network = true
network_allow = ["crates.io", "*.crates.io", "github.com"]
network_deny = ["pastebin.com"]example.com matches exactly, and *.example.com matches its subdomains but not the domain itself. allow_network = false blocks command traffic entirely. Domain rules aren't available on Windows.
Git guard
Separately from the sandbox, Dial's git guard refuses git commands that would throw away uncommitted work, such as git reset --hard, git clean -f, git checkout . and git stash. Forms that keep your work, like git reset --soft or git clean -n, run normally.
By default (shell.git_guard = "workers") it covers helper agents that edit your live checkout. "always" applies it to every command and "off" turns it off.
What it doesn't do
- It is not a security boundary against a determined local attacker, and macOS's
sandbox-execis deprecated by Apple. - It confines commands, not your decisions: approval modes and undo still matter.
The full rules are in dial's tool documentation and shell documentation.