Cloudflare Manager
qdhenry/Claude-Command-Suite
Workers, KV Storage, R2, Pages, DNS 및 Routes를 배포하기 위한 포괄적인 Cloudflare 계정 관리 도구입니다. Cloudflare 서비스를 배포하거나, Worker 컨테이너를 관리하거나, KV/R2 스토리지를 구성하거나, DNS/라우팅을 설정할 때 사용합니다. .env 파일에 CLOUDFLARE_API_KEY가 포함되어 있어야 하며, 의존성이 설치된 Bun 런타임이 필요합니다.
...모든 것을 확장하십시오소개 Cloudflare Manager
Cloudflare Manager 스킬은 다양한 Cloudflare 서비스를 관리하기 위한 통합 솔루션을 제공하며, Cloudflare Workers, KV Storage, R2 버킷, Pages, DNS 레코드 및 라우팅의 배포와 구성을 간소화합니다. 이 스킬을 사용하면 사용자가 Cloudflare 대시보드에 직접 접속할 필요 없이 서버리스 애플리케이션을 배포하고 스토리지 솔루션을 관리하는 과정을 단순화할 수 있습니다. 이 스킬은 API 자격 증명 검증, 배포 URL 조회, 오류 처리와 같은 작업을 자동화하여 Cloudflare의 강력한 서비스를 활용하고자 하는 사용자에게 원활한 경험을 제공합니다.
자주 묻는 질문
Cloudflare Manager 스킬은 어떻게 설정하나요?
스킬을 설정하려면 'bun install'을 사용하여 종속성을 설치하고 '.env' 파일에서 API 키를 구성하십시오. 또한 'bun scripts/validate-api-key.ts'를 사용하여 API 자격 증명을 검증해야 합니다.
Cloudflare API 토큰에 필요한 권한은 무엇입니까?
Cloudflare API 토큰에는 'Workers Scripts: Edit', 'Workers KV Storage: Edit', 'Workers R2 Storage: Edit', 'Cloudflare Pages: Edit' 및 'DNS: Edit'(사용자 지정 도메인을 사용하는 경우)에 대한 권한이 있어야 합니다.
이 스킬을 여러 Cloudflare 계정에서 사용할 수 있나요?
예, '.env' 파일에 올바른 계정 ID를 지정하면 이 스킬이 여러 Cloudflare 계정을 지원할 수 있습니다. 단, 계정 ID는 자동으로 감지되므로 필수 사항은 아닙니다.
Cloudflare API 유효성 검사가 실패하면 어떻게 되나요?
401/403 오류로 유효성 검증이 실패할 경우, '.env' 파일의 API 토큰이 올바른지 확인하십시오. 네트워크 문제의 경우 인터넷 연결 상태를 확인하십시오. 또한 '--no-cache' 플래그를 사용하여 강제적으로 새로운 유효성 검증을 수행할 수도 있습니다.
KV Storage 사용 시 제한 사항이 있나요?
KV 스토리지(KV Storage)는 최종 일관성(eventual consistency)을 사용하므로, 쓰기 작업이 반영되는 데 최대 60초가 소요될 수 있습니다. 데이터를 쓰거나 읽을 때 이 점을 유의하시기 바랍니다.
Cloudflare Manager
Comprehensive Cloudflare service management skill that enables deployment and configuration of Workers, KV Storage, R2 buckets, Pages, DNS records, and routing. Automatically validates API credentials, extracts deployment URLs, and provides actionable error messages.
Initial Setup
Before using this skill for the first time:
Install Dependencies
cd ~/.claude/skills/cloudflare-managerbun install
Configure API Key
Create a
.envfile in your project root:CLOUDFLARE_API_KEY=your_api_token_hereCLOUDFLARE_ACCOUNT_ID=your_account_id # Optional, auto-detectedGetting your API token:
- Visit https://dash.cloudflare.com/profile/api-tokens
- Click "Create Token"
- Use "Edit Cloudflare Workers" template (or create custom token)
- Required permissions:
- Account > Workers Scripts > Edit
- Account > Workers KV Storage > Edit
- Account > Workers R2 Storage > Edit
- Account > Cloudflare Pages > Edit
- Zone > DNS > Edit (if using custom domains)
Validate Credentials
Run validation to verify your API key and check permissions:
cd ~/.claude/skills/cloudflare-managerbun scripts/validate-api-key.ts
Expected output:
✅ API key is valid!ℹ️ Token Status: activeℹ️ Account: Your Account Name (abc123...)🔑 Granted Permissions: ✅ Workers Scripts: Edit ✅ Workers KV Storage: Edit ✅ Workers R2 Storage: EditTroubleshooting validation:
- If validation fails with 401/403: Check your API token is correct in
.env - If validation fails with network error: Check internet connection
- Use
--no-cacheflag to force fresh validation:bun scripts/validate-api-key.ts --no-cache
- If validation fails with 401/403: Check your API token is correct in
Current API Permissions
Run bun scripts/validate-api-key.ts to populate this section with your current permissions.
Quick Start Guide
Deploy a Worker Container
To deploy a new worker container sandbox:
# Using the skillbun scripts/workers.ts deploy worker-name ./worker-script.jsWhat happens:
- Creates new worker container
- Deploys JavaScript/TypeScript code
- Automatically extracts and returns Cloudflare-generated URL (e.g.,
https://worker-name.username.workers.dev) - Returns worker ID and configuration
Example conversation:
User: "Set up and deploy a new cloudflare worker container sandbox named 'api-handler' and return the URL"Claude: [Deploys worker using bun scripts/workers.ts deploy api-handler ./worker.js] Returns URL: https://api-handler.username.workers.devExit codes:
0: Success - worker deployed and URL returned1: Failure - check error message for details
Performance: Deployment typically completes in 2-5 seconds
Create and Use KV Storage
To create a KV namespace and store data:
# Create namespacebun scripts/kv-storage.ts create-namespace user-sessions# Returns: Namespace ID (e.g., abc123def456)# Save this ID for binding to workers# Write key-value pairbun scripts/kv-storage.ts write <namespace-id> "session:user123" '{"userId":"123","token":"abc"}'# Read valuebun scripts/kv-storage.ts read <namespace-id> "session:user123"# Returns: {"userId":"123","token":"abc"}# List all keys (useful for debugging)bun scripts/kv-storage.ts list-keys <namespace-id># Delete a keybun scripts/kv-storage.ts delete <namespace-id> "session:user123"
Important: KV storage uses eventual consistency. Writes may take up to 60 seconds to propagate globally. For immediate reads, use the same edge location where you wrote the data.
Create R2 Bucket and Upload Files
To create an R2 bucket and manage objects:
# Create bucketbun scripts/r2-storage.ts create-bucket media-assets# Upload filebun scripts/r2-storage.ts upload media-assets ./images/logo.png logo.png# List objectsbun scripts/r2-storage.ts list-objects media-assets# Download objectbun scripts/r2-storage.ts download media-assets logo.png ./downloaded-logo.png
Deploy to Cloudflare Pages
To deploy a static site or application to Pages:
# Create Pages project (or get existing project info)bun scripts/pages.ts deploy my-app ./dist# Returns: https://my-app.pages.dev# Set environment variablebun scripts/pages.ts set-env my-app API_URL https://api.example.com# Set environment variable for specific environmentbun scripts/pages.ts set-env my-app DEBUG true --env preview# Get deployment URLbun scripts/pages.ts get-url my-app
Auto-extracted URLs: The Pages script automatically extracts and returns the Cloudflare-generated URL (e.g., https://my-app.pages.dev) from the deployment response.
Note: The API creates the project structure, but for actual file uploads, you'll need Wrangler CLI:
npx wrangler pages deploy ./dist --project-name=my-app
Why this works: The skill creates/verifies the Pages project and returns the URL. For the initial deployment with files, Wrangler handles the complex multipart upload process.
Configure DNS and Routes
To create DNS records and configure worker routes:
# Create DNS A recordbun scripts/dns-routes.ts create-dns example.com A api 192.168.1.1# Route pattern to workerbun scripts/dns-routes.ts create-route example.com "*.example.com/api/*" api-handler
Common Workflows
Multi-Service Setup
To set up a complete application with worker, KV storage, and R2 bucket:
Create KV namespace for caching
bun scripts/kv-storage.ts create-namespace app-cache
Create R2 bucket for media
bun scripts/r2-storage.ts create-bucket app-media
Deploy worker with bindings
bun scripts/workers.ts deploy app-worker ./worker.js --kv-binding app-cache --r2-binding app-media
Configure route
bun scripts/dns-routes.ts create-route example.com "example.com/*" app-worker
Update Worker Configuration
To update an existing worker's code or bindings:
# Update worker codebun scripts/workers.ts update worker-name ./new-worker-script.js# Get worker detailsbun scripts/workers.ts get worker-name# List all workersbun scripts/workers.ts list
Bulk KV Operations
To perform bulk operations on KV storage:
# Bulk write from JSON filebun scripts/kv-storage.ts bulk-write namespace-name ./data.json# Delete multiple keysbun scripts/kv-storage.ts bulk-delete namespace-name key1 key2 key3
Error Handling
Missing API Key
If .env file is missing or CLOUDFLARE_API_KEY is not set:
Error: CLOUDFLARE_API_KEY not found in environmentSolution: Create .env file in project root: echo "CLOUDFLARE_API_KEY=your_token_here" > .envInvalid Permissions
If API token lacks required permissions:
Error: Insufficient permissions for Workers deploymentRequired: Workers Scripts: EditCurrent: Workers Scripts: ReadSolution: Update token permissions at: https://dash.cloudflare.com/profile/api-tokensAPI Rate Limiting
If too many requests are made:
Error: Rate limit exceeded (429)Solution: Retry automatically with exponential backoff (3 attempts)Network Issues
If API is unreachable:
Error: Failed to connect to Cloudflare APISolution: Check internet connection and retryBest Practices
Security:
- Never commit
.envfiles - always add to.gitignore - Use token-based authentication (not API keys)
- Rotate tokens periodically (every 90 days recommended)
- Use least-privilege principle: only grant required permissions
- Store secrets via Wrangler CLI:
wrangler secret put SECRET_NAME
Performance:
- Deploy workers to minimize latency (they run at Cloudflare edge)
- Use KV storage for frequently-read data (not frequently-written)
- Use R2 for large files (KV has 25MB limit per key)
- Enable caching with appropriate TTLs
- Keep worker scripts under 1MB for faster cold starts
Development Workflow:
- Test locally first:
wrangler devfor local testing - Use staging environment before production
- Validate credentials after token updates:
bun scripts/validate-api-key.ts - Monitor worker logs:
wrangler tail worker-name - Version your workers: use names like
api-v1,api-v2
Naming Conventions:
- Workers: Use descriptive names (e.g.,
user-auth-workernotworker1) - KV namespaces: Include purpose (e.g.,
app-sessions,api-cache) - R2 buckets: Use lowercase with hyphens (e.g.,
media-assets-prod) - Be consistent across your infrastructure
Resource Management:
- Delete unused workers, namespaces, and buckets
- Monitor usage in Cloudflare dashboard
- Free tier limits: 100,000 requests/day for Workers
- Set up billing alerts to avoid surprises
Advanced Usage
For advanced scenarios including:
- Complex routing configurations
- Multi-region deployments
- Custom domain setup
- Worker-to-worker communication
- Durable Objects integration
- Bulk operations and migrations
See examples.md for comprehensive examples and patterns.
Script Reference
All scripts are located in ~/.claude/skills/cloudflare-manager/scripts/:
- validate-api-key.ts: Validate API credentials and display permissions
- workers.ts: Deploy, update, and manage Workers
- kv-storage.ts: Create and manage KV namespaces and key-value pairs
- r2-storage.ts: Create and manage R2 buckets and objects
- pages.ts: Deploy and configure Cloudflare Pages projects
- dns-routes.ts: Configure DNS records and worker routes
- utils.ts: Shared utilities for API calls and error handling
Templates
Starter templates are available in ~/.claude/skills/cloudflare-manager/templates/:
- worker-template.js: Basic worker template with fetch handler
- wrangler.toml.template: Wrangler configuration template
Troubleshooting
Common Issues and Solutions
Issue: "Worker deployment failed with unknown error"
Symptoms: Deployment command exits with error code 1, no specific error message
Solutions:
- Check script syntax:
node --check ./worker.js - Verify file exists:
ls -lh ./worker.js - Re-validate API key:
bun scripts/validate-api-key.ts --no-cache - Check worker name is valid (alphanumeric, hyphens, underscores only)
Issue: "KV namespace not found"
Symptoms: Error when trying to read/write to namespace
Solutions:
- List all namespaces:
bun scripts/kv-storage.ts list-namespaces - Verify you're using namespace ID (not name) in commands
- Check namespace wasn't deleted
- Ensure API token has KV Storage permissions
Issue: "R2 bucket already exists" or "Bucket name taken"
Symptoms: Cannot create bucket with chosen name
Solutions:
- Bucket names must be globally unique across all Cloudflare accounts
- Try a more specific name:
my-app-media-2024instead ofmedia - Use existing bucket:
bun scripts/r2-storage.ts list-buckets - Names must be 3-63 characters, lowercase letters/numbers/hyphens only
Issue: "Pages deployment timeout" or "Deployment pending"
Symptoms: Deployment doesn't complete, stays in pending state
Solutions:
- Check deployment status:
bun scripts/pages.ts list-deployments project-name - View in dashboard: https://dash.cloudflare.com/pages
- Large deployments (>1000 files) may take 5-10 minutes
- Cancel and retry if stuck: Delete project and recreate
Issue: "DNS record creation failed"
Symptoms: Cannot create DNS records or routes
Solutions:
- Verify zone exists:
bun scripts/dns-routes.ts list-zones - Ensure domain is added to Cloudflare and active
- Check nameservers point to Cloudflare:
dig NS yourdomain.com - Verify API token has Zone > DNS > Edit permission
Issue: "API rate limit exceeded (429)"
Symptoms: Commands fail with "Too many requests"
Solutions:
- Scripts automatically retry with exponential backoff
- Wait 1-2 minutes before retrying manually
- Reduce concurrent operations
- Rate limits: 1200 requests per 5 minutes
Issue: "CLOUDFLARE_API_KEY not found in environment"
Symptoms: Commands fail immediately with environment error
Solutions:
- Create
.envfile in project root (not skill directory) - Verify file content:
cat .env | grep CLOUDFLARE_API_KEY - Ensure no extra spaces:
CLOUDFLARE_API_KEY=token(no spaces around=) - Run commands from project root where
.envexists
Quick Fix:
cd /path/to/your/projectecho "CLOUDFLARE_API_KEY=your_token_here" > .envbun scripts/validate-api-key.ts
Security Notes
- API keys are never logged or displayed in output
- All API requests use HTTPS
- User inputs are validated before API calls
- Destructive operations (delete) require confirmation
- Permissions are cached for 24 hours to minimize token exposure
Additional Resources
- Cloudflare API Documentation: https://developers.cloudflare.com/api/
- Workers Documentation: https://developers.cloudflare.com/workers/
- KV Storage Guide: https://developers.cloudflare.com/kv/
- R2 Storage Guide: https://developers.cloudflare.com/r2/
- Pages Documentation: https://developers.cloudflare.com/pages/
Cloudflare Manager 설치
스킬 파일을 다운로드하여 .claude/skills/ 디렉터리에 압축을 풀어주세요.
ZIP 다운로드저장소를 클론하고 스킬 파일을 프로젝트에 복사하세요.
git clone https://github.com/qdhenry/Claude-Command-Suite/blob/main/.claude/skills/cloudflare-manager/SKILL.md # Copy SKILL.md to your .claude/skills/ directory
복사





집
