# Manage Cloudflare caching with Claude Code

> Managing Cloudflare with Claude Code means asking it, from the terminal you already work in, to check a WordPress site's Cloudflare link, purge the edge cache or toggle development mode through xSpeed Hub.

Page: https://xspeedcache.com/agent/claude-code/cloudflare/
Last updated: October 2026

You are in the terminal, halfway through a theme or template change, and the live page still shows the old markup. Your own server may already be fresh while Cloudflare keeps handing out its stored copy from the edge. Instead of opening the Cloudflare dashboard, you tell Claude Code which site looks wrong. It calls list_sites to match the name, runs cloudflare_verify to confirm the credentials stored in xSpeed still work, and then decides whether you need an edge purge or development mode.

The three tools divide the work. cloudflare_verify is a read: it asks Cloudflare whether the stored token and zone still resolve, and it purges nothing. purge_cloudflare empties only the edge, which fits when you already purged the server and want nothing else touched. set_cloudflare_dev_mode with enabled true bypasses the edge for about three hours so your origin output shows straight away. All three need Cloudflare connected in xSpeed on that site, and none of them takes site: "all", so a fix across several sites is several calls, one site each.

Claude Code asks before it runs an MCP tool unless a permission rule allows it or you run auto mode or bypassPermissions mode, and the prompt carries the full name, such as mcp__xspeedhub__set_cloudflare_dev_mode. Because the session stays open while you edit, you can ask for dev mode, reload the page, change the template, reload again, and then ask Claude Code to switch dev mode off, all in one conversation.

## Set up Claude Code once

### 1. Put your sites in xSpeed Hub

Sign in at app.xspeedcache.com with Google or email; the Hub is free and has no site cap. Then connect each WordPress site from its own dashboard: click Connect Hub in the xSpeed Cache top bar, then Connect via xSpeed Hub. Each site needs the free xSpeed Cache plugin.

### 2. Add xSpeed Hub to Claude Code

Run this once. --scope user makes the server available in every project; leave it off and it applies to the current project only, which is Claude Code's default.

```bash
claude mcp add --transport http --scope user xspeedhub https://app.xspeedcache.com/xspeed/mcp
```

### 3. Sign in with /mcp

Start Claude Code, run /mcp, pick xspeedhub and finish the sign-in in your browser. You approve access on an xSpeed Hub page; there is no token to paste, and Claude Code keeps the credentials it receives and refreshes them.

```
/mcp
```

Full setup: https://xspeedcache.com/agent/claude-code/

### Before you send a prompt that changes something

Reads change nothing on your sites, though contact_support emails xSpeed support. Writes run once your connection allows them, so your client's approval prompt and a read-only connection (the token's Read-only everywhere switch, or a Viewer sign-in) are the gates that matter. Claude Code asks before it runs an MCP tool unless a permission rule already allows it, or you work in auto mode, where a classifier reviews actions instead of you, or in bypassPermissions mode, which skips prompts. A rule such as mcp__xspeedhub__get_cache_status allows one tool, and mcp__xspeedhub__get_* allows every read whose name starts with get_. Keep purge_cache, update_settings, toggle_cache and the other write tools on the prompt, because the Hub itself runs a write as soon as your connection allows it.

## Prompts

- Use xSpeed Hub to check that the Cloudflare connection on shop still works, and tell me if the check fails.
- I changed the single-product template on shop. With xSpeed Hub, purge its Cloudflare edge cache and nothing else.
- Use xSpeed Hub to turn on Cloudflare development mode for blog while I debug the header, and remind me to turn it off.

## Example session

```
You: The new header on shop is not showing for logged-out visitors. Use xSpeed Hub to check whether Cloudflare is holding the old one.
  → cloudflare_verify(site: shop) [read-only]: Credentials and zone resolve; Cloudflare connected
Agent: The connection is healthy, so a purge will reach the edge. The old header can also sit in xSpeed's page cache on the server, and the edge would refill from it. Purge shop's page cache first, then run purge_cloudflare?
You: Yes, both.
  → purge_cache(site: shop, type: page) [changes site]: page cache purged (41 entries)
  → purge_cloudflare(site: shop) [changes site]: Cloudflare edge cache purged
Agent: The server page cache and the Cloudflare edge are both cleared for shop. Reload it logged out to check the new header. If you want to keep editing without the edge in the way, I can switch development mode on for about three hours.
```

## How it works

