Skip to main content
The cf ask command lets you query your Cloudflare infrastructure using natural language. The AI analyzes your question, executes the necessary Cloudflare API calls, and provides a comprehensive markdown-formatted response.

Usage

clanker cf ask "<your-question>" [flags]

How it works

When you ask a question:
  1. Question analysis - The AI determines what Cloudflare operations are needed
  2. Context gathering - Relevant account information is collected
  3. API execution - Required Cloudflare API calls are made
  4. Response generation - Results are formatted into a clear, actionable answer
  5. Conversation history - Your question and answer are saved for follow-up questions

Flags

--account-id
string
Cloudflare account ID. If not provided, uses CLOUDFLARE_ACCOUNT_ID environment variable or value from config file.
--api-token
string
required
Cloudflare API token. If not provided, uses CLOUDFLARE_API_TOKEN environment variable or value from config file.
--zone
string
Default zone name for zone-specific queries. Useful when asking questions about a specific domain.
--ai-profile
string
AI profile to use for LLM queries. If not specified, uses the default provider from your config file.
--debug
boolean
default:"false"
Enable debug output to see API calls, conversation history, and internal processing.

Query types

The AI automatically routes your questions to specialized handlers:

DNS queries

Questions about DNS records, zones, and domain configuration.
clanker cf ask "show dns records for example.com"
Recognized keywords: dns, zone, record, a record, aaaa, cname, mx, txt, nameserver, ns record, srv, caa, domain

Worker queries

Questions about deployed Workers and their configuration.
clanker cf ask "what workers do I have deployed"

Zone queries

Questions about your Cloudflare zones and their settings.
clanker cf ask "list all my zones"

Tunnel queries

Questions about Cloudflare Tunnels.
clanker cf ask "list my tunnels"

Firewall queries

Questions about firewall rules and security settings.
clanker cf ask "show firewall rules for example.com"

General queries

Any other questions about your Cloudflare account are handled by the general AI agent, which can access account status and other context.
clanker cf ask "what resources am I using"
clanker cf ask "show me a summary of my account"

Examples

Basic zone information

clanker cf ask "list all my zones"
Example output:
You have 3 zones configured:

1. **example.com**
   - Status: Active
   - ID: zone-abc123
   - Nameservers: ns1.cloudflare.com, ns2.cloudflare.com

2. **api.example.net**
   - Status: Active
   - ID: zone-def456
   - Nameservers: ns3.cloudflare.com, ns4.cloudflare.com

3. **staging.example.org**
   - Status: Pending
   - ID: zone-ghi789
   - Nameservers: ns5.cloudflare.com, ns6.cloudflare.com

DNS record lookup

clanker cf ask "show dns records for example.com" --zone example.com
Example output:
DNS records for example.com:

**A Records:**
- www.example.com → 192.0.2.1 (Proxied)
- api.example.com → 192.0.2.2 (DNS only)

**CNAME Records:**
- blog.example.com → example.ghost.io

**MX Records:**
- example.com → mail.example.com (Priority: 10)

**TXT Records:**
- example.com → "v=spf1 include:_spf.example.com ~all"

Worker information

clanker cf ask "what workers do I have deployed"
Example output:
You have 4 Workers deployed:

1. **api-gateway**
   - Routes: api.example.com/*
   - Bindings: KV (CACHE), R2 (ASSETS)
   - Last modified: 2026-02-28

2. **redirect-handler**
   - Routes: example.com/old-path/*
   - Bindings: None
   - Last modified: 2026-02-15

3. **auth-middleware**
   - Routes: *.example.com/admin/*
   - Bindings: D1 (USERS)
   - Last modified: 2026-02-20

4. **image-optimizer**
   - Routes: cdn.example.com/images/*
   - Bindings: R2 (IMAGES)
   - Last modified: 2026-02-25

Tunnel status

clanker cf ask "list my tunnels"
Example output:
You have 2 Cloudflare Tunnels:

1. **production-tunnel**
   - ID: tunnel-xyz789
   - Status: Active
   - Connections: 2 active
   - Created: 2026-01-15

2. **staging-tunnel**
   - ID: tunnel-abc123
   - Status: Inactive
   - Connections: 0
   - Created: 2026-01-20

Conversation history

Conversation history is automatically maintained per Cloudflare account, allowing you to ask follow-up questions:
# First question
clanker cf ask "show dns records for example.com"

# Follow-up questions use context from previous answers
clanker cf ask "what about the MX records"
clanker cf ask "are any of those proxied"
The conversation history includes:
  • Previous questions and answers
  • Account status snapshot
  • Resource context
History is stored locally and persists between CLI sessions.

DNS modification plans

For DNS modification queries, the AI generates an execution plan instead of making changes directly:
clanker cf ask "add an A record for blog.example.com pointing to 192.0.2.10"
Example output:
DNS Modification Plan:

Summary: Add A record for blog.example.com

Commands to execute:

1. POST /zones/zone-abc123/dns_records
   Reason: Create new A record
   Body: {"type":"A","name":"blog","content":"192.0.2.10","ttl":1,"proxied":false}

To apply this plan, use: clanker cf apply <plan-file>
DNS modification plans are shown for review but not executed automatically. This prevents accidental changes to your DNS configuration.

Using different AI profiles

You can specify which AI provider to use for processing your queries:
clanker cf ask "list my zones" --ai-profile anthropic
Each provider requires appropriate API credentials configured in your ~/.clanker.yaml file.

Debugging queries

Use the --debug flag to see detailed information about how your query is processed:
clanker cf ask "list my zones" --debug
Debug output includes:
  • Conversation history loading status
  • Account status gathering
  • Query type determination (DNS, Worker, general, etc.)
  • API calls being made
  • AI prompt construction
  • Response generation

Authentication

The cf ask command requires authentication. Provide credentials using:
clanker cf ask "list my zones" \
  --account-id your-account-id \
  --api-token your-api-token

Best practices

When asking about DNS or zone-specific resources, include the zone name or use the --zone flag:
clanker cf ask "show dns records for example.com"
# or
clanker cf ask "show dns records" --zone example.com
Leverage conversation history for more efficient queries:
clanker cf ask "list all my zones"
clanker cf ask "tell me more about the first one"
clanker cf ask "what dns records does it have"
Always review DNS modification plans carefully before executing them to prevent accidental changes.
If you’re not getting the expected results, enable --debug to understand how your query is being processed.

Error handling

Error: question cannot be emptySolution: Provide a non-empty question string:
clanker cf ask "list my zones"
Error: cloudflare API token is requiredSolution: Provide your API token via flag, environment variable, or config file.
Error: DNS query failed: <details>Solutions:
  • Verify the zone name is correct
  • Check your API token has DNS read permissions
  • Use --debug to see detailed error information
Error: AI query failed: <details>Solutions:
  • Verify your AI provider credentials are correct
  • Check your API quota hasn’t been exceeded
  • Try a different AI profile with --ai-profile

Next steps

Deploy resources

Learn how to deploy Workers, Pages, and other resources

Cloudflare overview

Explore all Cloudflare commands

Natural language concepts

Understand how natural language processing works in Clanker

AI configuration

Configure AI providers and profiles

Build docs developers (and LLMs) love