Cloud Infrastructure
Cloudflare Worker Previews Gives Coding Agents Isolated Test Environments Per Git Branch
Each Git branch now gets its own production-like sandbox with stable URLs and independent state, enabling rapid testing cycles for AI-driven code changes without risking live systems.
InfoQ
Cloudflare has announced Worker Previews, a new capability that spins up isolated, production-mirroring environments for Workers on a per-branch basis. The feature is designed to support agent-driven development, where coding agents generate large volumes of changes that require rapid, safe testing before reaching production.
How Previews Work#
Worker Previews creates a distinct sandbox for each Git branch using a stable URL and its own configuration, secrets, and state. Developers trigger a preview with npx wrangler preview, and hundreds of previews can run in parallel under the same Worker without interfering with production traffic or one another.
Each preview environment includes:
- Isolated Durable Objects: New storage namespaces and Container instances prevent failed migrations or schema changes from affecting live data
- Scoped configuration: Teams define a base setup in Wrangler's previews block, with each branch able to override individual settings (database, API keys, storage buckets) independently
- Observability: Logs, errors, metrics, and request traces are captured exclusively for that preview, removing the noise of production traffic
The State Management Challenge#
The technical cornerstone involves handling persistent state. Durable Objects use a singleton model where one instance manages storage for a given ID—a shared namespace between preview and production would corrupt live instances. Cloudflare's solution creates a separate Durable Object namespace and Container app per preview, isolating any schema migrations or failed deployments to that branch alone.
Supporting Agent-Driven Workflows#
The feature fits within what Cloudflare frames as the Agent Development Lifecycle. Coding agents benefit from a tightly integrated feedback loop where each change is atomic, independently deployable, fully observable, and revisable. Previews can also be exposed via custom domains (e.g., feature-login.previews.example.com) to replicate production behavior for cookies, CORS, and OAuth, and can be gated behind Cloudflare Access.
Cloudflare describes an integrated agent loop combining Browser Run, Playwright MCP, and Workers Observability: an agent opens the preview in a headless browser, steps through a user flow, captures screenshots or sessions, traces failed requests, patches the code, redeploys, and verifies the fix.

