Blog

Auditing a Cloudflare zone with claudeflare: setup, scoring and limits

Magnifying glass in front of a cloud shape with three status dots

In claudeflare a zone audit is one command: /claudeflare:audit yourdomain.com. What you get back is an overall score out of 100, a separate score for each of seven domains, and findings ordered by severity. Every finding states the current value, the recommended value, the reason and what the fix could break. The audit changes nothing. It is also worth saying up front that the tool never runs commands on your server: origin-side fixes come back to you as step-by-step instructions.

I wrote claudeflare as an open source plugin for Claude Code; what it is and why I built it is on the project page. This post is the practical side: setup, how the audit runs under the hood, how the score is computed and which findings deserve your attention first. Everything here describes version 0.3.1 on the public main branch.

Setup: two commands and a read-only connection

You need three things: Claude Code with plugin support, Node.js 18 or later, and a Cloudflare account. Inside Claude Code, installation is two lines:

  • /plugin marketplace add denizbarish/claudeflare
  • /plugin install claudeflare@claudeflare

Then run /claudeflare:setup in your project. It checks the MCP connection and the API token, creates the local state folder (.claudeflare/) and adds it to .gitignore.

Reads go through Cloudflare's official MCP server. When you pick the cloudflare server with /mcp and sign in, Cloudflare shows a consent screen. Grant read-only scopes there and nothing else. That is the real guarantee that an audit cannot write anything. The plugin's own guard hook is a second line of defence, not a substitute.

An audit needs no API token. The token is only for applying changes, or for reading through claudeflare get when MCP is unavailable. If you need one, start with the read set in the token template. A full audit also needs read permissions for WAF, Bot Management and the individual rule phases to cover the rules, WAF and bots domains; Cloudflare has no single "Zone Rulesets Read" permission, and each rules phase has its own.

What the audit command does

/claudeflare:audit first finds the zone and reads its plan (Free, Pro, Business or Enterprise). It then starts one auditor subagent per domain, all at once. Each auditor reads only its own domain's checklist and returns a single JSON object: its findings, and the checks it could not read (unread).

That second list is the tool's most important honesty rule. When a read is denied, fails or gets truncated, the auditor does not guess the value. A domain with unread checks is re-run once. If it is still incomplete on the second try, it stays out of the score and appears in the report as "not audited", with the reason. A token with missing permissions therefore cannot produce a high score that happens to be wrong.

A zone audit covers these seven domains. The examples in parentheses are real finding ids from the checklists:

  • dns: dangling records, unproxied web records and an exposed origin IP, DNSSEC, CAA (dns.records.dangling, dns.proxy.origin_exposed, dns.mx.proxied)
  • ssl: SSL mode, Always Use HTTPS, HSTS (ssl.mode.flexible, ssl.mode.full_not_strict, ssl.hsts.off)
  • cache: Tiered Cache, a cache rule for static files, HTML with session cookies being cached (cache.html.cached_with_cookies)
  • performance: Brotli, Early Hints, Polish, risky Rocket Loader (perf.rocket_loader.risky)
  • rules: legacy Page Rules, redirect chains and loop risk (rules.redirect.loop_risk)
  • waf: the managed ruleset, the OWASP set, unprotected admin paths, overly broad skip rules (waf.skip.too_broad)
  • bots-ratelimit: Bot Fight Mode, rate limits on login and API endpoints (ratelimit.login.missing)

If the zone has load balancers or Spectrum apps, those two domains join in. A product you do not use is not scored 100; it is left out and the summary says so. Workers, Pages, storage and Zero Trust audits work at account level and only join a zone audit when you ask.

How the score is computed

Each domain starts at 100. Every critical finding costs 25 points, every high 10, every medium 4 and every low 1, with a floor of 0. The overall score is the rounded mean of the audited domains. The model does not do this arithmetic; claudeflare report does, and the model has to use its numbers as they are.

A concrete case: on a zone with SSL mode set to Flexible, that single finding drops ssl to 75. If the WAF managed ruleset is also off, waf falls to 90. With the other five domains clean, the overall score comes out at about 95. The averaging has a side effect worth knowing: one critical finding moves the overall score by only a few points. So read the domain scores and the critical lines, not the headline number.

