| name | cloudflare-dns |
| description | Use the flarectl CLI tool to manage Cloudflare DNS records, including listing, adding, updating, and deleting DNS records, as well as querying Zone information. Trigger this skill when the user mentions "Cloudflare DNS", "CF DNS", "add DNS record", "delete DNS record", "update DNS", "view DNS records", "cloudflare-dns", "flarectl", or any scenario involving Cloudflare DNS management. |
Cloudflare DNS Management
Environment Setup
Install flarectl
Current environment (Alpine Linux arm64) can use the pre-installed version. If not present, install from Release:
if ! which flarectl > /dev/null 2>&1; then
wget -q https://github.com/wsvn53/flarectl/releases/download/flarectl-v0.1.0-alpine-arm64/flarectl-linux-arm64 \
-O /usr/local/bin/flarectl && chmod +x /usr/local/bin/flarectl
fi
Auth Configuration
flarectl supports two authentication methods (API Token preferred):
Method 1: API Token (Recommended)
export CF_API_TOKEN=<your_token>
Method 2: Global API Key
export CF_API_KEY=<your_key>
export CF_API_EMAIL=<your_email>
Optional:
export CF_ACCOUNT_ID=<account_id>
Check whether environment variables are set:
[ -n "$CF_API_TOKEN" ] && echo "Token: set" || echo "Token: NOT SET"
[ -n "$CF_API_KEY" ] && echo "API Key: set" || echo "API Key: NOT SET"
If not set, inform the user of the required variable names and provide setup links:
Common Operations
List Zones
flarectl zone list
Example output:
ID NAME PLAN STATUS
abc123... example.com Free active
List DNS Records
flarectl dns list --zone example.com
flarectl dns list --zone example.com --type A
flarectl dns list --zone example.com --name sub.example.com
flarectl --json dns list --zone example.com
Add DNS Record
flarectl dns create --zone example.com --type A --name sub.example.com --content 1.2.3.4 --ttl 1
flarectl dns create --zone example.com --type CNAME --name www.example.com --content example.com --proxy
flarectl dns create --zone example.com --type MX --name example.com --content mail.example.com --priority 10
flarectl dns create --zone example.com --type TXT --name _dmarc.example.com --content "v=DMARC1; p=none"
flarectl dns create --zone example.com --type AAAA --name ipv6.example.com --content "2001:db8::1"
Parameter notes:
--ttl 1: Auto TTL (recommended); other values in seconds (e.g. --ttl 300)
--proxy: Enable Cloudflare orange cloud proxy (A/AAAA/CNAME only)
Update DNS Record
Update requires the record id, first get it with dns list:
flarectl --json dns list --zone example.com --name sub.example.com | python3 -c "
import sys,json
for r in json.load(sys.stdin):
print(r['id'], r['type'], r['name'], r['content'])
"
flarectl dns update --zone example.com --id <record_id> --content 5.6.7.8
flarectl dns update --zone example.com --id <record_id> --content 5.6.7.8 --proxy
Create or Update (Upsert)
flarectl dns create-or-update --zone example.com --type A --name sub.example.com --content 1.2.3.4
Delete DNS Record
flarectl --json dns list --zone example.com --name sub.example.com | python3 -c "
import sys,json
for r in json.load(sys.stdin):
print(r['id'], r['name'], r['type'])
"
flarectl dns delete --zone example.com --id <record_id>
Batch Delete Records with Same Name
flarectl --json dns list --zone example.com --name sub.example.com | python3 -c "
import sys,json,subprocess
for r in json.load(sys.stdin):
subprocess.run(['flarectl','dns','delete','--zone','example.com','--id',r['id']])
print('Deleted:', r['id'], r['type'], r['content'])
"
Workflow
- Verify auth: Check if
CF_API_TOKEN or CF_API_KEY+CF_API_EMAIL is set
- Confirm domain: If the user hasn't specified a zone, first use
flarectl zone list to list available domains for the user to choose
- Execute operation: Run list/create/update/delete as needed
- Show results: After operation, use
flarectl dns list --zone <zone> to display the latest record status
Notes
- Delete is irreversible, confirm with the user before executing
--proxy only supports A, AAAA, CNAME record types
- MX records must specify
--priority
- TXT record values with spaces must be wrapped in quotes
flarectl --json global flag must be placed before the subcommand