sandbox-sdk

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

13|1|Updated Feb 9, 2026
One-click install
npx skills add https://github.com/vedang/dotagents --skill sandbox-sdk-vedang
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sandbox-sdk
Source: https://github.com/vedang/dotagents/tree/main/specific_skills/sandbox-sdk
Command: npx skills add https://github.com/vedang/dotagents --skill sandbox-sdk-vedang

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Running untrusted or LLM-generated code safely requires isolated execution environments, and configuring Cloudflare's Sandbox SDK involves specific wrangler settings, Durable Object bindings, and API patterns that are easy to get wrong. ## Core Features & Use Cases - Command and Code Execution: Run shell commands with exec() or execute Python, JavaScript, and TypeScript with runCode() for rich outputs and persistent state. - File and Port Management: Write, read, and list files inside sandboxes, and expose HTTP services via preview URLs. - Use Case: Build an AI code interpreter where an agent generates Python data analysis code, executes it in an isolated per-session sandbox with pandas, and returns charts and results to the user. ## Quick Start Ask the agent to create a Cloudflare Worker that uses the Sandbox SDK to run Python code in an isolated sandbox and return the result.

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 sandbox.createCodeContext(). It supports Python, JavaScript, and TypeScript, returns rich outputs like text and images, and persists state within the context across executions.

How do I execute shell commands with the Cloudflare Sandbox SDK?

Call sandbox.exec() with the command string, optionally passing cwd, env, timeout, and stdin. It returns stdout, stderr, exitCode, and a success flag, making it suitable for build and test pipelines.

What wrangler configuration does the Sandbox SDK require?

You need a containers entry with class_name Sandbox and a Dockerfile image, a Durable Object binding named Sandbox, and a migration with new_sqlite_classes. The Worker entry must also re-export the Sandbox class.

Does the Cloudflare Sandbox SDK support preview URLs for exposed ports?

Yes, sandbox.exposePort() returns a preview URL for HTTP services running in the sandbox. In production this requires a custom domain with wildcard DNS, since .workers.dev does not support preview URL subdomains.

Why is my Cloudflare sandbox Worker failing to deploy?

A common cause is missing the required export of the Sandbox class from the Worker entry file. Also verify the wrangler containers, Durable Object bindings, and migrations match the required structure exactly.

When should I use exec() versus runCode() in the Sandbox SDK?

Use exec() for shell commands, scripts, and build pipelines where you need exit codes and stderr. Use runCode() for LLM-generated code and data analysis where you want rich outputs and persistent state across calls.