This is a systematic approach to debugging Cloudflare issues using their API instead of clicking around the dashboard. When you hit redirect loops, SSL errors, or DNS problems, it walks you through gathering evidence with curl commands before making changes. The structure is solid: get zone ID, query actual configuration state, cross-reference settings that might conflict, then apply targeted fixes. It covers the common gotchas like flexible SSL mode causing redirect loops and includes investigation patterns for DNS, certificates, and origin errors. The emphasis on evidence over assumptions is right, though you'll still need to know enough about Cloudflare's architecture to ask the right questions. Useful if you troubleshoot Cloudflare setups regularly and want a methodical checklist.
npx -y skills add daymade/claude-code-skills --skill cloudflare-troubleshooting --agent claude-codeInstalls into .claude/skills of the current project.
Methodology base: the general evidence-driven network-diagnosis discipline (falsification, layered isolation, counter-review) lives in the debugging-network-issues skill. This skill is the Cloudflare domain layer on top of it.
Investigate with evidence, not assumptions. Always query Cloudflare API to examine actual configuration before diagnosing issues. The skill's value is the systematic investigation methodology, not predetermined solutions.
Request from user:
Global API Key location: Cloudflare Dashboard → My Profile → API Tokens → View Global API Key
First step for any Cloudflare troubleshooting - obtain the zone ID:
curl -s -X GET "https://api.cloudflare.com/client/v4/zones?name=<domain>" \
-H "X-Auth-Email: <email>" \
-H "X-Auth-Key: <api_key>" | jq '.'
Extract zone_id from result[0].id for subsequent API calls.
For each issue, gather evidence before making conclusions. Use Cloudflare API to inspect:
Evidence gathering sequence:
Check SSL/TLS mode:
curl -X GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/settings/ssl" \
-H "X-Auth-Email: email" \
-H "X-Auth-Key: key"
Look for: result.value - tells current SSL mode
Check Always Use HTTPS setting:
curl -X GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/settings/always_use_https" \
-H "X-Auth-Email: email" \
-H "X-Auth-Key: key"
Check Page Rules for redirects:
curl -X GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/pagerules" \
-H "X-Auth-Email: email" \
-H "X-Auth-Key: key"
Look for: forwarding_url or always_use_https actions
Test origin server directly (if possible):
curl -I -H "Host: <domain>" https://<origin_ip>
Diagnosis logic:
Fix:
curl -X PATCH "https://api.cloudflare.com/client/v4/zones/{zone_id}/settings/ssl" \
-H "X-Auth-Email: email" \
-H "X-Auth-Key: key" \
-H "Content-Type: application/json" \
--data '{"value":"full"}'
Purge cache after fix:
curl -X POST "https://api.cloudflare.com/client/v4/zones/{zone_id}/purge_cache" \
-H "X-Auth-Email: email" \
-H "X-Auth-Key: key" \
-d '{"purge_everything":true}'
Evidence gathering:
List DNS records:
curl -X GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/dns_records" \
-H "X-Auth-Email: email" \
-H "X-Auth-Key: key"
Check external DNS resolution:
dig <domain>
dig @8.8.8.8 <domain>
Check DNSSEC status:
curl -X GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/dnssec" \
-H "X-Auth-Email: email" \
-H "X-Auth-Key: key"
Look for:
Evidence gathering:
Check SSL certificate status:
curl -X GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/ssl/certificate_packs" \
-H "X-Auth-Email: email" \
-H "X-Auth-Key: key"
Check origin certificate (if using Full Strict):
openssl s_client -connect <origin_ip>:443 -servername <domain>
Check SSL settings:
Common issues:
Evidence gathering:
Check if origin is reachable:
curl -I -H "Host: <domain>" https://<origin_ip>
Check DNS records point to correct origin:
curl -X GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/dns_records" \
-H "X-Auth-Email: email" \
-H "X-Auth-Key: key"
Review load balancer config (if applicable):
curl -X GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/load_balancers" \
-H "X-Auth-Email: email" \
-H "X-Auth-Key: key"
Check firewall rules:
curl -X GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/firewall/rules" \
-H "X-Auth-Email: email" \
-H "X-Auth-Key: key"
When encountering issues not covered above, consult Cloudflare API documentation:
Pattern for exploring new APIs:
# List available settings for a zone
curl -X GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/settings" \
-H "X-Auth-Email: email" \
-H "X-Auth-Key: key"
Consult references/api_overview.md for:
Consult references/ssl_modes.md for:
Consult references/common_issues.md for:
jq or python for readability"success": true/false in responseserrors array in responses1. Gather: domain, email, API key
2. Get zone_id via zones API
3. Investigate:
- Query relevant APIs for evidence
- Check multiple related settings
- Verify with external tools (dig, curl)
4. Analyze evidence to determine root cause
5. Apply fix via appropriate API endpoint
6. Purge cache if configuration change affects delivery
7. Verify fix via API query and external testing
8. Inform user of resolution and any required actions
When user reports "site shows ERR_TOO_MANY_REDIRECTS":
# 1. Get zone ID
curl -s -X GET "https://api.cloudflare.com/client/v4/zones?name=example.com" \
-H "X-Auth-Email: user@example.com" \
-H "X-Auth-Key: abc123" | jq '.result[0].id'
# 2. Check SSL mode (primary suspect for redirect loops)
curl -s -X GET "https://api.cloudflare.com/client/v4/zones/ZONE_ID/settings/ssl" \
-H "X-Auth-Email: user@example.com" \
-H "X-Auth-Key: abc123" | jq '.result.value'
# If returns "flexible" and origin is GitHub Pages/Netlify/Vercel:
# 3. Fix by changing to "full"
curl -X PATCH "https://api.cloudflare.com/client/v4/zones/ZONE_ID/settings/ssl" \
-H "X-Auth-Email: user@example.com" \
-H "X-Auth-Key: abc123" \
-H "Content-Type: application/json" \
--data '{"value":"full"}'
# 4. Purge cache
curl -X POST "https://api.cloudflare.com/client/v4/zones/ZONE_ID/purge_cache" \
-H "X-Auth-Email: user@example.com" \
-H "X-Auth-Key: abc123" \
-d '{"purge_everything":true}'
# 5. Inform user: Wait 60 seconds, clear browser cache, retry
The bundled scripts (scripts/check_cloudflare_config.py, scripts/fix_ssl_mode.py) serve as:
However, prefer direct API calls via Bash/curl for flexibility and transparency. Scripts should not limit capability - use them when convenient, but use raw API calls when needed for:
The investigation methodology and API knowledge is the core skill, not the scripts.
JamieMason/syncpack
awslabs/agent-plugins
github/awesome-copilot
addyosmani/agent-skills