cf (Cloudflare)
The cf command provides direct access to your Cloudflare infrastructure. It includes subcommands for querying, creating, deploying, and deleting Cloudflare resources across DNS, Workers, Pages, KV, D1, R2, Tunnels, and more.
The command can also be invoked using its full alias: clanker cloudflare.
Usage
bash
clanker cf <subcommand> [flags]Subcommands Overview
Query and Analysis
| Subcommand | Description |
|---|---|
cf ask <question> | Ask natural language questions about your Cloudflare account using AI |
cf list <resource> | List Cloudflare resources (zones, workers, KV namespaces, D1 databases, R2 buckets, tunnels, DNS records, firewall rules, page rules) |
Resource Management
| Subcommand | Description |
|---|---|
cf create <resource> | Create Cloudflare resources (Pages projects, KV namespaces, D1 databases, R2 buckets, Tunnels, DNS records) |
cf deploy <resource> | Deploy Workers and Pages applications |
cf delete <resource> | Delete Cloudflare resources (Workers, Pages projects, KV namespaces, D1 databases, R2 buckets, Tunnels, DNS records) |
Supported Resources
The cf command tree covers the following Cloudflare services:
- DNS: Zone listing, DNS record management (A, AAAA, CNAME, MX, TXT, SRV, CAA, and more)
- Workers: Script deployment with KV, R2, D1, and environment variable bindings
- Pages: Project creation and asset deployment
- KV: Workers KV namespace creation and deletion
- D1: Serverless SQL database creation and deletion
- R2: Object storage bucket creation and deletion
- Tunnels: Cloudflare Tunnel creation and deletion
- WAF: Firewall rule listing
- Page Rules: Page rule listing
Authentication
The cf command requires a Cloudflare API token. It can be provided in any of the following ways (in order of precedence):
- The
--api-tokenflag on the command - The
CLOUDFLARE_API_TOKENorCF_API_TOKENenvironment variable - The
cloudflare.api_tokenvalue in~/.clanker.yaml
An account ID is optional but recommended for account-scoped operations. It can be set via:
- The
--account-idflag on the command - The
CLOUDFLARE_ACCOUNT_IDenvironment variable - The
cloudflare.account_idvalue in~/.clanker.yaml
Examples
bash
# Ask a natural language question about your Cloudflare account
clanker cf ask "list all my zones"
# List all DNS zones
clanker cf list zones
# Create a DNS record
clanker cf create dns --zone example.com --type A --name www --content 1.2.3.4
# Deploy a Worker script
clanker cf deploy worker --name my-api --script ./worker.js
# Create a KV namespace
clanker cf create kv --name my-namespace
# Create an R2 bucket
clanker cf create r2 --name my-bucket
# Deploy to Cloudflare Pages
clanker cf deploy pages --project my-site --directory ./dist
# Delete a Worker
clanker cf delete worker --name my-apiSee Also
- Configuration -- Setting up Cloudflare credentials
- credentials -- Storing Cloudflare credentials in the clanker backend
- ask -- General natural language infrastructure queries