sandcastle
by
mattpocock

Description: Orchestrate sandboxed coding agents in TypeScript with sandcastle.run()

View on GitHub ↗

Summary Information

Updated 25 minutes ago
Added to GitGenius on June 9th, 2026
Created on March 17th, 2026
Open Issues & Pull Requests: 71 (+0)
Number of forks: 601
Total Stargazers: 5,975 (+1)
Total Subscribers: 16 (+0)

Issue Activity (beta)

Open issues: 28
New in 7 days: 10
Closed in 7 days: 4
Avg open age: 24 days
Stale 30+ days: 1
Stale 90+ days: 0

Recent activity

Opened in 7 days: 9
Closed in 7 days: 4
Comments in 7 days: 11
Events in 7 days: 53

Top labels

  • ready-for-agent (171)
  • enhancement (132)
  • needs-triage (46)
  • bug (45)
  • needs-info (8)
  • wontfix (8)
  • documentation (7)
  • agent:blocked (1)

Detailed Description

Sandcastle is a TypeScript library designed to orchestrate AI coding agents in isolated sandboxes, enabling safe and efficient automation of code generation, review, and modification tasks. Its primary purpose is to provide a robust framework for running agents—such as AI models like Claude—in environments that are isolated from the host system, ensuring that code changes are managed, tracked, and merged back into the main repository in a controlled manner. Sandcastle is particularly useful for parallelizing multiple agents, creating automated review pipelines, or simply orchestrating custom coding agents.

The core functionality revolves around the `sandcastle.run()` method, which allows users to invoke agents with a single command. Sandcastle handles the creation of sandboxed environments using a configurable branch strategy, ensuring that each agent operates on its own isolated branch. The changes made by agents are committed to these branches and can be merged back into the main repository, facilitating collaborative and automated workflows.

Sandcastle is provider-agnostic, meaning it supports multiple sandbox providers out of the box and allows users to create custom providers. Built-in providers include Docker, Podman, and Vercel. Docker and Podman offer local container-based isolation, while Vercel provides cloud-based microVMs for remote execution. There is also a "no-sandbox" option for running agents directly on the host when container isolation is not required. Users can extend Sandcastle by implementing their own providers using helper functions like `createBindMountSandboxProvider` or `createIsolatedSandboxProvider`.

To get started, users install the package and initialize the project with `npx @ai-hero/sandcastle init`, which scaffolds a `.sandcastle` directory containing all necessary files. Configuration is managed via environment variables, such as API keys for AI providers. The main entry point is typically `.sandcastle/main.ts`, which can be executed with `npx tsx`.

Sandcastle offers a flexible API for programmatic use in scripts, CI pipelines, or custom tooling. The `run()` function is suitable for one-shot invocations, automatically handling sandbox lifecycle. For scenarios requiring multiple agent runs within the same environment, the `createSandbox()` method creates a reusable sandbox, allowing repeated agent invocations without incurring container startup costs. This is ideal for workflows where dependencies and build artifacts need to persist across runs.

The library provides granular control over sandbox and worktree management. Options include specifying branches, sandbox providers, working directories, lifecycle hooks, file copying, and timeouts. Sandcastle supports automatic and manual cleanup of sandboxes and worktrees, preserving worktrees with uncommitted changes for inspection or further use.

Worktrees are managed independently from sandboxes, allowing users to run interactive sessions or hand off worktrees to agents. Ownership and cleanup responsibilities are clearly defined, ensuring that containers and worktrees are managed appropriately based on the workflow.

Overall, Sandcastle is a powerful tool for orchestrating AI-driven coding workflows in isolated environments, offering flexibility, extensibility, and safety. Its provider-agnostic design, comprehensive API, and robust lifecycle management make it suitable for advanced automation scenarios, collaborative coding, and integration with modern development pipelines.

sandcastle
by
mattpocockmattpocock/sandcastle

Repository Details

Fetching additional details & charts...