# Sandcastle (AI)
Sandcastle is a [[TypeScript]] library by [[Matt Pocock]] for orchestrating AI coding agents in isolated sandboxes. You invoke an agent with a single `sandcastle.run()` call; the library runs it in a sandbox on a configurable branch, then merges the resulting commits back into your repo. It targets parallelizing multiple AFK agents, building review pipelines, or orchestrating your own agents.
## Key aspects
- **Provider-agnostic**: Docker, Podman, Vercel, or custom providers. Bind-mount providers (like Docker) mount worktrees directly; isolated providers sync via `copyIn` / `copyFileOut`
- **Branch strategies**: head (direct write), merge-to-head (temporary branch), or explicit branch names
- **Session capture and resume** for continued agent conversations
- **Structured output** via Standard Schema validators
- **Prompt system** with dynamic context (shell expressions, template substitution) and before/after lifecycle hooks
- **Multi-iteration** support with completion signals and idle timeouts
## Agent support
Claude Code, Codex, Pi, Cursor, OpenCode, and Copilot, each configurable (model, reasoning effort, permission modes). MIT licensed; TypeScript (tsup + vitest).
## References
- https://github.com/mattpocock/sandcastle
## Related
- [[Matt Pocock]]
- [[AI Agents]]
- [[Agentic Engineering]]
- [[Docker Sandboxes]]
- [[OpenSandbox]]
- [[Vercel Sandboxes]]
- [[Cloudflare Sandbox SDK]]
- [[microVM]]
- [[Claude Code]]
- [[TypeScript]]
- [[MIT License]]