What problem does it solve?
sandbox-sdk helps you run potentially untrusted code or commands in a strongly isolated environment so you can execute safely without giving it access to your host.
Core Features & Use Cases
- Isolated command execution: Run shell commands inside a Cloudflare Sandbox container and capture stdout, stderr, exit codes, and success status.
- LLM-friendly code interpreter: Execute LLM-generated code with language support (python, javascript, typescript) using reusable execution contexts for stateful workflows.
- Sandboxed file system & service previewing: Create directories, write/read/list files, and expose ports to obtain preview URLs for HTTP services.
- Lifecycle management: Lazily start sandboxes, reuse a stable sandboxId per user/session, and explicitly destroy sandboxes to free resources.
Use case example: Build a web-based coding assistant that runs user-submitted analysis scripts by writing files into the sandbox workspace, executing them with a persistent code context, and returning structured outputs without risking the host.
Quick Start
Use the sandbox-sdk skill to run code inside a Cloudflare Sandbox by providing your required wrangler.jsonc configuration and re-exporting the Sandbox class from your worker entry.