Đang tải…
Đang tải…
npx claude-code-templates@latest --sandbox cloudflare/IMPLEMENTATION_SUMMARYComplete implementation of Cloudflare Workers sandbox for executing Claude Code with AI-powered code generation. This sandbox leverages Cloudflare's global edge network to provide ultra-fast, isolated code execution.
Cloudflare Worker (src/index.ts)
/execute, /health, and root endpointsTypeScript Launcher (launcher.ts)
Monitoring Tool (monitor.ts)
Main Documentation (claude-code-sandbox.md)
Quick Start Guide (QUICKSTART.md)
Debugging Guide (SANDBOX_DEBUGGING.md)
README (README.md)
Package Configuration (package.json)
Wrangler Configuration (wrangler.toml)
TypeScript Configuration (tsconfig.json)
Environment Templates (.dev.vars.example)
Git Ignore (.gitignore)
┌─────────────────────────────────────────────────────┐
│ CLI / HTTP Client │
└──────────────────┬──────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────┐
│ Cloudflare Worker @ Edge │
│ • Receives questions │
│ • Manages secrets │
│ • Handles CORS │
└──────────────────┬──────────────────────────────────┘
│
┌──────────┴──────────┐
│ │
▼ ▼
┌──────────────┐ ┌──────────────────┐
│ Claude AI │ │ Sandbox SDK │
│ Code Gen │ │ Isolated Exec │
└──────┬───────┘ └────────┬─────────┘
│ │
│ Generated Code │
└──────────┬──────────┘
│
▼
┌───────────────┐
│ Results │
│ • Code │
│ • Output │
│ • Errors │
│ • Metrics │
└───────────────┘
| Aspect | Cloudflare | E2B | Winner |
|---|---|---|---|
| Speed | ~100ms cold start | 2-3s cold start | ⚡ Cloudflare |
| Global | Edge network | Single region | 🌍 Cloudflare |
| Duration | 30s max (Workers) | Hours | ⏱️ E2B |
| Environment | Python/Node.js | Full Linux | 🖥️ E2B |
| Pricing | $5/month flat | Usage-based | 💰 Depends |
| Setup | Medium complexity | Low complexity | 🔧 E2B |
| Integration | API-based | Native template | 🔌 E2B |
| Use Case | High volume, fast | Long operations | 🎯 Different |
cloudflare/
├── src/
│ └── index.ts # Cloudflare Worker source (253 lines)
├── launcher.ts # CLI launcher tool (254 lines)
├── monitor.ts # Monitoring tool (372 lines)
├── claude-code-sandbox.md # Main component doc (358 lines)
├── README.md # Complete guide (435 lines)
├── QUICKSTART.md # Quick start (315 lines)
├── SANDBOX_DEBUGGING.md # Debug guide (523 lines)
├── package.json # Dependencies
├── tsconfig.json # TypeScript config
├── wrangler.toml # Cloudflare config
├── .gitignore # Git ignore rules
└── .dev.vars.example # Environment template
Total Lines of Code: ~2,500+ lines Total Files: 12 files
cd .claude/sandbox/cloudflare
npm install
npx wrangler secret put ANTHROPIC_API_KEY
npx wrangler deploy
npm run dev
curl -X POST http://localhost:8787/execute \
-d '{"question": "What is 2^10?"}'
node monitor.ts "Calculate factorial of 5" your_api_key
curl https://your-worker.workers.dev/health
The sandbox integrates seamlessly with the main CLI:
npx claude-code-templates@latest --sandbox cloudflare \
--anthropic-api-key your_key \
--prompt "Your prompt"
Can be combined with agents, commands, and settings:
npx claude-code-templates@latest --sandbox cloudflare \
--agent frontend-developer \
--command setup-react \
--prompt "Create a todo app"
✅ Complete Cloudflare Worker implementation ✅ Full CLI tooling (launcher + monitor) ✅ Comprehensive documentation suite ✅ Local development support ✅ Production deployment guide ✅ Debugging and troubleshooting guides ✅ Integration with Claude Code Templates ✅ Security best practices implemented ✅ Performance optimizations included ✅ Cost analysis provided
This implementation provides a production-ready, globally-distributed sandbox solution for executing AI-generated code. It complements the existing E2B sandbox by offering ultra-fast cold starts and predictable pricing, making it ideal for high-volume, latency-sensitive applications.
The comprehensive documentation and tooling ensure developers can quickly get started and effectively debug any issues that arise. The modular architecture allows for easy extension and customization based on specific use cases.
Implementation Date: October 19, 2025 Version: 1.0.0 Status: Production Ready ✅