用途
Cloudflare Doctor 用于审计用户的 Cloudflare 项目,像医生一样工作:从证据出发诊断,精确命名风险,解释 Cloudflare 原语/产品不匹配之处,并开出最小安全修复方案。它面向最佳实践漂移、错误原语/产品选择、遗漏优化、产品配置错误、安全缺口、可靠性问题以及成本陷阱等审计场景。
主要能力
- 以证据为先:每条发现都需要文件/配置/账户来源,尽可能提供行号/引用,并关联具体的 Cloudflare 行为或计费机制。
- 以当前文档为准:在断言 Cloudflare 最佳实践、产品行为、限制、定价细节或配置建议之前,获取当前官方 Cloudflare 文档,不依赖训练数据或记忆。若无法获取文档,会说明该主张未经当前文档验证。
- 不根据仓库文件推断仪表盘/账户设置:若缺少 DNS、SSL/TLS、WAF、缓存规则、Access、计费或 Logpush 证据,会要求提供 Terraform/导出/截图/API 输出,或标记为未检查。
- 区分已确认发现与待验证疑点。
- 优先原语匹配修复,而非局部补丁:KV vs D1 vs Durable Objects vs R2 vs Queues vs Workflows vs Cache 往往是根本问题。
- 成本问题即使应用正常运行也算发现:估算成本机制,除非用户提供用量和套餐细节,否则不估算精确金额。
使用方式
标准工作流:
- 阅读 references/audit-playbook.md、references/sharing-cloudflare-state.md、references/recommendation-provenance.md、references/audit-engine-patterns.md、references/war-story-scenario-checklist.md 和 references/cloudflare-best-practices-docs.md。
- 若仪表盘/账户状态重要,从 references/sharing-cloudflare-state.md 请求最小证据包。不要仅凭仓库文件推断仪表盘设置。
- 使用 https://developers.cloudflare.com/llms.txt、产品 llms.txt 索引以及已验证最佳实践列表中适用的 Markdown 页面,获取检测到的产品的当前 Cloudflare 文档。本地参考文件仅作为导航辅助,不是权威当前指南。每条建议都需要来源依据:官方当前 Cloudflare 文档或已接受的 war story。
- 若允许,从项目根目录运行静态扫描器,使用此技能脚本的绝对路径(SKILL.md 旁边的 scripts/ 目录):
python3 <skill-dir>/scripts/cfdoctor_static_scan.py .
将扫描器输出视为线索,而非证据。
- 清点 Cloudflare 表面:仓库文件、Wrangler 配置、绑定、IaC、包脚本、路由/域名、运行时代码、迁移、测试以及提供的账户/仪表盘证据。
- 映射产品与原语,然后阅读适用参考章节:references/product-fit-rubric.md、references/config-and-security-checks.md、references/performance-and-reliability.md、references/cost-footguns.md、references/audit-engine-patterns.md(借鉴 React Doctor、Duckbill、Lighthouse 和 IaC 扫描器的报告/检查/证据模式)、references/war-story-scenario-checklist.md(跨平台恐怖故事场景检查)、references/official-source-map.md(来源链接和日期敏感的定价/限制验证)。
- 按下方要求格式生成发现,优先处理高影响的正确性、安全、可靠性和成本发现,而非琐碎细节。
审计输出格式
开头包含:
## Cloudflare Doctor audit
Scope inspected: <repo paths, config, account/dashboard evidence, commands run>
Scope not inspected: <missing account/dashboard/deploy evidence>
Docs refreshed: <Cloudflare docs URLs fetched, or explicit note that current docs could not be fetched>
Detected products: <Workers/Pages/KV/D1/...>
Cost proxy summary: <request count assumptions; CPU/subrequests; D1 rows; R2/KV ops; DO duration/requests; Queue retries; AI/browser/media/vector usage; cache hit/miss assumptions>
Overall risk: <low|medium|high> — <one sentence>
然后分组发现:
### <severity>: <short finding title>
- Category: <best-practice drift | wrong primitive | missed optimization | misconfiguration | cost footgun | security | reliability>
- Evidence: <file:line/config/account source/command output>
- Why it matters: <Cloudflare-specific behavior, limit, consistency model, billing mechanism, or failure mode>
- Fix: <smallest safe remediation; include better primitive/product if applicable>
- Verify: <command, dashboard check, load test, or config check>
- Source basis: <official Cloudflare docs URL(s) fetched this audit and/or accepted war story URL(s)>
- Confidence: <high|medium|low>
结尾包含:
## Run summary with cost proxies
- Hot paths: <routes/jobs/crons/workflows reviewed>
- Expensive primitives per user action: <rough operation counts or unknown>
- Retry/fanout/circuit-breaker posture: <bounded|unbounded|unknown>
- Cache map: <browser/CDN/Worker Cache/KV/R2/D1/AI Gateway/etc.; key, TTL, invalidation owner>
## Recommended next actions
1. <highest leverage fix>
2. <next>
## Questions / evidence needed
- <only questions that would change the diagnosis>
严重性指南
- Critical:可能的密钥泄露、公开数据暴露、生产中断风险、失控计费或已部署的安全绕过。
- High:在正常规模下导致正确性/可靠性/成本风险的错误原语;严重配置错误;敏感端点缺少认证/速率限制。
- Medium:有意义的性能/成本/可靠性改进,或随增长可能变严重的配置漂移。
- Low:卫生、可维护性、次要优化或低置信度异味。
安全命令策略
本地只读命令可以执行:find、rg、python3 <skill-dir>/scripts/cfdoctor_static_scan.py .、包管理器元数据命令,以及未认证的 Cloudflare 文档获取,例如 curl -fsSL https://developers.cloudflare.com/workers/llms.txt。
在执行已认证的 Cloudflare 命令前需询问,即使是只读命令,因为它们可能暴露账户/项目名称或消耗 API 速率限制。
除非用户明确要求,否则绝不部署、变更绑定、创建/删除资源、清除缓存、更改 DNS/WAF/规则或轮换密钥。
适用场景
适用于需要审计 Cloudflare 项目配置、产品选择、安全性、可靠性和成本的开发者或团队,尤其是使用 Workers、Pages、KV、D1、R2、Queues、Durable Objects 等产品的项目。
限制
- 不根据仓库文件推断仪表盘/账户设置;缺少证据时会标记未检查或要求补充。
- 不估算精确金额,除非用户提供用量和套餐细节。
- 不执行部署、变更绑定、创建/删除资源、清除缓存、更改 DNS/WAF/规则或轮换密钥,除非用户明确要求。
- 已认证的 Cloudflare 命令需事先询问。
- 若无法获取当前官方文档,会说明相关主张未经当前文档验证。