sandbox-sdk

Build sandboxed code execution environments on Cloudflare Workers using the Sandbox SDK.

1|Updated Jul 2, 2026
One-click install
npx skills add https://github.com/tarabakz25/my-skills --skill sandbox-sdk-tarabakz25
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sandbox-sdk
Source: https://github.com/tarabakz25/my-skills/tree/main/sandbox-sdk
Command: npx skills add https://github.com/tarabakz25/my-skills --skill sandbox-sdk-tarabakz25

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @cloudflare/sandbox, and includes references (resource) components.

What problem does it solve? Executing untrusted or LLM-generated code safely requires isolated environments, and configuring Cloudflare's Sandbox SDK involves precise wrangler.jsonc settings, Durable Object bindings, and API choices that are easy to get wrong. ## Core Features & Use Cases - Sandbox Lifecycle Management: Create isolated containers with getSandbox(), control sleep behavior, and destroy instances to free resources. - Command and Code Execution: Run shell commands with exec() or execute LLM-generated code with runCode() supporting Python, JavaScript, and TypeScript with persistent contexts. - File and Port Operations: Read, write, and list files in the sandbox filesystem, and expose HTTP services via preview URLs. - Use Case: Build an AI code interpreter where an agent writes Python analysis code, executes it in an isolated sandbox with pandas, and returns rich outputs like charts and tables to the user. ## Quick Start Ask the agent to set up a Cloudflare Worker using the Sandbox SDK that runs Python code in an isolated sandbox and returns the execution results.

Frequently Asked Questions about sandbox-sdk

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

FAQPage Schema
How do I run LLM-generated code in a Cloudflare sandbox?▼

Use sandbox.runCode() with a code context created via createCodeContext(). It supports Python, JavaScript, and TypeScript, persists state within a context, and returns rich outputs like text, HTML, and PNG.

What is the difference between exec() and runCode() in the Sandbox SDK?▼

exec() runs shell commands and returns stdout, stderr, and exit codes, suiting scripts and build pipelines. runCode() executes code with rich outputs and state persistence, making it better for LLM-generated code and data analysis.

Why won't my Cloudflare Sandbox Worker deploy?▼

The Worker must re-export the Sandbox class with export { Sandbox } from '@cloudflare/sandbox'. Also verify wrangler.jsonc includes the containers section, Durable Object bindings, and the SQLite migration for the Sandbox class.

Do preview URLs work on the workers.dev domain?▼

No, preview URLs from exposePort() require a custom domain with wildcard DNS such as *.yourdomain.com. The default .workers.dev domain does not support preview URL subdomains in production.

How long do Cloudflare sandbox containers stay alive?▼

Containers sleep after 10 minutes of inactivity by default, configurable via the sleepAfter option or prevented with keepAlive. Call destroy() to immediately terminate a sandbox and free its resources.