Skip to main content
The cf deploy command deploys applications and resources to Cloudflare’s edge network.

Usage

clanker cf deploy <resource-type> [flags]

Resource types

Worker deployment

Deploy a Cloudflare Worker script to the edge.
clanker cf deploy worker --name <worker-name> --script <path-to-script> [flags]

Flags

--name
string
required
Worker name. This is the unique identifier for your Worker.
--script
string
required
Path to the Worker script file (JavaScript or TypeScript).
--compatibility-date
string
Compatibility date for the Worker runtime (e.g., 2024-01-01). Determines which features and behaviors are available.
--route
string[]
Worker routes. Can specify multiple routes by repeating the flag. Example: example.com/*
--kv
string[]
KV namespace bindings in the format BINDING=namespace-id. Can specify multiple bindings.
--r2
string[]
R2 bucket bindings in the format BINDING=bucket-name. Can specify multiple bindings.
--d1
string[]
D1 database bindings in the format BINDING=database-id. Can specify multiple bindings.
--env
string[]
Environment variables in the format KEY=value. Can specify multiple variables.

Examples

clanker cf deploy worker --name my-worker --script ./worker.js

Output

Deploying Worker 'my-worker'...
Worker deployed successfully!
URL: https://my-worker.your-subdomain.workers.dev
ID: worker-id-123

Pages deployment

Deploy static assets to Cloudflare Pages.
clanker cf deploy pages --project <project-name> --directory <build-dir> [flags]

Flags

--project
string
required
Pages project name. Must be an existing project or create one first with cf create pages.
--directory
string
required
Directory containing the built static assets to deploy.
--branch
string
Git branch name. Used to determine if this is a production or preview deployment.
--commit-hash
string
Git commit hash for deployment tracking.
--commit-message
string
Git commit message for deployment context.

Examples

clanker cf deploy pages --project my-site --directory ./dist

Output

Deploying to Pages project 'my-site'...
Pages deployed successfully!
URL: https://abc123.my-site.pages.dev

Creating resources

Before deploying, you may need to create supporting resources:

Create Pages project

clanker cf create pages --name <project-name> [flags]
--name
string
required
Project name for the new Pages project.
--production-branch
string
default:"main"
The Git branch to use for production deployments.
--build-command
string
Build command to run (e.g., npm run build).
--build-directory
string
Output directory from the build command (e.g., dist or build).

Create KV namespace

clanker cf create kv --name <namespace-name>
--name
string
required
KV namespace name.

Create D1 database

clanker cf create d1 --name <database-name>
--name
string
required
D1 database name.

Create R2 bucket

clanker cf create r2 --name <bucket-name> [flags]
--name
string
required
R2 bucket name.
--location
string
Location hint for optimal performance. Options: wnam (Western North America), enam (Eastern North America), weur (Western Europe), eeur (Eastern Europe), apac (Asia-Pacific).

Create Cloudflare Tunnel

clanker cf create tunnel --name <tunnel-name>
--name
string
required
Tunnel name.

Create DNS record

clanker cf create dns --zone <zone> --type <type> --name <name> --content <content> [flags]
--zone
string
required
Zone name or ID (e.g., example.com).
--type
string
required
DNS record type: A, AAAA, CNAME, MX, TXT, NS, SRV, CAA, etc.
--name
string
required
DNS record name (e.g., www, api, or @ for root).
--content
string
required
Record content (e.g., IP address for A records, domain for CNAME).
--ttl
integer
default:"1"
Time-to-live in seconds. Use 1 for automatic.
--proxied
boolean
default:"false"
Whether to proxy the record through Cloudflare (orange cloud).
--priority
integer
default:"0"
Priority for MX records.

Deleting resources

Delete Worker

clanker cf delete worker --name <worker-name>

Delete Pages project

clanker cf delete pages --name <project-name>

Delete KV namespace

clanker cf delete kv --id <namespace-id>

Delete D1 database

clanker cf delete d1 --id <database-id>

Delete R2 bucket

clanker cf delete r2 --name <bucket-name>

Delete Tunnel

clanker cf delete tunnel --id <tunnel-id>

Delete DNS record

clanker cf delete dns --zone <zone> --id <record-id>

Listing resources

View your existing Cloudflare resources:
clanker cf list zones
Example output:
[
  {
    "id": "zone-id-123",
    "name": "example.com",
    "status": "active",
    "name_servers": [
      "ns1.cloudflare.com",
      "ns2.cloudflare.com"
    ]
  }
]

Complete deployment example

Here’s a complete workflow for deploying a Worker with all supporting resources:
1

Create KV namespace for caching

clanker cf create kv --name my-cache
Output:
KV namespace created successfully!
ID: namespace-abc123
Title: my-cache
2

Create R2 bucket for assets

clanker cf create r2 --name my-assets --location wnam
Output:
R2 bucket created successfully!
Name: my-assets
Location: wnam
3

Deploy the Worker

clanker cf deploy worker \
  --name my-api \
  --script ./worker.js \
  --route "api.example.com/*" \
  --kv CACHE=namespace-abc123 \
  --r2 ASSETS=my-assets \
  --env API_URL=https://backend.example.com
Output:
Deploying Worker 'my-api'...
Worker deployed successfully!
URL: https://my-api.your-subdomain.workers.dev
ID: worker-xyz789
4

Create DNS record

clanker cf create dns \
  --zone example.com \
  --type CNAME \
  --name api \
  --content my-api.your-subdomain.workers.dev \
  --proxied
Output:
Creating DNS record CNAME api -> my-api.your-subdomain.workers.dev...
DNS record created successfully!
ID: record-123
Type: CNAME
Name: api.example.com
Content: my-api.your-subdomain.workers.dev
Proxied: true

Common authentication flags

--account-id
string
Cloudflare account ID. Can also be set via CLOUDFLARE_ACCOUNT_ID or in config file.
--api-token
string
required
Cloudflare API token. Can also be set via CLOUDFLARE_API_TOKEN or in config file.
--debug
boolean
default:"false"
Enable debug output for troubleshooting.

Error handling

Common errors and solutions:
Error: cloudflare API token is requiredSolution: Provide your API token via:
  • --api-token flag
  • CLOUDFLARE_API_TOKEN environment variable
  • cloudflare.api_token in ~/.clanker.yaml
Error: failed to deploy worker: <error details>Solutions:
  • Verify your script syntax is valid
  • Check that all bindings reference existing resources
  • Ensure your API token has Worker deployment permissions
  • Use --debug flag to see detailed error information
Error: failed to find zoneSolutions:
  • Verify the zone name is correct
  • Ensure the zone exists in your Cloudflare account
  • Check your API token has permission to access the zone

Next steps

Natural language queries

Query your deployments using natural language

Cloudflare overview

Learn about all Cloudflare commands

Configuration

Configure default Cloudflare settings

Provider guide

Deep dive into Cloudflare integration

Build docs developers (and LLMs) love