Đang tải…
Đang tải…
npx claude-code-templates@latest --sandbox cloudflare/QUICKSTARTGet your Cloudflare Claude Code Sandbox running in under 5 minutes.
Perfect if you want to skip local testing and deploy directly.
cd .claude/sandbox/cloudflare
npm install
npx wrangler secret put ANTHROPIC_API_KEY
# Paste your Anthropic API key when prompted
npx wrangler deploy
# Wait 2-3 minutes, then check:
npx wrangler containers list
# You should see: ✓ Container ready
# Get your worker URL from the deploy output, then:
curl -X POST https://YOUR-WORKER.YOUR-SUBDOMAIN.workers.dev/execute \
-H "Content-Type: application/json" \
-d '{"question": "What is the 10th Fibonacci number?"}'
Expected response:
{
"success": true,
"question": "What is the 10th Fibonacci number?",
"code": "def fibonacci(n):\n ...",
"output": "55\n",
"error": "",
"executionTime": 1234
}
Done! Your sandbox is live at the edge.
Perfect if you want to test locally before deploying.
cd .claude/sandbox/cloudflare
npm install
cp .dev.vars.example .dev.vars
# Edit .dev.vars and add your Anthropic API key
# macOS: Open Docker Desktop
# Linux: sudo systemctl start docker
# Windows: Start Docker Desktop
# Verify Docker is running:
docker ps
npm run dev
Wait for:
⛅️ wrangler 3.78.12
-------------------
⎔ Starting local server...
[wrangler:inf] Ready on http://localhost:8787
# In a new terminal:
curl -X POST http://localhost:8787/execute \
-H "Content-Type: application/json" \
-d '{"question": "Calculate factorial of 5"}'
# Stop the dev server (Ctrl+C)
npx wrangler secret put ANTHROPIC_API_KEY
npx wrangler deploy
Done! You've tested locally and deployed.
Perfect if you prefer command-line interaction.
cd .claude/sandbox/cloudflare
npm install
npx wrangler secret put ANTHROPIC_API_KEY
npx wrangler deploy
# Execute a prompt
node launcher.ts "What is 2 to the power of 10?" \
"" \
your_anthropic_key \
https://your-worker.workers.dev
# Get detailed execution metrics
node monitor.ts "Calculate factorial of 5" \
your_anthropic_key \
https://your-worker.workers.dev
Done! You're using the CLI tools.
Solution: Wait 2-3 minutes after first deployment
npx wrangler containers list
Solution: Start Docker Desktop or Docker service
docker ps # Should list containers
Solution: Set the secret
# Production:
npx wrangler secret put ANTHROPIC_API_KEY
# Local (.dev.vars):
echo "ANTHROPIC_API_KEY=sk-ant-your-key" > .dev.vars
Solution: Deploy the worker
npx wrangler deploy
Solution: Increase timeout in request
{
"question": "Your question",
"timeout": 60000
}
Edit src/index.ts to add custom logic:
# Watch logs in real-time
npx wrangler tail
# Use the monitor tool
node monitor.ts "your prompt" your_api_key
# Python (default)
curl -X POST https://your-worker.workers.dev/execute \
-d '{"question": "Fibonacci", "language": "python"}'
# JavaScript
curl -X POST https://your-worker.workers.dev/execute \
-d '{"question": "Fibonacci", "language": "javascript"}'
// Frontend integration
const response = await fetch('https://your-worker.workers.dev/execute', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ question: 'Calculate factorial of 5' })
});
const result = await response.json();
console.log(result.output);
See the main README.md for:
npx wrangler tailnode monitor.ts "test" your_keynpx wrangler containers listcurl https://your-worker.workers.dev/healthYou're all set! Start executing code with Claude AI on Cloudflare's edge network.