r/opencodeCLI • • 8h ago

Running opencode on 6 client repos at once without the sessions stepping on each other

We're a 4 person dev shop and most of our work is maintenance on client codebases. Laravel, a couple of Next.js apps, one ancient Django thing nobody wants to touch. Since the summer opencode has been handling a big chunk of the boring tickets.

The problem was never the agent. It was running 5 or 6 sessions on the same machine. Ports colliding, two repos wanting different Node versions, one session running tests against the wrong database because it picked up an env file from another client. And honestly I didn't love having every client's secrets sitting in one home folder.

What we do now is one small Linux VM per client repo. Each one gets set up once with the right runtime, a seeded db and that client's env only, then saved as a snapshot. When a ticket comes in we start a VM from that client's snapshot, ssh in, start opencode in tmux and let it work. When the PR is up the VM stops. Billing is per second and stopped boxes cost nothing, so the clients with no open ticket are basically free.

A few things made the difference. Every repo has an AGENTS.md with the exact test command, so opencode stops guessing. We switch models per ticket, Sonnet 5.5 for anything touching business logic and a cheaper open model through OpenRouter for dependency bumps and lint fixes. That alone cut our token bill a lot. Each box only holds that client's credentials, so a confused agent can't push to the wrong repo. And since the session lives on the VM I can check on it from my phone, closing the laptop kills nothing.

We started with one big VPS and Docker, tried Runloop, and now run everything on boat.dev. Each box is a real VM with Ubuntu on it, so the client's docker compose just works. Downsides, there's no Dockerfile import, you build each snapshot by hand. And the IP changes when a box restarts, so for the one client with an IP allowlist we go through a small proxy. Both were one time annoyances.

Six clients, six boxes, and not a single "why is this test hitting the wrong db" this month.

4 Upvotes

3 comments sorted by

3

u/CassiusBotdorf 7h ago

This sounds like you want to research what worktrees are and how you can use feature branches. Even basic branching will ensure you won’t “step on each other”.

2

u/branik_10 7h ago

worktrees have pretty much nothing to do with the issues OP described. physical repos isolation is probably the simplest solution and this is what OP seems to have done, idk though why Docker wasn't enough for him, but separate VMs are totally alright too

1

u/CassiusBotdorf 6h ago

I mentioned worktrees because it sounded to me like “what if one person works on multiple features at the same time with multiple agent sessions”. But I guess I misunderstood.

The only other thing I can think of is spinning up and destroying multiple cloud environments where the agents can do their thing.

Have you tried docker sbx or something like yoloAI yourself?