Agent-by-Agent VM Strategy for Engineering Teams Running Claude Code or Codex at Scale
Isolated VMs, scoped credentials, and PRs make parallel coding agents safe.

To run Claude Code in the cloud at engineering-team scale, give each agent an isolated execution environment, task-scoped credentials, and a pull request as its output. Managed cloud agents provide that isolation without requiring teams to manage hosts. For self-managed execution, one VM per agent makes parallel work an infrastructure design.
Why coding agents break down when they share infrastructure
Agents compete for more than files on disk. Cloning a large repository, running a test suite, and iterating on a build consume CPU and memory for sustained periods. On a shared host, one agent’s workload degrades the others. That contention makes execution less predictable even when agents are working on unrelated code. A slow or failed run can therefore reflect resource pressure.
Agent behavior depends on the toolchain, dependencies, and context available when work begins, but another agent can modify that environment mid-run. Git worktrees separate working directories and branches while sharing an object store, yet they leave databases, ports, and external services exposed to runtime contention. Code separation is not execution separation.
The same ambiguity undermines cost and security governance. When agents run under one machine identity, the host provides no task-specific boundary for auditing access, scoping credentials, or attributing compute spend. A failure also has no clear limit to its blast radius. Shared infrastructure is therefore not a minor inconvenience that teams can tolerate while adding agents. It prevents parallelism from working as intended.
How to run Claude Code in the cloud with one-VM-per-agent isolation
One VM per agent establishes an explicit execution boundary. Each agent gets its own filesystem, process space, network identity, and credential store, so a runaway process or local environment change remains within that VM. Those boundaries must be enforced deliberately in self-managed infrastructure. They do not appear merely because each agent has a different terminal or working directory. Shared external services still require separate controls.
Claude Code on the web runs each session in an isolated VM on Anthropic-managed infrastructure. Sessions can begin at claude.ai/code or through claude --cloud, and claude --teleport brings a cloud session into a local terminal. Codex cloud instead runs each task in an isolated, OpenAI-managed container preloaded with the repository. As of August 2026, its agent phase runs with internet access off by default.
The common primitive is isolation. Managed execution supplies the boundary without host administration, while self-managed VMs give teams responsibility for enforcing it. Anthropic’s host requirements include Ubuntu 20.04+, Debian 10+, or Alpine 3.19+, x64 or ARM64, and at least 4 GB RAM. Those requirements establish compatibility, but the repository’s workload determines the resources needed for useful execution.
Provisioning a VM that is sized correctly for agent work
For self-managed execution, start with the build workload. A configuration of 2 vCPUs and 4 GB RAM handles the agent and a lightweight toolchain. If the repository requires a heavy npm or cargo build, or a development server runs with the agent, 8 GB is the comfortable floor. The model client is only part of the load. Whether the VM can reliably finish the task depends on the builds, tests, and other processes it has to run.
On a 4 GB machine, a 4 GB swapfile provides a useful safety net. A build that needs a lot of memory can slow down and keep running instead of being killed, which helps when an agent compiles changes over and over. Swap does not replace adequate RAM. Its role is to soften temporary pressure rather than justify undersizing a consistently heavy workload.
Ubuntu 24.04 LTS is a practical default because it satisfies Anthropic’s minimum and has packages for a typical agent setup. ARM instances usually cost less, and Claude Code has ARM64 builds. For Codex cloud, OpenAI manages the host, so instance architecture is not a team decision. The sizing decision belongs where execution is managed.
Hardening the VM before any agent touches it
An isolated VM still holds sensitive assets and access. Its repository checkout, Claude and GitHub credentials, generated artifacts, and network position can all be available to the agent. Hardening must therefore address what the agent can read, change, and reach. Moving the work off a laptop alone does not limit what the agent can do. Relaxed access controls merely relocate the exposure.
Before agent execution, use non-root accounts, SSH key authentication with password logins disabled, a firewall restricted to SSH, and unattended security upgrades. Where people access the host, use one Unix user per person. Separate home directories keep Claude credentials, GitHub authentication, shell environments, and tmux servers apart. A shared development account erases those distinctions. Keep only the secrets required for the task, with permissions narrower than unrestricted access to every repository and branch.
Network controls require a separate decision from login controls. A mesh VPN such as Tailscale can remove SSH from the public internet so that only enrolled devices can reach it. That limits inbound access and leaves agent egress unchanged. Codex’s default-offline agent phase prevents network exfiltration and unexpected package downloads during that phase because it has no network access. Teams seeking equivalent guarantees on self-managed VMs need explicit outbound firewall rules, rather than assuming that VM isolation also implies network isolation.
Keeping agent sessions alive and observable across the VM lifecycle
Session persistence must survive a developer’s disconnect. For interactive self-managed work, start the agent inside tmux so it continues after the terminal detaches or the user logs out. Reattaching restores access to the running session without restarting the task. This supports long refactors, overnight migrations, and handoffs in which a colleague observes ongoing work. It does not remove the need to keep the VM running.
Persistence also needs an observable completion state. Teams can watch Claude Code cloud sessions through the Claude mobile app and use --teleport to steer the work from a local terminal. Codex exposes session logs and accepts revision requests after completion. Self-managed teams must supply their own equivalent visibility. Structured logging to a central store or a webhook fired when the session ends gives operations an answer beyond an unattended terminal.
Headless execution changes the lifecycle mechanism. Claude Code’s -p flag, also available as --print or API mode, supports scheduled work and alert-triggered runs without a person at the keyboard. A process supervisor replaces tmux in that mode. Teams need an explicit answer for starting, disconnecting, resuming, and completing work, whether the task is interactive or automated. A cloud host is useful only if execution remains durable and its outcome can be found.
Running agents in parallel without letting them collide
VM isolation makes independent execution possible, but coordination remains. The N-version delegation pattern sends the same specification to several agents using different models or decomposition strategies, producing candidate implementations for review. This is a practical parallelism pattern for everyday engineering work. It keeps the comparison at the pull-request level rather than asking agents to edit the same working directory. The team still has to judge the alternatives.
Each agent needs a branch and working directory of its own. Git worktrees provide a private index and branch while sharing an object store, but they do not remove merge conflicts at review time. Nor do they isolate runtime dependencies. Agents running integration tests need their own database instances or test-scoped fixtures. VM separation alone cannot protect a service deliberately shared across those VMs.
Anthropic’s guidance reserves multi-agent coordination for work that exceeds one context window, requires different tool access or behavioral constraints, contains genuinely parallel parts where elapsed time is important, or benefits from independent critique. Otherwise, a single well-configured agent is cheaper and more predictable. Parallel capacity is not itself a reason to use it. The topology enables concurrency, and depending on task decomposition, that concurrency saves time or adds coordination overhead.
Credential handling across a fleet of agent VMs
Parallel execution multiplies the places where credentials can leak. A fleet with manually distributed GitHub tokens, API keys, and database credentials can retain the same over-permissioned secret across many machines without a central revocation path. The fleet needs a credential strategy that governs distribution, scope, expiry, and auditability together.
Inject secrets at VM startup from a central secret manager rather than embedding them in images or distributing them manually. Each VM should receive only what its task requires, scoped to the repository and duration. Prefer short-lived credentials where available. A GitHub App installation token that expires after an hour and is limited to one repository has a smaller blast radius than a broadly privileged personal access token left in a session environment.
Keep model API keys and GitHub or GitLab credentials in different secret namespaces, with independent rotation schedules. The model key belongs to the team’s own account and subscription. Record which agent used which credential, when it used it, and what it pushed. For enterprise teams, SOC 2, SCIM, and self-hosting belong among infrastructure requirements, with self-hosted Claude Code environments available to Team and Enterprise organizations that need code and credentials on their servers.
Connecting agent VMs to the tools where engineering work already happens
Agent execution should begin from the systems engineers already use, including Slack mentions, assigned GitHub or GitLab issues, Linear tags, monitoring webhooks, and scheduled triggers. Each entry point can start a VM and provide its task context. A separate dashboard should not become a prerequisite for delegation.
Linear’s coding agent illustrates this integration pattern. It gathers evidence from Sentry or Datadog through MCP, traces the root cause, and produces a fix before an issue reaches an engineer. Linear reports resolving a meaningful share of incoming bug reports this way, mostly on the first pass. The useful distinction is the continuity of context. Evidence gathering and code changes remain attached to the issue.
That connectivity must fit the network policy already established. An integration-enabled VM needs access to GitHub or GitLab APIs, webhook payloads or a polled queue, and credentials scoped to its integrations. Those requirements differ from a deliberately offline agent phase. Within CI/CD, an invocation such as codex exec can pre-screen reviews, generate tests, update documentation, and handle routine fixes on pull requests. Caching is especially useful there because the same repository context is reused repeatedly, while results stay inside the existing review process.
Making every agent run end in a reviewable pull request
The pull request is the human control point. It lets reviewers check, test, approve, or reject the agent’s work without going into the execution environment. Unlike a file diff, it provides a named branch, CI/CD pipeline, comment thread, approval workflow, branch protections, and audit trail. Those controls apply to agent-generated changes just as they apply to human-generated changes. Every implementation run should return through that boundary.
Human approval must remain effective after delegation. Copilot’s coding agent requires approval before CI/CD workflows run on its draft pull requests, and the same requirement should apply to other agent-generated pull requests. An isolated execution environment does not justify bypassing the merge gate. Claude Code’s auto-fix option can watch a pull request once it is open and act on CI failures and review comments in an Anthropic-managed cloud VM. That allows iteration without moving review outside the established workflow.
The pull request also gives governance a concrete unit. Teams can use the changes delivered to track compute cost, audit what agents did, and judge the work they produced, rather than count sessions started or tokens consumed. Isolated VMs, workload-sized provisioning, scoped credentials, parallel execution, and integrated triggers all serve this outcome. Their sophistication should be invisible to the reviewer. What reaches that reviewer is a pull request clear enough to inspect and credible enough to review seriously.


