Skip to main content

Coding agents

Sandcastle

Sandcastle runs coding agents like Claude Code and Codex on your repo, each in its own E2B sandbox. The agents' commits come back to a branch on your machine.

Maintained by
Sandcastle
How it works
Built-in E2B sandbox provider
Package
@ai-hero/sandcastle
Language
TypeScript

Set it up

Get started

Paste the prompt into your coding agent, or follow the steps yourself.

Paste this into your coding agent

Add E2B sandboxes to this Sandcastle project.

  1. 1.Install @ai-hero/sandcastle and e2b using the project's package manager.
  2. 2.Sandcastle needs the E2B_API_KEY environment variable in my shell. If it isn't set, ask me for my API key from https://console.e2b.dev/?tab=keys. Never hardcode it, and never put it in .sandcastle/.env.
  3. 3.Follow the Sandcastle guide at https://docs.e2b.dev/agents/sandcastle and run claudeCode with sandbox: e2b({ template: "claude" }), passing ANTHROPIC_API_KEY in the agent env.
  4. 4.Run it once from the repo root and show me the commits that came back from the sandbox.

Or set it up yourself

  1. 1. Install Sandcastle and E2B

    npm install @ai-hero/sandcastle e2b
  2. 2. Set your API keys

    export E2B_API_KEY="e2b_..."
    export ANTHROPIC_API_KEY="..."
  3. 3. Run Claude Code in a sandbox

    import { run, claudeCode } from "@ai-hero/sandcastle";
    import { e2b } from "@ai-hero/sandcastle/sandboxes/e2b";
    
    const result = await run({
      agent: claudeCode("claude-opus-4-8", {
        env: { ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY! },
      }),
      sandbox: e2b({ template: "claude" }),
      prompt: "Fix the failing test in src/slugify.js and commit the fix.",
    });
    
    console.log(result.commits);

Security

What runs in the sandbox

Each agent works on a copy of your repo in its own sandbox. Only its commits come back.

  • CodeThe agent CLI from the template, claude or codex, working on a copy of your repo in $HOME/workspace.
  • CommitsCommits land on your current branch, or on a separate one with branchStrategy.
  • Lifetimerun() creates a sandbox and kills it when the run finishes. At timeoutMs, 30 minutes by default, it's killed, never paused.
  • SecretsOnly keys in .sandcastle/.env and the providers' env reach the sandbox. Keep E2B_API_KEY out of .sandcastle/.env.

3B+ sandboxes started

Give every agent a machine