The problem
Parallel agents on one database step on each other. Some services should belong to one instance and be free to wreck, others are one shared dev database.
A service without scope is isolated, with one container per instance on a network of its own. scope = "global" makes one container shared by every sandbox that lists it. Both answer to the service’s name.
Config
devsandboxes.toml
[services.postgres]
image = "postgres:16"
scope = "global" # one for the whole config root
env = { POSTGRES_PASSWORD = "postgres" }
ports = ["127.0.0.1:5432:5432"] # optional: reach it from the host
[services.redis]
image = "redis:7" # no scope: one per instance
[template.base]
image = "node:22"
services = ["postgres", "redis"]
containerEnv = { DATABASE_URL = "postgres://postgres:postgres@postgres:5432/postgres", REDIS_URL = "redis://redis:6379" }
[sandbox.api]
extends = "base"
folder = "../api"
[sandbox.web]
extends = "base"
folder = "../web"Try it
TERMINAL
devsandbox run api # starts postgres, then api with its own redis
devsandbox run api --name fix-login # its own redis, the same postgres
devsandbox run web
devsandbox service lsHow it works
- Isolated services follow their instance through
stop,startandrm. Give them no hostports, since a second instance would collide. Usedevsandbox portinstead. - A global service keeps running for the others.
devsandbox gcremoves it once no instance uses it. devsandbox service rebuild postgresapplies config changes and rewires running sandboxes in place. The data lives in the container, so keep a way to re-seed.
Agent instructions
Paste it into Claude Code, Codex or any agent with a shell. It finds your repo and config itself and asks only what it can't tell. Agent skills (opens in a new tab)
Source: site/src/content/examples/services.mdxEdit this page on GitHub(opens in a new tab)