Picture a team of 20 developers that ran happily on one shared staging environment for years. A few dozen pull requests a week, and an unwritten rule in the team channel: say something before you deploy to staging. Then the team rolled out coding agents. Pull request volume roughly doubled within a quarter, and staging quietly became the slowest part of the pipeline.
Variations of that story are showing up everywhere. Claude Code, Codex and Cursor can help teams open pull requests faster than before, and every one of those changes has to run somewhere before it merges. Most pre-merge infrastructure was sized for people. It was never sized for this.
This article looks at why shared staging fails under agent-driven volume, what an agent actually needs from a test environment, and how to move to per-pull-request environments without drowning in platform work.
Why Shared Staging Breaks Under Agent Volume
Shared staging was always a compromise. It worked because humans coordinate socially: they wait their turn, ask who deployed last, and roll back each other’s mistakes over chat. Agents don’t naturally coordinate in the same way. Four problems show up fast.
It becomes a queue. One environment means one change under test at a time, or several changes tangled together. Either the agents wait, which wastes the speed you adopted them for, or they deploy on top of each other.
Nobody can tell who broke it. When three changes land in staging and the end-to-end suite fails, someone has to work out which change caused it. A human can usually guess from context. An agent reading a red test run may lack that context, so it either retries blindly or fixes something that wasn’t broken.
It drifts. Long-lived environments collect manual hotfixes, half-applied migrations and stale data. Tests pass in staging and fail in production, or the reverse. The more changes flow through, the faster the drift.
It costs money around the clock. Staging can run at full size on nights and weekends, whether anyone is testing or not.
Google’s DORA research has linked higher AI adoption with lower software delivery stability. There are many possible causes, but one is easy to see on the ground: teams have widened the top of the funnel without widening the narrow path that verifies changes before they ship.
What an Agent Needs From a Test Environment
An agent’s feedback loop ends where its environment ends. If it can only run unit tests, it is guessing about how the change behaves against a real database, a real queue and the services around it. To close that loop, the environment has to meet a few requirements that human-oriented staging environments have not always needed to prioritize.
- Self-service creation. The agent should be able to get an environment without a ticket or a person in the loop.
- Real dependencies. A reachable URL backed by real, non-production instances of the database, cache and neighboring services, not mocks.
- Machine-readable feedback. Build logs, container status and test output the agent can read and act on.
- Isolation. One agent’s broken migration should never block another agent, or a human.
- A short loop. Push, deploy, test, read results and fix in minutes, not hours.
- Guardrails. Scoped credentials, no production data, and an audit trail of what ran where.
None of these are new ideas. Platform teams have wanted most of them for human developers for years. Agents just remove the option of living without them.
The Per-Pull-Request Environment Pattern
The pattern that meets those requirements goes by several names: ephemeral environments, preview environments, PR environments. The idea is the same. Every pull request gets its own short-lived, full-stack copy of the application, and that copy disappears when the work is done.
The lifecycle looks like this:
- A developer or an agent opens a pull request.
- The platform builds an isolated environment from the application’s own definition, with all its services and a fresh copy of seed data.
- CI runs the integration and end-to-end suites against it. The agent runs its own checks. Reviewers, QA and product get a link to click through the change.
- Results post back to the pull request, where both people and agents read them.
- If the change needs work, the next commit triggers an update or rebuild of the environment.
- On merge or close, the environment is destroyed.
Each step answers one of the staging problems. Isolation simplifies attribution, because changes can be tested independently. Building fresh from the definition reduces configuration drift. Teardown, plus scaling idle environments to zero, reduces always-on infrastructure costs. And because the agent has its own environment, it can iterate several times before a human ever looks at the pull request.
Making It Work in Practice
The concept is simple. The details are where teams stall. These are the ones worth settling early.
Start from the definition you already have. Most teams already describe their stack somewhere: a Docker Compose file for local development, a Helm chart for Kubernetes. Build environments from that, not from a hand-maintained copy. If the definition the environment uses drifts from the one production uses, the environment will lie to you.
Treat data as a first-class problem. An empty database proves very little. Use seed scripts or sanitized snapshots, give every environment its own fresh copy, and never point a preview at raw production data. Agents can run destructive tests without hesitation, which is exactly what you want, as long as the blast radius is one disposable copy.
Contain third-party dependencies at the edge. Payment providers, email services and external APIs should get sandbox credentials or stubs. Everything you own should run for real where practical.
Put hard limits on cost. Scale idle environments to zero, set time-to-live limits, cap how many environments can run at once, and tear down on merge or close. Then check for orphans. Agents can open a lot of pull requests on a busy day, and a forgotten environment is still a bill.
Lock down access. Preview URLs should sit behind SSO, secrets should be injected rather than committed, and every environment should leave an audit trail. Role-based access matters more once non-human actors are creating infrastructure.
Give agents a real interface. A web dashboard is fine for people. Agents need an API, a CLI or an MCP server so they can create an environment, read its logs and run tests without anyone copying output into a chat window. MCP in particular is becoming a common way for coding agents to call external tools.
Report results where review happens. Post environment links, build status and test results on the pull request itself. Humans and agents should look in the same place.
Build It or Buy It
Teams with platform capacity can build this themselves. A common approach is a Kubernetes namespace per pull request, created by the CI pipeline and deployed with Helm, or Argo CD’s ApplicationSet pull request generator, which creates an application for each open pull request. Depending on existing infrastructure and platform maturity, getting a first environment running may be relatively straightforward.
The long tail is what costs time: wildcard DNS and TLS, data seeding, secrets, orphan cleanup, cost controls, access control, and now an agent-facing interface. Each piece is small. Together they add up to a product someone has to maintain.
Managed platforms can take much of that work off the platform team. Shipyard, for example, builds a full-stack environment for each pull request from a Docker Compose file, scales idle environments to zero, tears them down on merge, and lets coding agents create environments, read logs and run tests through an MCP server and CLI.
Whichever way you go, a few questions separate the options:
- Where do environments run: in your cloud account, or the vendor’s?
- What application definition does it need, and how close is that to what you run in production?
- How are data and secrets handled for each environment?
- Can an agent drive the full loop through an API, CLI or MCP server?
- What mechanisms ensure teardown, and how are orphans found?
- How does pricing behave when pull request volume doubles?
Where to Start
Don’t try to convert every service at once. Pick the one where staging contention hurts most, get per-pull-request environments working for human developers first, and wire your end-to-end suite into them. Once that loop is reliable, give an agent access and let it run the whole cycle on a low-risk change.
Measure a handful of things before and after: time from pull request opened to first integration test result, hours spent waiting on staging, how often merged changes need rework, and environment cost per pull request. Those numbers make the case to finance and leadership better than any architecture diagram.
Coding agents changed how fast code gets written. The teams that get real value from them will be the ones that also change how fast code gets proven. Shared staging alone may no longer be enough. A disposable environment per change can help close that gap.

