sandbox-sdk

Execute untrusted commands and AI-generated code in Cloudflare Sandbox containers on Workers.

17|1|Updated Feb 2, 2024
One-click install
npx skills add https://github.com/FormalSnake/dotfiles --skill sandbox-sdk-formalsnake
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sandbox-sdk
Source: https://github.com/FormalSnake/dotfiles/tree/main/users/kyandesutter/claude/skills/sandbox-sdk
Command: npx skills add https://github.com/FormalSnake/dotfiles --skill sandbox-sdk-formalsnake

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Sandbox SDK enables secure, isolated execution of commands and AI-generated code so you can run untrusted workloads without exposing your main environment.

Core Features & Use Cases

  • Secure isolated execution on Cloudflare Workers: Runs shell-style commands and code interpreter-style execution inside Sandbox containers for safer evaluation.
  • LLM-friendly code execution with persisted context: Uses createCodeContext and runCode to support multi-step code workflows where state matters.
  • Workspace file and port operations: Creates directories, reads/writes files, lists artifacts, and exposes ports for preview URLs.

Example use case: you want to execute AI-generated Python to transform uploaded data, write results into /workspace, and expose a temporary HTTP preview endpoint—without risking your host system.

Quick Start

Configure wrangler.jsonc and re-export Sandbox from your Worker entry, then ask the AI to help you implement a Worker route that calls getSandbox(env.Sandbox, sessionId) and runs runCode() for the requested language and code.

Frequently Asked Questions about sandbox-sdk

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

FAQPage Schema
How do I securely execute AI-generated code in an isolated environment?

Yes, Cloudflare Workers supports isolated sandbox execution for untrusted code through Durable Object containers. You configure a wrangler.jsonc file and re-export the Sandbox entry point to establish secure boundaries for running shell commands and code interpreters.

How do I run multi-step code workflows with persisted context on Cloudflare?

You run multi-step workflows with persisted context by using the createCodeContext and runCode functions. This allows sequential code execution where state matters across multiple steps, maintaining session data within the isolated Cloudflare Sandbox environment.

Can I create preview URLs and manage file operations within a Cloudflare Sandbox?

Yes, you can manage workspace file operations like reading, writing, and listing files, and expose ports to generate temporary preview URLs. This allows you to write execution results into a workspace directory and expose an HTTP endpoint for previewing outputs.

What's the best way to configure a code interpreter sandbox for OpenAI agents?

The best way to configure a code interpreter sandbox for agents is configuring wrangler.jsonc for Durable Objects and re-exporting the Sandbox entry in your Worker. You then call getSandbox to retrieve the session and runCode to execute the requested language.

Do I need Durable Objects to run isolated shell commands on Workers?

Yes, you need Durable Objects configured in wrangler.jsonc to run isolated shell commands. This specific container configuration provides the required per-session state isolation and lifecycle control for safe execution and cleanup via destroy.