1. **Verify the connection**: cloudflare_verify calls Cloudflare's API with the credentials stored on the site and checks that the token and zone still resolve. It purges nothing and works on a read-only connection. If Cloudflare is not connected on that site, the call comes back as an error and the agent should tell you rather than retry.
2. **Purge the edge**: purge_cloudflare empties the Cloudflare edge cache for the site's zone. It does not touch the copies on your server. When Cloudflare is in front of a site, a content change usually needs both, so the agent runs purge_cache first and purge_cloudflare after it, or one purge_cache of type all, which reaches the edge when Cloudflare is connected.
3. **Turn development mode on to see origin changes**: set_cloudflare_dev_mode with enabled true bypasses the edge for about three hours, so changes on the origin show immediately. It slows the site for real visitors the whole time. Your client's prompt is the gate here, because the Hub's instructions do not name this tool in their confirm list.
4. **Turn it off when you finish**: set_cloudflare_dev_mode with enabled false switches development mode off. Cloudflare also ends it on its own after about three hours. No Hub tool reads whether it is currently on, so note when you turned it on.
5. **Read a failure**: A rejected token, an empty zone ID or a refused call comes back as an error that names the action, the HTTP status and Cloudflare's message when it gave one. It is not reported as a success. The credentials themselves are set in the xSpeed Cache panel in wp-admin, not through the Hub.

## Reference

| | |
| --- | --- |
| Read tool | cloudflare_verify; purges nothing and works on a read-only connection |
| Write tools | purge_cloudflare and set_cloudflare_dev_mode (enabled true or false) |
| Needs | Cloudflare connected in xSpeed on that site: integration on, an API token (or the legacy key and email) and a Zone ID |
| Edge purge scope | Everything Cloudflare holds for the site's zone; the server copies stay |
| Development mode | Bypasses the edge for about 3 hours, then Cloudflare switches it off |
| Token permissions | Zone Cache Purge, and Zone Settings Edit for development mode |
| What verify proves | The token and zone resolve; a token without Zone Settings Edit still verifies |
| Through purge_cache | Type all also clears the edge when Cloudflare is connected; page, assets, object and rest do not |
| Every site at once | None of the three accept site: "all"; one site per call |
| Failure shape | An error with the action, the HTTP status and Cloudflare's message |
| Read-only connection | The connection token with Read-only everywhere on, or a Viewer member's sign-in; purge_cloudflare and set_cloudflare_dev_mode are refused and cloudflare_verify works. An OAuth sign-in gets the scopes the client asks for, so the switch does not make it read-only |
| Confirmation | None on the Hub; your client's prompt is the gate |

## Rules

- Run cloudflare_verify first, but do not read a pass as proof that every call will work. A token that lacks Zone Settings Edit verifies and purges fine, then fails the first time development mode is switched.
- Purge the server and the edge together after a content change. Purging only the site leaves visitors on the old page until the edge copy expires.
- Turn development mode off as soon as you are done. It slows the site for real visitors for up to about three hours, and no tool reports its state.
- Never paste a Cloudflare token or Global API Key into the chat. Connect Cloudflare in the xSpeed Cache panel in wp-admin, and use a scoped API token rather than the Global API Key.
- purge_cloudflare and set_cloudflare_dev_mode are write tools. The Hub runs them as soon as your connection allows writes, so your client's approval prompt and a read-only connection (the connection token with Read-only everywhere on, or a Viewer member's sign-in) are the gates that matter.

## Good to know with Claude Code

A permission rule that allows every tool from the xspeedhub server also allows set_cloudflare_dev_mode and purge_cloudflare, and then Claude Code runs them without showing you a prompt. Auto mode, where a classifier reviews actions instead of you, and bypassPermissions mode, which shows no prompts, skip the prompt for them as well. Allow mcp__xspeedhub__cloudflare_verify by name and keep the two write tools on the prompt. Development mode also outlives your session: closing the terminal does not end it, Cloudflare does after about three hours, and the site is slower for real visitors until then, so ask Claude Code to turn it off before you leave. No Hub tool reports whether dev mode is currently on, so note when you switched it on.

## More prompts for this job

They work in any client connected to xSpeed Hub.

- Use xSpeed Hub to check that the Cloudflare connection on shop still works.
- With xSpeed Hub, purge the Cloudflare edge cache on blog.
- I changed the checkout page on shop. Use xSpeed Hub to purge the site cache and the Cloudflare edge.
- Use xSpeed Hub to turn Cloudflare development mode on for shop. I am editing the theme.
- With xSpeed Hub, turn Cloudflare development mode off on shop.
- Ask xSpeed Hub to verify Cloudflare on shop and tell me what is wrong if it fails.
- Using xSpeed Hub, which of my sites have a working Cloudflare connection? Check them one at a time.

## Frequently asked questions

### Can Claude Code purge Cloudflare without purging my server cache?

Yes. purge_cloudflare clears only the Cloudflare edge and leaves the copies on your server alone. A purge_cache call with type all clears the server caches and also the edge when Cloudflare is connected, so pick the tool that matches what you want.

### Does Claude Code turn development mode off by itself?

No. It switches dev mode off only when you ask. Cloudflare ends it on its own after about three hours, and the Hub does not schedule anything for Claude Code, so tell it to turn dev mode off when you finish debugging.

