Parallel environments
A developer working on three branches at once, often with an AI agent on each, wants three copies of the environment running simultaneously. Alzo gives every Git worktree its own instance: its own ports, hostnames, containers, networks and volumes, with nothing to coordinate by hand.
~/acme → default api.example.dev ports 20000–20099
~/acme-feature-x → instance 1 api-k3m9x2qp.example.dev ports 20100–20199
~/acme-fix-auth → instance 2 api-7b2e4f19.example.dev ports 20200–20299Everyday development has the commands for creating, moving and removing worktrees.
What identifies an instance
An instance belongs to its checkout, not to its branch: changing branch, or detaching HEAD, keeps the same environment and data. Outside Git, the configuration's directory is the checkout. A new checkout created at a reused path gets its own data. To move a checkout on the same filesystem, stop its instance, move it, and run alzo rebind from the new path, with the same --instance selector if you used one. A copy, or a move to another filesystem, gets a fresh environment.
--instance <name> adds a further named environment within one checkout, for example to keep a review environment beside your own.
Ports
Each instance claims a 100-port block. Service offsets within a block are shared by worktrees of the same workspace, and a remembered block is reused whenever it is free. If it is occupied, Alzo reports the old block, the new block and the conflict. Allocations can differ between machines, so read current endpoints from alzo status --json rather than writing them down. alzo instances lists stopped reservations, and orphan cleanup can release their ports while keeping their named volumes.
Hostnames
The hostname label is random, not your branch name, and the default worktree has none — api.example.dev is the stable one you would register with an OAuth provider. Randomness lets one *.example.dev TLS wildcard cover every instance, and avoids disclosing branch names or creating collisions between similar ones. It is not authentication, and the hostname is not a secret. Public exposure must be explicit, and the application or ingress must enforce any authorisation it needs; a webhook must use its provider's signature or another explicit credential rather than rely on an unguessable hostname. alzo instances maps labels back to branches, and the dashboard shows the branch, so you never have to read the label to know where you are.
No shared scope
Every node is per-instance. There is no shared scope, and that is a deliberate trade: three worktrees means three Postgres containers.
The alternative — one Postgres process shared by every worktree, with a database each — was designed and removed. Sharing a live service couples worktrees in ways the configuration cannot express: one worktree's migration alters the schema another is running against, alzo down has to be reference-counted so it does not kill a neighbour, and one crash fails every worktree at once. That is reference counting, ownership transfer and cross-instance teardown ordering, bought to save some memory.
Sharing a service on purpose
When you genuinely do want to share something, point at it explicitly:
const db = defineService({
name: 'db',
ports: { pg: 5432 },
// Not ours. Something else runs it, and every worktree talks to it.
provision: { adopt: { host: '127.0.0.1', port: { pg: 5432 } } },
outputs: ({ hostname, port }) => ({
connectionString: (u: { database: string }) => `postgres://${hostname}:${port.pg}/${u.database}`,
}),
});
const api = defineService({
name: 'api',
run: 'pnpm dev',
// The server is shared, so the database name still carries the worktree.
env: () => ({ DATABASE_URL: db.outputs.connectionString({ database: `acme_${instance.slug}` }) }),
});adopt is visible in review. A scope keyword whose consequences reach into teardown ordering would not be. instance also carries the worktree's name, branch, path and isDefault flag, which the dashboard can display.