skills/core-openclaw/cloudflare/SKILL.md
Cloudflare API: DNS, Zones, Pages, Access, Workers, R2. Account ID: <your-account-id>
npx skillsauth add alphaonedev/openclaw-graph cloudflareInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill provides programmatic access to Cloudflare's API for managing DNS records, zones, Pages sites, Access policies, Workers scripts, and R2 storage. It uses the specified account ID (YOUR_CLOUDFLARE_ACCOUNT_ID) to perform operations securely.
Use this skill for automating infrastructure tasks like updating DNS records during deployments, securing applications with Access, deploying static sites via Pages, running edge compute with Workers, managing object storage in R2, or creating/deleting zones. Apply it in scripts, CI/CD pipelines, or when integrating Cloudflare with other services.
$CLOUDFLARE_API_TOKEN; include the account ID in API requests.Always authenticate requests with $CLOUDFLARE_API_TOKEN. Use HTTP headers for API calls (e.g., Authorization: Bearer $CLOUDFLARE_API_TOKEN). For CLI, install Wrangler and log in with wrangler login. Structure requests with JSON payloads and handle responses via status codes. Prefix API endpoints with https://api.cloudflare.com/client/v4 and include the account ID in paths, like /accounts/YOUR_CLOUDFLARE_ACCOUNT_ID/zones.
/zones/{zone_id}/dns_records/{record_id} with JSON body like {"type":"A","name":"example.com","content":"192.0.2.1","ttl":3600}./zones with body {"name":"example.com","account":{"id":"YOUR_CLOUDFLARE_ACCOUNT_ID"}}.wrangler pages deploy ./build --project-name=my-site./access/policies with body {"name":"Block IP","precedence":1,"decision":"deny","request":{"ip":"1.1.1.1"}}./accounts/YOUR_CLOUDFLARE_ACCOUNT_ID/workers/scripts/my-worker with script content./accounts/YOUR_CLOUDFLARE_ACCOUNT_ID/r2/buckets/my-bucket/objects/my-file with file data.
Code snippet for DNS update:curl -X PUT "https://api.cloudflare.com/client/v4/zones/zone_id/dns_records/record_id" \
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
-H "Content-Type: application/json" \
--data '{"type":"A","name":"example.com","content":"192.0.2.1"}'
Config format: Store API token in .env as CLOUDFLARE_API_TOKEN=your_token, and load it in scripts.
Integrate by exporting $CLOUDFLARE_API_TOKEN in your environment. For Node.js, use the @cloudflare/workers SDK: install via npm i @cloudflare/workers, then import and initialize with the token. In Python, use cloudflare library: pip install cloudflare, and authenticate with Cloudflare(api_token=os.environ['CLOUDFLARE_API_TOKEN']). Always validate responses for the account ID to avoid cross-account errors. For Wrangler, run wrangler whoami to verify login before commands.
Check HTTP status codes: 200-299 for success, 4xx for client errors (e.g., 401 Unauthorized if token is invalid), and 5xx for server issues. For API errors, parse the JSON response body for "errors" array, e.g., {"errors":[{"code":1000,"message":"Bad request"}]}. Retry transient errors (e.g., 429 Rate Limit) with exponential backoff. In scripts, wrap calls in try-catch blocks:
try {
const response = await fetch('https://api.cloudflare.com/client/v4/...', { headers: { Authorization: `Bearer ${process.env.CLOUDFLARE_API_TOKEN}` } });
if (!response.ok) throw new Error(`HTTP error: ${response.status}`);
} catch (error) {
console.error('API call failed:', error.message);
}
Log detailed error messages including the endpoint and parameters for debugging.
/zones?name=example.com. Then, use the record ID to update: PUT /zones/zone_id/dns_records/record_id with body {"content":"new_ip_address"}. This ensures the domain points to the latest server IP.worker.js, then run wrangler publish --name my-worker. For API integration, upload via PUT /accounts/YOUR_CLOUDFLARE_ACCOUNT_ID/workers/scripts/my-worker with the script content, then bind it to a route with POST /zones/zone_id/workers/routes.tools
Root web development: project structure, tooling selection, deployment decisions
development
WebAssembly: Rust/Go/C to WASM, wasm-bindgen, Emscripten, WASM Component Model
development
Vue 3: Composition API script setup, Pinia, Vue Router 4, SFCs, Vite, Nuxt 3
tools
Tailwind CSS 4: utility classes, config, JIT, arbitrary values, darkMode, plugins, shadcn/ui