Gestionnaire Cloudflare
/SKILLCompétence complète de gestion des services Cloudflare qui permet le déploiement et la configuration des travailleurs, du stockage KV, des buckets R2, des pages, des enregistrements DNS et du routage.
name: Cloudflare Manager
description: Comprehensive Cloudflare account management for deploying Workers, KV Storage, R2, Pages, DNS, and Routes. Use when deploying cloudflare services, managing worker containers, configuring KV/R2 storage, or setting up DNS/routing. Requires CLOUDFLAREAPIKEY in .env and Bun runtime with dependencies installed.
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-manager
bun install- Configure API Key
Create a .env file in your project root:
CLOUDFLARE_API_KEY=your_api_token_here
CLOUDFLARE_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-manager
bun scripts/validate-api-key.tsExpected 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
Current API Permissions
<!-- PERMISSIONS_START -->
Run bun scripts/validate-api-key.ts to populate this section with your current permissions.
<!-- PERMISSIONS_END -->
Quick Start Guide
Deploy a Worker Container
To deploy a new worker container sandbox:
# Using the skill
bun 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 namespace
bun scripts/kv-storage.ts create-namespace user-sessions
# Returns: Namespace ID (e.g., abc123def456)
# Save this ID for binding to workers
# Write key-value pair
bun scripts/kv-storage.ts write <namespace-id> "session:user123" '{"userId":"123","token":"abc"}'
# Read value
bun 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 key
bun 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 bucket
bun scripts/r2-storage.ts create-bucket media-assets
# Upload file
bun scripts/r2-storage.ts upload media-assets ./images/logo.png logo.png
# List objects
bun scripts/r2-storage.ts list-objects media-assets
# Download object
bun scripts/r2-storage.ts download media-assets logo.png ./downloaded-logo.pngDeploy 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 variable
bun scripts/pages.ts set-env my-app API_URL https://api.example.com
# Set environment variable for specific environment
bun scripts/pages.ts set-env my-app DEBUG true --env preview
# Get deployment URL
bun scripts/pages.ts get-url my-app