mcpField
C
cloudflare-pages

cloudflare-pages

github.com/genericserviceCloud & DevOps093 installsUpdated 24w ago
Repository

About cloudflare-pages

cloudflare-pages is a skill for deploying static sites to Cloudflare Pages, for developers managing projects, domains, and delivery pipelines. It provides Wrangler-based deployment steps plus scripts to configure domains and verify deployments.

Key features

  1. 01Create Cloudflare Pages projects
  2. 02Deploy static build output with Wrangler
  3. 03Register custom domains and configure CNAME
  4. 04Use GitHub Actions CI/CD templates
  5. 05Check deployment status, SSL, and HTTP response

Use cases

  1. 01Publish a built static site to Pages
  2. 02Connect a custom domain to a Pages project
  3. 03Set up GitHub Actions deployment workflows
  4. 04Check deployment health and recent releases

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/genericservice/claude-skills --skill cloudflare-pages

After installing, type/cloudflare-pagesin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
ci-cd-templates.md
scripts/
add-custom-domain.sh
setup-pages-project.sh
verify-deployment.sh

Details

From the project README

Cloudflare Pages

Deploy any static site to Cloudflare Pages — create projects, attach custom domains, wire up CI/CD, and verify deployments. Framework-agnostic: works with Hugo, Astro, Next.js, Nuxt, SvelteKit, or any build tool that produces static output.

Prerequisites

RequirementHow to get it
wrangler CLInpm i -g wrangler then wrangler login (opens browser OAuth)
Cloudflare accountdash.cloudflare.com — free tier works
Account IDDashboard → any zone → Overview sidebar, or wrangler whoami
API Token (CI/CD)Dashboard → API Tokens → "Edit Cloudflare Workers" template (includes Pages)
DNS API TokenDashboard → API Tokens → Custom → Zone:DNS:Edit (only if adding custom domains via API)
Zone IDDashboard → your domain → Overview sidebar (only for custom domains)

Quick Deploy

For a one-off manual deploy when CI/CD isn't set up yet:

# 1. Build your site
<your-build-command>          # e.g. hugo --minify, npm run build

# 2. Deploy output directory
wrangler pages deploy <output-dir> --project-name <project-name>

Each deploy gets a unique preview URL. The latest deploy on production branch becomes the live site at <project>.pages.dev.

Full Setup Workflow

Step 1 — Create the Pages project
bash scripts/setup-pages-project.sh <project-name> "<build-command>" <output-dir> [branch]

This runs wrangler pages project create and prints the resulting *.pages.dev URL. The branch argument defaults to main.

Manual alternative:

wrangler pages project create <project-name> --production-branch main
Step 2 — Deploy

Build and deploy:

<your-build-command>
wrangler pages deploy <output-dir> --project-name <project-name>
Step 3 — Add a custom domain
# Set required environment variables
export CLOUDFLARE_ACCOUNT_ID="<your-account-id>"
export CLOUDFLARE_API_TOKEN="<pages-edit-token>"
export CLOUDFLARE_ZONE_ID="<your-zone-id>"
export CLOUDFLARE_DNS_TOKEN="<dns-edit-token>"   # optional, falls back to API_TOKEN

bash scripts/add-custom-domain.sh <custom-domain> <project-name>

The script performs two operations:

  1. Registers the domain on the Pages project via Cloudflare API
  2. Creates a proxied CNAME DNS record pointing to <project>.pages.dev

Both operations are idempotent — safe to re-run.

Step 4 — Set up CI/CD

See references/ci-cd-templates.md for complete GitHub Actions workflows for Hugo, Astro, Next.js, and generic npm builds.

Required GitHub Secrets:

SecretValue
CLOUDFLARE_API_TOKENAPI token with "Edit Cloudflare Workers" permissions
CLOUDFLARE_ACCOUNT_IDYour Cloudflare account ID

Set these at: Repository → Settings → Secrets and variables → Actions → New repository secret

Rollback

# List recent deployments
wrangler pages deployment list --project-name <project-name>

# Rollback: checkout previous commit, rebuild, redeploy
git checkout <commit-hash>
<your-build-command>
wrangler pages deploy <output-dir> --project-name <project-name>

# Return to latest
git checkout main

Verify Deployment

export CLOUDFLARE_ACCOUNT_ID="<your-account-id>"
export CLOUDFLARE_API_TOKEN="<your-token>"

bash scripts/verify-deployment.sh <project-name> [custom-domain]

Shows: latest deployment status (color-coded), last 5 deployments table, custom domain SSL status, and HTTP 200 check on *.pages.dev.

Script Reference

ScriptPurposeRequired env vars
setup-pages-project.shCreate Pages project via wranglerCLOUDFLARE_ACCOUNT_ID
add-custom-domain.shRegister domain + create CNAMECLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_API_TOKEN, CLOUDFLARE_ZONE_ID
verify-deployment.shCheck deploy status, SSL, HTTPCLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_API_TOKEN

Token Reference

OperationToken neededScopeWhere used
wrangler pages deployWrangler OAuthAutomatic via wrangler loginLocal CLI, CI/CD
Register custom domain on PagesAPI TokenAccount:Cloudflare Pages:Editadd-custom-domain.sh
Create CNAME DNS recordDNS API TokenZone:DNS:Editadd-custom-domain.sh
CI/CD deploy (GitHub Actions)API Token"Edit Cloudflare Workers" templateGitHub Secrets
Query deploymentsAPI TokenAccount:Cloudflare Pages:Readverify-deployment.sh

Tip: For simpler setups, a single API token with both Pages:Edit and DNS:Edit scopes can be used — set CLOUDFLARE_API_TOKEN and omit CLOUDFLARE_DNS_TOKEN.

Troubleshooting

ProblemCauseFix
wrangler: command not foundwrangler not installednpm i -g wrangler
Authentication errorOAuth expired or wrong tokenwrangler login (re-authenticate)
Custom domain stuck "pending"Missing or wrong CNAME recordCheck DNS: CNAME must point to <project>.pages.dev
SSL not provisioningDomain not proxied through CloudflareSet CNAME proxy to "Proxied" (orange cloud)
522 error on custom domainDNS record exists but wrong targetDelete old record, re-run add-custom-domain.sh
Deploy succeeds but site 404sWrong output directoryVerify build output dir matches deploy path
CI/CD deploy failsMissing GitHub secretsAdd CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID

Agentic Workflow & Vibe Coding

  • Iterative Deployment: Do not expect the perfect CI/CD setup or DNS propagation on the first run. Draft the configuration or run the manual deploy, review the Cloudflare Pages logs or status checks, isolate specific build errors or proxy issues, adjust ONE setting at a time, and redeploy until the site is live.
  • Vibe Coding: Commit your working deployment scripts and GitHub Actions workflows locally before testing them on the live repository, making it easy to roll back if the pipeline breaks.

Anti-Patterns

  • Don't use Cloudflare's git integration — use wrangler pages deploy for direct uploads. Git integration adds complexity with no benefit for this workflow.
  • Don't create multiple projects for the same site — one project can have multiple custom domains.
  • Don't skip the CNAME step — registering a domain on Pages without the DNS record leaves it "pending" indefinitely.
  • Don't use unproxied CNAME records — Cloudflare's SSL and CDN only work when the orange cloud (proxy) is enabled.
  • Don't hardcode account IDs in scripts — always use environment variables.

Comments

Markdown supported