Start here
Getting started
On this page
What Is Sandcastle?
A TypeScript library for orchestrating AI coding agents in isolated sandboxes:
- You invoke agents with a single
sandcastle.run(). - Sandcastle handles sandboxing the agent with a configurable branch strategy.
- The commits made on the branches get merged back.
Sandcastle is provider-agnostic — it ships with built-in providers for Docker, Podman, and Vercel, and you can create your own. Great for parallelizing multiple AFK agents, creating review pipelines, or even just orchestrating your own agents.
Prerequisites
- Git
- A sandbox provider — Sandcastle needs an isolated environment to run agents in. Built-in options:
- Docker Desktop — most common for local development
- Podman — rootless alternative to Docker
- Vercel — cloud-based Firecracker microVMs via
@vercel/sandbox - Or create your own using
createBindMountSandboxProviderorcreateIsolatedSandboxProvider
Quick start
- Install the package:
npm install --save-dev @ai-hero/sandcastle
- Run
npx @ai-hero/sandcastle init. This scaffolds a.sandcastledirectory with all the files needed.
npx @ai-hero/sandcastle init
- Copy
.sandcastle/.env.exampleto.sandcastle/.env, then fill in your default values forCLAUDE_CODE_OAUTH_TOKEN(runclaude setup-tokenon your host to get one). To use an Anthropic API key instead, uncomment and fill inANTHROPIC_API_KEY.
cp .sandcastle/.env.example .sandcastle/.env
- Run the
.sandcastle/main.ts(ormain.mts) file withnpx tsx
npx tsx .sandcastle/main.ts
// 4. Run the agent via the JS APIimport { run, claudeCode } from "@ai-hero/sandcastle";import { docker } from "@ai-hero/sandcastle/sandboxes/docker";await run({agent: claudeCode("claude-opus-4-8"),sandbox: docker(), // or podman(), vercel(), or your own providerpromptFile: ".sandcastle/prompt.md",});