jackspace/claudeskillz/cloudflare-sandbox
- community
Checking that the SKILL.md file is still in the repository.
Guide to the Cloudflare Sandbox SDK (@cloudflare/sandbox), which runs code inside isolated Ubuntu Linux containers at the edge, routed by Durable Objects. Covers wrangler container and Durable Object bindings, getSandbox(), exec(), runCode(), gitCheckout(), session management, container lifecycle and cold starts, file handling, and state persistence. Use when executing untrusted or AI-generated code, running Python or Node.js scripts safely, building code interpreters and chat-based coding agents, issuing shell commands in isolation, working with git repositories programmatically, creating ephemeral build or CI/CD environments, processing files with system tools such as ffmpeg or imagemagick, or debugging sandbox container lifecycle, routing, and session persistence problems.
Install
npx vskill@latest install jackspace/claudeskillz/cloudflare-sandboxSKILL.md
Cloudflare Sandboxes SDK
Status: Production Ready (Open Beta) Last Updated: 2025-10-29 Dependencies: cloudflare-worker-base, cloudflare-durable-objects (recommended for understanding) Latest Versions: @cloudflare/sandbox@0.4.12, Docker image: cloudflare/sandbox:0.4.12
Quick Start (15 Minutes)
1. Install SDK and Setup Wrangler
wrangler.jsonc:
Why this matters:
nodejs_compatenables Node.js APIs required by SDKcontainersdefines the Ubuntu container imagedurable_objectsbinding enables persistent routingmigrationsregisters the Sandbox class
2. Create Your First Sandbox Worker
CRITICAL:
- MUST export
{ Sandbox }from@cloudflare/sandboxin your Worker - Sandbox ID determines routing (same ID = same container)
- First request creates container (~2-3 min cold start)
- Subsequent requests are fast (<1s)
3. Deploy and Test
Expected output:
Architecture (Understanding the 3-Layer Model)
How Sandboxes Work
Key Insight: Workers handle API logic (fast), Durable Objects route requests (persistent identity), Containers execute code (full capabilities).
Critical Container Lifecycle (Most Important Section!)
Container States
The #1 Gotcha: Ephemeral by Default
While Container is Active (~10 min after last request):
- ✅ Files in
/workspace,/tmp,/homepersist - ✅ Background processes keep running
- ✅ Shell environment variables remain
- ✅ Session working directories preserved
When Container Goes Idle (after inactivity):
- ❌ ALL files deleted (entire filesystem reset)
- ❌ ALL processes terminated
- ❌ ALL shell state lost
- ⚠️ Next request creates fresh container from scratch
This is NOT like a traditional server. Sandboxes are ephemeral by design.
Handling Persistence
For Important Data: Use external storage
For Build Artifacts: Accept ephemerality or use caching
Session Management (Game-Changer for Chat Agents)
What Are Sessions?
Sessions are bash shell contexts within one sandbox. Think terminal tabs.
Key Properties:
- Each session has separate working directory
- Sessions share same filesystem
- Working directory persists across commands in same session
- Perfect for multi-step workflows
Pattern: Chat-Based Coding Agent
Without Sessions (Common Mistake)
Pattern: Parallel Execution
Sandbox Naming Strategies
Per-User Sandboxes (Persistent Workspace)
Pros: User's work persists while actively using (10 min idle time) Cons: Geographic lock-in (first request determines location) Use Cases: Interactive notebooks, IDEs, persistent workspaces
Per-Session Sandboxes (Fresh Each Time)
Pros: Clean environment, no state pollution Cons: No persistence between requests Use Cases: One-shot code execution, CI/CD, testing
Per-Task Sandboxes (Idempotent & Traceable)
Pros: Reproducible, debuggable, cacheable Cons: Need explicit cleanup strategy Use Cases: Build systems, data pipelines, automated workflows
Core API Reference
Getting a Sandbox
Executing Commands
File Operations
Git Operations
Code Interpreter (Jupyter-like)
Background Processes
Cleanup
Critical Rules
Always Do
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 40 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/cloudflare-sandbox/SKILL.md
Popularity
- Repository stars
- 12
- Repository forks
- 4
- 7-day trend score
- 13
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 5 Apr 2026, 6 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/jackspace/claudeskillz/cloudflare-sandbox)