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 parallel
Canonical version: 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
Related
- Matt Pocock
- AI Agents
- Agentic Engineering
- Docker Sandboxes
- OpenSandbox
- Vercel Sandboxes
- Cloudflare Sandbox SDK
- microVM
- Claude Code
- TypeScript
- MIT License
About Sébastien
I'm Sébastien Dubois, and I'm on a mission to help knowledge workers escape information overload. After 20+ years in IT and seeing too many brilliant minds drowning in digital chaos, I've decided to help people build systems that actually work. Through the Knowii Community, my courses, products & services and my Website/Newsletter, I share practical and battle-tested systems.
I write about Knowledge Work, Personal Knowledge Management, Note-taking, Lifelong Learning, Personal Organization, Productivity, and more. I also craft lovely digital products and tools.
If you want to follow my work, then become a member and join our community.
Ready to get to the next level?
If you're tired of information overwhelm and ready to build a reliable knowledge system:
- 📚 KM for Beginners — 10+ hours of structured video lessons
- 🚀 Obsidian Starter Kit — Ready-made vault with 40+ templates
- 💼 Knowledge Worker Kit — Complete guides + lifetime community
- 🦉 1-on-1 Coaching — Personalized guidance
- 🎯 Join Knowii — Community + ALL courses & tools
Found this valuable? Share it with someone who needs it.