Severities have fixed definitions:

  • critical: an outage, data exposure or an open attack surface
  • high: a significant loss of security or performance
  • medium: a best practice gap with measurable impact
  • low: polish

Which findings to look at first

The report orders findings by severity, but I would not follow that order blindly. This is the order I use:

  1. Anything that causes an outage: findings such as dns.mx.proxied are a straight loss of service. If the MX target is proxied, mail to that host does not arrive, because the Cloudflare proxy only carries HTTP and HTTPS.
  2. Anything that leaks data: cache.html.cached_with_cookies can serve one logged-in user's page to another visitor. ssl.mode.flexible leaves traffic between Cloudflare and your origin unencrypted.
  3. Anything with prerequisites: every finding has a prerequisites field. Before moving from Flexible to Full (strict), the origin needs a valid certificate, or the site returns 526. The HSTS recommendation only appears once SSL is strict and Always Use HTTPS is on.
  4. Anything above your plan: the plan_tier field says which plan the fix needs. A fix your plan does not support has an empty fix list, and the summary gives you the best option on your current plan instead.

One more distinction matters. A finding with a non-empty fix list can become a change plan directly. An empty one is either origin-side, manual or above your plan, and for those Claude writes you step-by-step instructions.

What I measured on my own domain

I ran the first live test on 25 October 2026, on denizbarish.com, against the real API. The overall score was 86. The full chain of plan, approval, apply and rollback also ran on a real change.

Two things from that test went back into the code. The first is the dns.proxy.non_http_service check, which catches proxied records whose names point to ftp, ssh or mail services. The Cloudflare proxy only passes specific HTTP and HTTPS ports, so those services break behind it. The check shipped in 0.1.0 and the CHANGELOG still carries its "found in a live test" note. The second was a critical finding: the MX target was proxied. Today that record is DNS-only.

The token I used in that test was missing the Rulesets and Bot Management read permissions. The rule that auditors list what they could not read exists for exactly this situation. When you create your token, add the full audit permissions from the template from the start.

From finding to change

Once the audit finishes, Claude asks which findings you want fixed. The ones you pick become a plan: a plan id, a before and after table, the risk and any step that cannot be undone. The model cannot approve it; you type /claudeflare:approve <plan-id> yourself, and a hook records that as a signed approval. An approval lasts 30 minutes, works once and is bound to the plan's content, so an edited plan is no longer approved.

Before applying, claudeflare snapshots every resource the plan touches. /claudeflare:rollback <plan-id> builds a reversal plan from that snapshot, and the reversal needs its own approval. Cache purges, DNSSEC, Tiered Cache and Bot Fight Mode cannot be rolled back, and the plan says so in its risk note before you approve. Apply only works in interactive sessions. In a headless claude -p run there is nobody to answer the confirmation prompt, so the call is denied.

What claudeflare will not do

I repeat the limits from the README here, because they decide how far you should trust an audit tool:

  • It does not touch your origin: nginx, certificate and firewall fixes come as instructions. When the root cause of an error like 522 sits on your server, you make the fix.
  • It guards against model mistakes, not deliberate evasion: the Bash checks in the guard are string matches. A wrangler call hidden in a script file, or a write sent with node -e, gets past them. The real guarantee is read-only MCP scopes and keeping only a read token in the session.
  • It cannot stop a process running as your user: the approval key lives in a local file, and a malicious process running as the same user can read it. claudeflare is not a sandbox.
  • There is no safety layer in claude.ai chat: plugin hooks do not run there. Use MCP read-only in chat and make changes from Claude Code.

Each of these limits is also tested in code: the 813 unit tests on main passed locally today with zero failures. Behaviour is covered by an 11-case eval set, with Cloudflare mocked and no real account involved.

If you manage many domains on Cloudflare, it pays to pair the audit with the Search Console side; I covered that in setting up GSC and IndexNow across 36 domains. My other open source work is on the projects page. The source and install details are in the GitHub repository; run your first audit on your own zone with read-only scopes, and read the critical lines first.

CloudflareClaude CodeSecurity