Matt Pocock's Sandcastle Lets AI Coding Agents Run in Parallel With One Call
Matt Pocock's Sandcastle wraps Claude Code, Codex, Cursor and others in Docker or Podman sandboxes, orchestrated from TypeScript with a single run() call.
Takeaways
- Sandcastle orchestrates sandboxed AI coding agents in TypeScript via a single run() call.
- Provider-agnostic: built-in Docker, Podman, and Vercel Firecracker microVM sandboxes plus custom.
- Supports Claude Code, Codex, Pi, Cursor, OpenCode, and GitHub Copilot as agent providers.
- Three branch strategies (head, merge-to-head, branch) handle worktrees and merge-back automatically.
- Session capture, resume, and fork enable fan-out workflows across parallel branches.
- MIT-licensed, install via
npm install @ai-hero/sandcastlewith five workflow templates.
Fleets of background coding agents are getting easier to run, but wiring them up to isolated environments, git worktrees, and clean merge strategies still requires a lot of glue code. Sandcastle, a new open-source library from Matt Pocock, tries to collapse that glue into one function call. It targets the increasingly common pattern of AFK agents (fire-and-forget coding sessions you kick off and check back on later) and gives you a typed API to orchestrate them.
The TypeScript library orchestrates AI coding agents in isolated sandboxes. You invoke an agent with a single sandcastle.run(), Sandcastle handles isolation with a configurable branch strategy, and commits made on those branches get merged back. The project is MIT-licensed and published on npm as @ai-hero/sandcastle.
One call, three moving parts
The core API is deliberately minimal. You hand run() an agent provider, a sandbox provider, and a prompt, and it returns the commits that were made:
import { run, claudeCode } from "@ai-hero/sandcastle";
import { docker } from "@ai-hero/sandcastle/sandboxes/docker";
await run({
agent: claudeCode("claude-opus-4-8"),
sandbox: docker(),
promptFile: ".sandcastle/prompt.md",
});
Under the hood, Sandcastle creates a git worktree, spins up a container, bind-mounts the worktree in, runs the agent, collects the commits, and merges them back to your working branch. The library is provider-agnostic, ships with built-in providers for Docker, Podman, and Vercel, and lets you write your own. It's designed for parallelizing multiple AFK agents, creating review pipelines, or orchestrating custom workflows.