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
How it works
When you ask a question:- Question analysis - The AI determines what Cloudflare operations are needed
- Context gathering - Relevant account information is collected
- API execution - Required Cloudflare API calls are made
- Response generation - Results are formatted into a clear, actionable answer
- Conversation history - Your question and answer are saved for follow-up questions
Flags
Cloudflare account ID. If not provided, uses
CLOUDFLARE_ACCOUNT_ID environment variable or value from config file.Cloudflare API token. If not provided, uses
CLOUDFLARE_API_TOKEN environment variable or value from config file.Default zone name for zone-specific queries. Useful when asking questions about a specific domain.
AI profile to use for LLM queries. If not specified, uses the default provider from your config file.
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.dns, zone, record, a record, aaaa, cname, mx, txt, nameserver, ns record, srv, caa, domain
Worker queries
Questions about deployed Workers and their configuration.Zone queries
Questions about your Cloudflare zones and their settings.Tunnel queries
Questions about Cloudflare Tunnels.Firewall queries
Questions about firewall rules and security settings.General queries
Any other questions about your Cloudflare account are handled by the general AI agent, which can access account status and other context.Examples
Basic zone information
DNS record lookup
Worker information
Tunnel status
Conversation history
Conversation history is automatically maintained per Cloudflare account, allowing you to ask follow-up questions:- Previous questions and answers
- Account status snapshot
- Resource context
DNS modification plans
For DNS modification queries, the AI generates an execution plan instead of making changes directly: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.yaml file.
Debugging queries
Use the--debug flag to see detailed information about how your query is processed:
- Conversation history loading status
- Account status gathering
- Query type determination (DNS, Worker, general, etc.)
- API calls being made
- AI prompt construction
- Response generation
Authentication
Thecf ask command requires authentication. Provide credentials using:
- Command flags
- Environment variables
- Config file
Best practices
Be specific with zone names
Be specific with zone names
When asking about DNS or zone-specific resources, include the zone name or use the
--zone flag:Use follow-up questions
Use follow-up questions
Leverage conversation history for more efficient queries:
Review DNS plans before applying
Review DNS plans before applying
Always review DNS modification plans carefully before executing them to prevent accidental changes.
Use debug mode for troubleshooting
Use debug mode for troubleshooting
If you’re not getting the expected results, enable
--debug to understand how your query is being processed.Error handling
Empty question
Empty question
Error:
question cannot be emptySolution: Provide a non-empty question string:API token required
API token required
Error:
cloudflare API token is requiredSolution: Provide your API token via flag, environment variable, or config file.DNS query failed
DNS query failed
Error:
DNS query failed: <details>Solutions:- Verify the zone name is correct
- Check your API token has DNS read permissions
- Use
--debugto see detailed error information
AI query failed
AI query failed
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