Introducing Sandcastle Matt Pocock introduced Sandcastle, an AI agent orchestration tool that uses Git worktrees to run multiple AI agents in parallel without version control conflicts. The tool, available on GitHub and installable via npm, requires a Claude Code OAuth token and a GitHub personal access token to manage issues and pull requests. Sandcastle is positioned as a low-level primitive for developers to build custom multi-agent workflows. This is a post about Sandcastle https://github.com/mattpocock/sandcastle , an AI Agent Orchestration tool. What is AI orchestration? The short answer is that it’s the process of getting multiple agents to work on things at the same time. If you’re wondering why you need a tool for that, well, read on. Why do I need a tool to run multiple agents? Let’s say you have 4 issues that can be implemented simultaneously. You might wonder why you can’t just spin up 4 different terminals, start Claude in each, write your prompts, and hit enter. That would work, sort of. But think about your version control system. At the end of the day, git works off your file system. Any changes you make to files are immediately reflected as unstaged. Yes, any or all of those agents can create branches, but you can only have one branch checked out at any given time. Basically, those agents will all be stepping on each other. That said, there’s a git feature that predates AI by a generation and is designed to solve this very problem: workstrees. Worktrees have existed in git for over 10 years, but I’ll be honest, I’d never even heard of them before AI. Back when we were writing our code manually, life was simple: check out a branch, do work, commit, and push. Then potentially switch to a different branch. Rinse and repeat. You have one working directory, which has one branch open at any given time. What are Git Worktrees? Worktrees allow you to have multiple working directories of your repo checked out on disk at any given time. Each of these separate working directories can have its own branch checked out. This is obviously a fantastic solution for orchestrating AI agents to work on things in parallel. But if you think this is the part of the post where I get into the git commands necessary to use Worktrees, things have already evolved past that. There are tools that happily and elegantly manage these things for you, and this is a post about one of them: Sandcastle https://github.com/mattpocock/sandcastle . Setting Expectations If you’re imagining a high-level tool that will magically do amazing things for you out of the box, please understand that this is a low-level primitive. It performs some low-level tasks extremely well, allowing you to put together your own workflow for your own project as needed. And with that, let’s get started. Installation Install it into your project. npm install --save-dev @ai-hero/sandcastle Then run this to kick off the setup: npx @ai-hero/sandcastle init If you let it, it’ll set up the default Docker image. This is the image Sandcastle will use to run your agents if you select the Docker sandbox to ensure isolation from each other. Looking Around Let’s see what was created for us. You should see a .sandcastle folder, inside of which there should be a .env.example file. Mine looks like this. Claude Code OAuth token — get one by running claude setup-token on your host. Lets the agent use your Claude subscription instead of an API key. CLAUDE CODE OAUTH TOKEN= Or use an Anthropic API key instead — uncomment and fill in: ANTHROPIC API KEY= GitHub personal access token — the agent uses it to read and manage GitHub Issues Create a fine-grained token: https://github.com/settings/personal-access-tokens/new Required repository permissions: Issues Read and write and Metadata Read GH TOKEN= Rename it to .env , and then let’s get it filled out. It needs a Claude Code token, and a GitHub token; the latter is needed for things like creating GitHub issues, and pull requests. The instructions for the Claude token are self-explanatory and listed right there: just run claude setup-token in a terminal not a Claude session . For the GitHub token, head to the new Personal Access Token https://github.com/settings/personal-access-tokens/new page. Give your token a name, expiration, etc. And for permissions, make sure you select what’s below, at a minimum. Make sure contents, pull requests, and issues all have read/write permissions. Hello World The simplest possible way to run Sandcastle is via the sample main.ts file that was scaffolded. It looks like this by default. js import { run, claudeCode } from "@ai-hero/sandcastle"; import { docker } from "@ai-hero/sandcastle/sandboxes/docker"; // Blank template: customize this to build your own orchestration. // Run this with: npx tsx .sandcastle/main.ts // Or add to package.json scripts: "sandcastle": "npx tsx .sandcastle/main.ts" await run { agent: claudeCode "claude-opus-4-6" , sandbox: docker , promptFile: "./.sandcastle/prompt.md", } ; Here’s the prompt.md file that was generated Context < -- Use command to pull in dynamic context. Commands run inside the sandbox. -- < -- Example: git log --oneline -10 or gh issue list --state open --label Sandcastle --limit 100 --json number,title,body,labels,comments --jq ' . | {number, title, body, labels: .labels .name , comments: .comments .body } ' -- Task < -- Describe what the agent should do. -- Done < -- When the task is complete, output