Cloudflare Sandbox SDK for Openclaw

A powerful SDK for building secure, isolated code execution environments inside Cloudflare Workers to power AI interpreters, CI/CD pipelines, and runtime sandboxes.

creativerezz
v1.0.0
Jun 11, 2026
0
429
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install sandbox-sdk

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install sandbox-sdk using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Cloudflare Sandbox SDK?

The Cloudflare Sandbox SDK enables developers to run untrusted code securely inside lightweight, containerized environments on top of Cloudflare Workers. This capability is crucial for implementing code interpreters for large language models, interactive development environments, and automated CI/CD pipelines. By combining the low latency of edge computing with Docker-backed isolated runtime sandboxes, it solves the challenge of executing dynamic script code safely and efficiently.

Integrating this package into Openclaw Skills allows AI coding agents to dynamically write, run, and test code, creating highly capable autonomous assistants that can interact with file systems and execute terminal commands in a secure sandbox.

Cloudflare Sandbox SDK Use Cases

  • Executing LLM-generated code safely within isolated Python, JavaScript, or TypeScript runtime contexts.
  • Setting up dynamic, on-demand development environments and automated testing CI/CD pipelines.
  • Running untrusted user code in web-based playgrounds or interactive sandboxes without risking backend security.
  • Creating custom agent tools using the OpenAI Agents SDK to expose terminal access and file systems to AI workflows.
  • Exposing local development ports securely to generate live preview URLs for web applications.

How Cloudflare Sandbox SDK Works

  1. Initialization: The sandbox instance is initialized using the getSandbox() method with a unique session identifier.
  2. Lazy Container Start: The underlying sandbox container starts lazily upon receiving its first execution or file operation request.
  3. State Management & Persistence: Developers run code using state-aware execution contexts or perform direct shell commands, persisting state inside the /workspace directory.
  4. Resource Management: The container automatically sleeps after 10 minutes of inactivity to optimize resource usage, or can be explicitly torn down using the destroy() method.

Cloudflare Sandbox SDK Setup

To begin using the Cloudflare Sandbox SDK with your Openclaw Skills workflow, verify your local Docker installation and install the package:

npm install @cloudflare/sandbox
docker info # Must succeed - Docker is required for local development

Configure your wrangler.jsonc file with the required Durable Object and Container configurations:

{
  "containers": [{
    "class_name": "Sandbox",
    "image": "./Dockerfile",
    "instance_type": "lite",
    "max_instances": 1
  }],
  "durable_objects": {
    "bindings": [{ "class_name": "Sandbox", "name": "Sandbox" }]
  },
  "migrations": [{ "new_sqlite_classes": ["Sandbox"], "tag": "v1" }]
}

Then, ensure your Worker entrypoint properly re-exports the Sandbox class:

import { getSandbox } from '@cloudflare/sandbox';
export { Sandbox } from '@cloudflare/sandbox'; // Required export

Cloudflare Sandbox SDK Data Schema & Taxonomy

The Cloudflare Sandbox SDK relies on structured Docker environments and persistent workspaces to store code, assets, and project dependencies.

Workspace Layout

All file operations take place within the /workspace partition of the sandbox.

Directory / File Description
/workspace The primary directory where all workspace files, custom scripts, and code interpreter outputs reside.
./Dockerfile The local container definition that extends the base sandbox image (docker.io/cloudflare/sandbox:0.7.0).
wrangler.jsonc The orchestration and binding configuration for local or cloud-based deployments.

Dockerfile Customization Example

You can customize the underlying image by defining a standard Dockerfile:

FROM docker.io/cloudflare/sandbox:0.7.0

# Pre-install language packages
RUN pip install requests beautifulsoup4
RUN npm install -g typescript

# Expose the default HTTP service port
EXPOSE 8080

Cloudflare Sandbox SDK Advanced Features

  • Integrated OpenAI Agents SDK helpers (Shell and Editor from @cloudflare/sandbox/openai) to simplify prompt-to-sandbox tools.
  • Automated runtime isolation of LLM outputs using persistent execution contexts inside runCode() to retain variables and modules.
  • Preview URLs generation via exposePort() for debugging and previewing local web applications with wildcard DNS bindings in production.
  • Configurable container lifetimes with custom inactivity sleep intervals to optimize cloud operational costs.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*