The Localhost Cloud: Inside Coasts
How a Rust daemon uses Git worktrees and socket proxies to build the isolated sandboxes necessary for parallel AI coding agents.

Worktrees create a git-linked copy of your code so multiple agents can work in isolation. The problem is that AGENTS NEED RUNTIMES.
- AI coding agents parallelize work using Git worktrees, which isolates code but causes fatal collisions over shared local ports and databases.
- Coasts solves this infrastructure bottleneck by treating the Git worktree as the fundamental boundary for full-stack isolation.
- Instead of slowly rebuilding Docker networks on branch changes, Coasts achieves millisecond context switching by hot-swapping socat proxies.
- The system relies on a Rust daemon to orchestrate Docker-in-Docker sandboxes, ensuring rogue agent code cannot pollute the host machine.
The Localhost Traffic Jam
Autonomous coding agents are breaking local development. Tools like Claude Code and Cursor are designed to handle multiple tasks in parallel. To do this safely, they check out different Git branches into isolated directories using Git worktrees. This keeps the source code separate. However, the underlying runtime infrastructure remains completely shared.
When two agents attempt to boot a web application simultaneously, they crash into each other. They fight over port 8080. They corrupt shared local database states. They overwrite environment variables in the single running Docker Compose network.
The Worktree as the Infrastructure Boundary
Coasts introduces a fundamental shift in the local development mental model. It reads the output of the native Git command and automatically provisions an entirely isolated environment for every branch. The project introduces the Coastfile as the blueprint for these parallel worlds.
By tying isolated Docker runtimes directly to Git worktrees, developers and agents can spin up five versions of a complex application simultaneously without conflicts.
| Feature | Git Worktrees | Docker Compose | Coasts |
|---|---|---|---|
| Primary Role | Code Isolation | Service Orchestration | Full Stack Isolation |
| Port Management | Manual | Manual (YAML) | Automatic Dynamic/Canonical |
| Database State | Shared | Shared (usually) | Isolated Logical Databases |
| Multi-Agent Safe | No | No | Yes |
The Millisecond Port Swap
The most technically impressive feature of Coasts is its switching speed. Tearing down and rebuilding Docker networks every time a developer switches branches takes minutes. Coasts bypasses this entirely using socat.
The system maintains a Canonical Port (like 8080) bound to the host. When a user switches branches, Coasts instantly kills and respawns a lightweight socat process to route traffic to the specific container's internal IP. The containers themselves are long-running and never stop spinning.
The Rust Orchestration Engine
Under the hood, a long-running background process called coastd manages the complexity. Written in Rust, it leverages the tokio runtime for asynchronous operations and communicates with the CLI via Unix Domain Sockets.
To handle crash recovery gracefully, the daemon uses Rust's Drop trait. By utilizing an UpdateOperationGuard, Coasts ensures that if a build process is interrupted or fails, the state is automatically cleaned up and rolled back.
impl Drop for UpdateOperationGuard {
fn drop(&mut self) {
if let Some(state) = self.state.take() {
// Automatically clean up orphaned containers
// and reset proxy routes if the operation panics.
cleanup_failed_coast_state(state);
}
}
}
Sandboxing the Agentic Era
To save resources while maintaining strict boundaries, Coasts distinguishes between instance services (the application code) and shared services (heavy databases like Postgres). It maps isolated logical databases within a single shared container.
Ultimately, the project embraces a Docker-in-Docker approach. It provides a sandbox within a sandbox. As AI coding agents become more autonomous, they require environments where they can execute arbitrary code, run test suites, and fail repeatedly without destroying the host machine. Coasts provides exactly that.