ai-sandbox

Run harness adapters inside isolated sandboxes with declarative provisioning and durable run takeover.

3.1k|316|Updated Oct 8, 2025
One-click install
npx skills add https://github.com/TanStack/ai --skill ai-sandbox
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ai-sandbox
Source: https://github.com/TanStack/ai/tree/main/packages/ai-sandbox/skills/ai-sandbox
Command: npx skills add https://github.com/TanStack/ai --skill ai-sandbox

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Running agent CLIs like Claude Code, Codex, or OpenCode directly on the host is unsafe and hard to reproduce. This Skill runs harness adapters inside isolated sandboxes (local process, Docker, Daytona, Cloudflare) with declarative workspace provisioning, secret handling, snapshots, and durable run journals so long-running agent runs survive disconnects and host failures.

Core Features & Use Cases

  • Declarative sandbox provisioning: Define workspaces with git sources, setup scripts, skills (agentSkill/gitSkill/mcpSkill/fileSkill), plugins, secrets, and instructions projected per harness (AGENTS.md, .mcp.json, config.toml).
  • Snapshots and lifecycle: Automatic snapshot-after-setup with TTL, portable snapshots via withPersistence, named saves, checkpoint forks, and authorized artifact reads.
  • Durable runs and takeover: NDJSON run journals, replay alignment with chunkFingerprint, single-writer fencing, and sandboxRunDriver for detached runs that survive host death.
  • Use Case: A coding agent runs Claude Code inside a Docker container cloned from a GitHub repo; when the user's browser tab closes, a new host takes over the run by replaying the journal and resumes streaming events to the client.

Quick Start

Use the ai-sandbox skill to run Claude Code inside a Docker sandbox with a git workspace, setup steps, and snapshot-after-setup enabled.

Frequently Asked Questions about ai-sandbox

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run Claude Code inside a Docker sandbox?

Define a sandbox with defineSandbox using dockerSandbox({ image }) as the provider and a defineWorkspace with your git source and setup commands, then pass it to chat() via the withSandbox middleware. The adapter runs the agent CLI inside the container and streams events back.

How do sandbox snapshots work in TanStack AI?

When the provider supports snapshots, bootstrap takes one automatically after setup completes, and subsequent runs resume from it. You can set snapshotMaxAge as a TTL, and portable snapshots via withPersistence let you save named checkpoints, fork from them, and read artifacts.

Which sandbox providers does ai-sandbox support?

Three providers are documented: localProcessSandbox for host execution during development, dockerSandbox for isolated containers with snapshots and fork, and daytonaSandbox for Daytona cloud sandboxes. All implement the same SandboxHandle interface with fs, git, process, and ports.

Why does my durable run fail with DurableRunIdRequiredError?

When sandbox durability is wired, every run must receive an explicit unique runId because the journal path is derived from it and no generated id can be recomputed by a successor host. Pass a unique runId per run; reusing one appends to the previous run's journal and corrupts replay.

Can sandbox runs survive a browser refresh or host crash?

Yes, when you pass both runs and durability to withSandbox, the agent's NDJSON output is journaled inside the sandbox and sandboxRunDriver enables takeover by a new host. Passing only one of the two options silently disables durability entirely.

How are secrets handled in sandbox workspaces?

createSecrets stores values in a non-enumerable symbol-keyed registry so they are never logged, snapshotted, or written to the sandbox store. Use secret refs in gitSkill for private repos and bearer() for MCP authorization headers, resolved only at bootstrap time.