### What does a site need before the Cloudflare tools work?

Cloudflare has to be connected in xSpeed on that site: the integration switched on, an API token (or the legacy Global API Key with your Cloudflare email) and the Zone ID of the domain. You set these in the xSpeed Cache panel in wp-admin. Without them, the tools return an error instead of acting.

### Does purging the xSpeed cache also clear Cloudflare?

A purge_cache of type all does, when the site has Cloudflare connected, and it reports each step. A page, assets, object or rest purge stays on your server. purge_cloudflare clears only the edge, so use it when the server copy is already fresh.

### How long does development mode last?

About three hours. Cloudflare switches it off on its own after that. While it is on, the edge is bypassed, so origin changes show at once and real visitors get a slower site. Turn it off yourself with set_cloudflare_dev_mode set to false when you are done.

### Why did cloudflare_verify pass but development mode failed?

Verifying and purging do not need Zone Settings Edit on the token, so a token without it looks fine. Development mode writes a zone setting, so it is refused. Edit the token in Cloudflare so it has both Zone Cache Purge and Zone Settings Edit, then try again.

### Can I purge Cloudflare on all my sites with one prompt?

Not with purge_cloudflare, which takes one site per call. A purge_cache of type all with site set to all clears the edge on each site that has Cloudflare connected, and the result is reported per site. The Hub tells the agent to confirm a write across every site with you once first.

## Manage Cloudflare with other agents

[Claude](https://xspeedcache.com/agent/claude/cloudflare/) · [Claude Cowork](https://xspeedcache.com/agent/claude-cowork/cloudflare/) · [ChatGPT](https://xspeedcache.com/agent/chatgpt/cloudflare/) · [Codex](https://xspeedcache.com/agent/codex/cloudflare/) · [Cursor](https://xspeedcache.com/agent/cursor/cloudflare/) · [GitHub Copilot in VS Code](https://xspeedcache.com/agent/github-copilot/cloudflare/) · [Windsurf](https://xspeedcache.com/agent/windsurf/cloudflare/) · [Gemini CLI](https://xspeedcache.com/agent/gemini-cli/cloudflare/) · [Antigravity](https://xspeedcache.com/agent/antigravity/cloudflare/) · [Zed](https://xspeedcache.com/agent/zed/cloudflare/) · [Kiro](https://xspeedcache.com/agent/kiro/cloudflare/) · [OpenCode](https://xspeedcache.com/agent/opencode/cloudflare/) · [OpenClaw](https://xspeedcache.com/agent/openclaw/cloudflare/) · [Hermes Agent](https://xspeedcache.com/agent/hermes-agent/cloudflare/) · [Grok Build](https://xspeedcache.com/agent/grok-build/cloudflare/) · [ChatGPT dots](https://xspeedcache.com/agent/chatgpt-dots/cloudflare/) · [Grok](https://xspeedcache.com/agent/grok/cloudflare/) · [Grok Bot](https://xspeedcache.com/agent/grok-bot/cloudflare/) · [Muse](https://xspeedcache.com/agent/muse/cloudflare/) · [Manus](https://xspeedcache.com/agent/manus/cloudflare/) · [Kimi Code](https://xspeedcache.com/agent/kimi/cloudflare/) · [Paperclip](https://xspeedcache.com/agent/paperclip/cloudflare/) · [NanoClaw](https://xspeedcache.com/agent/nanoclaw/cloudflare/)

## More with Claude Code

- [Purge the WordPress cache with Claude Code](https://xspeedcache.com/agent/claude-code/purge-cache/)
- [Find out why WordPress pages are not cached with Claude Code](https://xspeedcache.com/agent/claude-code/troubleshoot-cache/)
- [Scan a website for speed problems with Claude Code](https://xspeedcache.com/agent/claude-code/speed-scan/)
- [Run and track PageSpeed tests with Claude Code](https://xspeedcache.com/agent/claude-code/pagespeed-tests/)
- [Raise a WordPress site's PageSpeed score with Claude Code](https://xspeedcache.com/agent/claude-code/optimize-site/)
- [Tune WordPress cache settings with Claude Code](https://xspeedcache.com/agent/claude-code/cache-settings/)
- [Warm the WordPress cache with Claude Code](https://xspeedcache.com/agent/claude-code/preload-cache/)
- [Set up the Redis object cache with Claude Code](https://xspeedcache.com/agent/claude-code/object-cache/)
- [Manage every WordPress site at once with Claude Code](https://xspeedcache.com/agent/claude-code/fleet/)

## Documentation

- How to connect Cloudflare: https://xspeedcache.com/docs/cloudflare/
- How to serve assets from a CDN: https://xspeedcache.com/docs/cdn/
- How to enable Page Cache: https://xspeedcache.com/docs/page-cache/
