← Back to Blog

Container Use for Locally Sandboxed, Background Agents in Zed

July 30th, 2025


While most haven't attained god-like 10x developer powers with AI coding agents, many of us are experimenting and navigating the tradeoffs. In some cases you want an agent to work directly on your local files, typically in the foreground as a synchronous AI "co-pilot". The Zed Agent Panel and built-in tools provide everything you need for that.

Other times, you want your agents to work on a problem async in the background. You definitely don't want the background agents interfering with your foreground work, especially if all of your agents are working on the same code base (e.g., your monorepo). Besides having a set of agents work in parallel on different parts of the codebase, you might want a parallel-capable model like Claude 4 to produce three different possible solutions from a single prompt. Ideally you want it all.

But to get those agents working in parallel typically means managing different directories with clones of your repo, or wrestling with git stash. You might have discovered the wonders of git worktree, which allows you to have parallel git histories, but then you're still running untrusted, AI-generated code on your local machine without an isolated sandbox. Containers seem like the right technology for isolation, but how should you integrate them with Git Worktrees for a complete solution that covers all of your use cases (and has a great DX)? That's likely more than you signed up for.

Still, ideally you want it all – the Zed foreground agent experience AND isolated background parallel agents. Turns out you can have it all with Zed + Container Use.

What is Container Use?

An overview of Container Use
An overview of Container Use

Container Use is an open source project, with a simple DX, that gives coding agents their own containerized sandbox environments by orchestrating:

  • Containers for isolation from your system, terminal access, service tunneling (provided by Dagger)
  • Git Worktrees for parallel git histories that can be easily merged

How does Container Use work?

With Zed configured for Container Use (via MCP), when you kick off an agent task, a new environment with a random name will be created with a Dagger container for isolation (ubuntu with tools like git and curl by default, but you can customize this) and a Git worktree managed by Container Use. You can have as many environments as you like and see them all with container-use list.

You can also use the container-use CLI to check in on the progress of your agents through commands like container-use watch, container-use log <env name>, and container-use diff <env name>.

Since Dagger containers have native support for ephemeral services and terminal debugging, it's easy to ask for a url to connect to a service running in an environment via the prompt – you'll get a tunnel from localhost to the sandbox container, plus you can run container-use terminal <env name> to be dropped into an interactive terminal session to poke around and run commands.

How to set up Container Use with Zed in an optimal way

The Container Use docs will help you get up and running, either by using the new Zed Extension for Container Use or manual configuration. Beyond that, the most important thing to set up to get the best of foreground and background agents is Zed's Agent Panel Custom Profiles.

These user-configured profiles go beyond the built in Write, Ask, and Minimal profiles in the Agent Panel. I suggest two: foreground and container-use (or if you like, background).

→ The foreground profile has ALL of the built-in Zed tools set to active.

Foreground profile
Foreground profile

→ The container-use profile has NONE of the built-in tools activated and only Container Use tools set to active.

Container Use profile
Container Use profile

The beauty of this system is that now your foreground and background agents won't collide. You can switch to the container-use profile and kick off a background parallel agent experiment (maybe asking for three new UI designs), then switch to the foreground profile and interactively edit some tricky server logic with agent support.

Even if you take your eyes off Zed and are doing some research in your web browser, you'll get a lovely notification from Zed when your background Agents' tasks are complete.

I'd also suggest using the Zed Rules Library together with your Custom Profiles. That way you can customize your Container Use rules and include them for background tasks.

Zed Rules Library
Zed Rules Library

What next?

Whether you want to go full manual in the foreground with agents in the background, go full-agentic, or somewhere in between, Container Use can fit into your Zed agent workflow. To get started, try out the quickstart and the Zed setup in the Container Use docs. Or check out the video demo.

And be sure to share your successes and suggestions with us in the #container-use channel in the Dagger Discord server. See you soon!