cloudflare-troubleshooting by daymade/claude-code-skills
npx skills add https://github.com/daymade/claude-code-skills --skill cloudflare-troubleshooting基于证据调查,而非假设。 在诊断问题之前,务必查询 Cloudflare API 以检查实际配置。此技能的价值在于系统化的调查方法,而非预设的解决方案。
向用户请求:
全局 API 密钥位置:Cloudflare 控制面板 → 我的个人资料 → API 令牌 → 查看全局 API 密钥
任何 Cloudflare 故障排除的第一步 - 获取区域 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 '.'
从 result[0].id 中提取 zone_id 用于后续的 API 调用。
对于每个问题,在下结论前先收集证据。使用 Cloudflare API 检查:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
检查 SSL/TLS 模式:
curl -X GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/settings/ssl" \
-H "X-Auth-Email: email" \
-H "X-Auth-Key: key"
查看:result.value - 显示当前 SSL 模式
检查"始终使用 HTTPS"设置:
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"
检查页面规则中的重定向:
curl -X GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/pagerules" \
-H "X-Auth-Email: email" \
-H "X-Auth-Key: key"
查看:forwarding_url 或 always_use_https 操作
直接测试源服务器(如果可能):
curl -I -H "Host: <domain>" https://<origin_ip>
诊断逻辑:
修复方法:
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"}'
修复后清除缓存:
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}'
证据收集:
列出 DNS 记录:
curl -X GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/dns_records" \
-H "X-Auth-Email: email" \
-H "X-Auth-Key: key"
检查外部 DNS 解析:
dig <domain>
dig @8.8.8.8 <domain>
检查 DNSSEC 状态:
curl -X GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/dnssec" \
-H "X-Auth-Email: email" \
-H "X-Auth-Key: key"
查找:
证据收集:
检查 SSL 证书状态:
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"
检查源站证书(如果使用 Full Strict 模式):
openssl s_client -connect <origin_ip>:443 -servername <domain>
检查 SSL 设置:
常见问题:
证据收集:
检查源站是否可达:
curl -I -H "Host: <domain>" https://<origin_ip>
检查 DNS 记录是否指向正确的源站:
curl -X GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/dns_records" \
-H "X-Auth-Email: email" \
-H "X-Auth-Key: key"
检查负载均衡器配置(如果适用):
curl -X GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/load_balancers" \
-H "X-Auth-Email: email" \
-H "X-Auth-Key: key"
检查防火墙规则:
curl -X GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/firewall/rules" \
-H "X-Auth-Email: email" \
-H "X-Auth-Key: key"
当遇到上述未涵盖的问题时,请查阅 Cloudflare API 文档:
探索新 API 的模式:
# 列出区域的可用设置
curl -X GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/settings" \
-H "X-Auth-Email: email" \
-H "X-Auth-Key: key"
查阅 references/api_overview.md 以了解:
查阅 references/ssl_modes.md 以了解:
查阅 references/common_issues.md 以了解:
jq 或 python 以提高可读性"success": true/falseerrors 数组1. 收集:域名、邮箱、API 密钥
2. 通过 zones API 获取 zone_id
3. 调查:
- 查询相关 API 以获取证据
- 检查多个相关设置
- 使用外部工具验证 (dig, curl)
4. 分析证据以确定根本原因
5. 通过适当的 API 端点应用修复
6. 如果配置更改影响内容交付,则清除缓存
7. 通过 API 查询和外部测试验证修复
8. 告知用户解决方案和任何必要的操作
当用户报告"网站显示 ERR_TOO_MANY_REDIRECTS"时:
# 1. 获取区域 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. 检查 SSL 模式(重定向循环的主要怀疑对象)
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'
# 如果返回 "flexible" 且源站是 GitHub Pages/Netlify/Vercel:
# 3. 通过更改为 "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. 清除缓存
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. 告知用户:等待 60 秒,清除浏览器缓存,重试
捆绑的脚本 (scripts/check_cloudflare_config.py, scripts/fix_ssl_mode.py) 可用作:
然而,为了灵活性和透明度,首选通过 Bash/curl 直接进行 API 调用。脚本不应限制能力 - 在方便时使用它们,但在需要时使用原始 API 调用以处理:
调查方法和 API 知识是核心技能,而非脚本。
每周安装数
132
代码仓库
GitHub 星标数
708
首次出现
Jan 21, 2026
安全审计
安装于
claude-code114
codex106
opencode106
gemini-cli104
cursor97
github-copilot94
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.
Weekly Installs
132
Repository
GitHub Stars
708
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykFail
Installed on
claude-code114
codex106
opencode106
gemini-cli104
cursor97
github-copilot94
企业法律风险评估框架:基于严重性与可能性的风险矩阵与分类指南
1,100 周安装
Valyu API 最佳实践指南:搜索、内容提取、AI 答案与深度研究
1,300 周安装
ralphinho-rfc-pipeline:AI驱动的复杂功能分解与多单元编排工作流工具
1,300 周安装
NanoClaw REPL - AI对话持久化工具,支持会话分支、模型切换与跨会话搜索
1,300 周安装
竞争情报分析工具:生成交互式HTML战卡,深度对比竞争对手功能、定价与定位
1,200 周安装
edit-article AI文章编辑助手 - 智能结构化重写,提升内容清晰度与连贯性
1,300 周安装