Manage Cloudflare infrastructure including DNS records, zones, SSL/TLS, caching, firewall rules, Workers, Pages, and analytics...
Created by After Dark Systems, LLC
This skill provides comprehensive Cloudflare infrastructure management capabilities through the Cloudflare API v4. It enables full control over domains, DNS, security, performance, and serverless deployments.
API credentials are stored at ~/cloudflare_global_key. The file contains:
Recommended: Use the Bearer token for API calls:
-H "Authorization: Bearer <token>"
To verify token validity:
./scripts/cf-api.sh verify-token
All scripts are located in the scripts/ directory and use the credentials from ~/cloudflare_global_key.
./scripts/zones.sh list
./scripts/zones.sh get <zone_id>
# or by domain name
./scripts/zones.sh get-by-name example.com
./scripts/dns.sh list <zone_id>
# Filter by type
./scripts/dns.sh list <zone_id> --type A
./scripts/dns.sh create <zone_id> \
--type A \
--name subdomain \
--content 192.0.2.1 \
--ttl 3600 \
--proxied true
./scripts/dns.sh update <zone_id> <record_id> \
--content 192.0.2.2 \
--ttl 1800
./scripts/dns.sh delete <zone_id> <record_id>
# Purge everything
./scripts/cache.sh purge-all <zone_id>
# Purge specific URLs
./scripts/cache.sh purge-urls <zone_id> "https://example.com/page1" "https://example.com/page2"
# Purge by cache tags
./scripts/cache.sh purge-tags <zone_id> tag1 tag2
# Get current SSL mode
./scripts/ssl.sh get-mode <zone_id>
# Set SSL mode (off, flexible, full, strict)
./scripts/ssl.sh set-mode <zone_id> strict
# List firewall rules
./scripts/firewall.sh list <zone_id>
# Block an IP
./scripts/ip-access.sh block <zone_id> 192.0.2.100 "Suspicious activity"
# Allow an IP
./scripts/ip-access.sh allow <zone_id> 192.0.2.50 "Trusted server"
# List workers
./scripts/workers.sh list
# Deploy a worker
./scripts/workers.sh deploy <script_name> <script_file>
# Delete a worker
./scripts/workers.sh delete <script_name>
./scripts/zones.sh create example.com
ZONE_ID=$(./scripts/zones.sh get-by-name example.com --id-only)
./scripts/dns.sh create $ZONE_ID --type A --name @ --content 192.0.2.1 --proxied true
./scripts/dns.sh create $ZONE_ID --type CNAME --name www --content example.com --proxied true
./scripts/dns.sh create $ZONE_ID --type MX --name @ --content mail.example.com --priority 10
./scripts/ssl.sh set-mode $ZONE_ID strict
./scripts/dns-import.sh <zone_id> records.txt
# Block specific IP
./scripts/ip-access.sh block <zone_id> <attacker_ip> "Attack mitigation"
# Enable Under Attack Mode
./scripts/zone-settings.sh set <zone_id> security_level under_attack
# Purge cache if compromised content was cached
./scripts/cache.sh purge-all <zone_id>
See reference.md for complete Cloudflare API v4 documentation including:
The templates/ directory contains JSON templates for common operations:
dns-records.json - Common DNS record configurationsfirewall-rules.json - Firewall rule templatespage-rules.json - Page rule templatesworker-config.json - Worker configuration templateAll scripts return appropriate exit codes:
Error responses include the Cloudflare error code and message for debugging.
For issues with this skill, contact After Dark Systems, LLC.
For Cloudflare API documentation: https://developers.cloudflare.com/api/