sandbox-sdk
Installation
SKILL.md
Sandbox SDK
Build secure, isolated code execution environments on Cloudflare Workers.
When to Use
- running LLM-generated code in isolation
- executing user-submitted scripts safely
- needing sandboxed compute with file access on edge
- building an AI code interpreter / dev environment
Core Rules
- Do NOT use internal clients (
CommandClient,FileClient) - use standardsandbox.*wrapper methods. - The Worker entrypoint script MUST explicitly include
export { Sandbox } from '@cloudflare/sandbox'. - Do not skip
destroy()calls on temporary sandboxes to avoid resource leaks. - Keep container images lean in the Dockerfile to optimize startup and prevent cold start latency.
- Always set explicit resource limits including
timeout_ms(up to 30,000 ms),memory_mb, andcpu_mson every sandbox invocation to prevent unbounded execution. - Manage network isolation by routing necessary sandboxed network requests through the Worker's allowed callback pattern using the
env.SANDBOXbinding. - Adhere to overarching policy
core/policies/execution-sandbox.md(Tier 4 Managed Cloud Sandbox) for universal resource quotas and containment standards.