sandbox-sdk

Runs untrusted commands and code in isolated Docker-like sandboxes on-demand.

1|Updated Apr 6, 2025
One-click install
npx skills add https://github.com/david-driscoll/stargate-command-cluster --skill sandbox-sdk-david-driscoll
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sandbox-sdk
Source: https://github.com/david-driscoll/stargate-command-cluster/tree/main/.agents/skills/sandbox-sdk
Command: npx skills add https://github.com/david-driscoll/stargate-command-cluster --skill sandbox-sdk-david-driscoll

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

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.

Frequently Asked Questions about sandbox-sdk

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

FAQPage Schema
How do I execute untrusted code securely in a Cloudflare Workers sandbox?

To execute untrusted code securely in a Cloudflare Workers sandbox, configure a wrangler.jsonc container with a durable object, re-export the Sandbox class from your worker entry, and use the getSandbox API to run isolated commands and code.

Can I run an LLM code interpreter with persistent state on Cloudflare Workers?

Yes, you can run an LLM code interpreter with persistent state on Cloudflare Workers by using reusable execution contexts within the sandbox-sdk, allowing stateful workflows across python, javascript, and typescript code executions.

How do I expose an HTTP service preview URL from a sandboxed container?

To expose an HTTP service preview URL from a sandboxed container, use the sandbox port APIs to map internal container ports to external preview URLs, enabling live HTTP service testing during isolated execution.

Does Cloudflare Sandbox support isolated file system operations for CI/CD pipelines?

Cloudflare Sandbox supports isolated file system operations for CI/CD pipelines by providing APIs to create directories, write, read, and list files within the isolated workspace without risking host access.

What is the best way to manage sandbox lifecycle and resource cleanup on Workers?

The best way to manage sandbox lifecycle and resource cleanup on Workers is to lazily start sandboxes, assign a stable sandboxId per user or session for reuse, and explicitly call destroy to free resources when execution is complete.

Do I need a wrangler.jsonc configuration to run isolated commands in Cloudflare Sandbox?

Yes, you need a correct wrangler.jsonc configuration defining container and durable object bindings to run isolated commands in Cloudflare Sandbox, along with a worker entry that re-exports the Sandbox class.