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


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:

Found this valuable? Share it with someone who needs it.

Join 6,000+ readers. Get practical systems for knowledge & AI. Free.

Subscribe ✨

Free: Knowledge System Checklist

A clear roadmap to building your own knowledge system. Subscribe and get it straight to your inbox.

6,000+ readers. No spam. Unsubscribe anytime.