Part V: Keep These Handy (use them when you need them)B
Appendix B
Appendix B: Tokens and automatic deployments
Automation later. Preview first.
Skip this for your first preview. Claude Code can deploy from your computer using Cloudflare's browser login. This appendix is for a different job: deploying from GitHub while your computer is closed.
Why a token still exists
A GitHub Actions job cannot ask you to approve a browser login. It needs a token with the permissions for that deployment. The deployment command reads that token from the job's environment. The local login is not a CI credential to copy out. Cloudflare's CI guidance.
The old version of this guide had everyone create a bootstrap token and mint broad, year-long access before building anything. You do not need that for the browser-login path.
Before you start
Have a working staging deploy, a GitHub repository and the key vault. The agent should know which Worker, account and resources this one site uses. That is what lets it ask for the right permissions instead of access to everything you own.
If Path B needed an approved framework deployment exception, keep that working route here too. The commands and configuration recorded in your project's CLAUDE.md apply to CI as well as launch.
Your part
- Ask the agent to list the permissions this project's deployment needs, with the account and any zone scope. It should check the current Cloudflare docs, not guess from an old token recipe.
- In Cloudflare, open your profile → API Tokens → Create Token. Use the specified permissions and resources, and choose an expiry you can manage. Create an API token.
- Save it in your vault as
CLOUDFLARE_DEPLOY_TOKEN. Do not paste the value in chat. - Run the prompt below. Let the agent verify a staging deployment before relying on the workflow.
The automatic-deploy prompt
My site already deploys from this computer. Add automatic staging deploys
from GitHub Actions using the deployment route validated on staging and
recorded in this project's CLAUDE.md.
- Default cf route: keep the pinned cf version and reviewed
cloudflare.config.ts. Do not let CI invent configuration on its first run.
- Approved framework deployment exception from Path B: keep its recorded
build, dry-run and deployment commands, versions and configuration.
Do not run cf init, cf dev, cf build or cf deploy against that unmigrated
project, or migrate it without separate approval.
Keep cf for account tasks; it does not replace the approved exception's
build or deployment command.
The dedicated token is in my vault as CLOUDFLARE_DEPLOY_TOKEN. Read it only
in the command that sets GitHub Actions secrets. Set that repository secret
and CLOUDFLARE_ACCOUNT_ID, then map CLOUDFLARE_DEPLOY_TOKEN to the
CLOUDFLARE_API_TOKEN environment variable only in the deploy job. Do not
copy my browser-login credentials into GitHub.
Run lint, type checks, tests and the production build on pull requests
without deploy credentials. Keep type checks separate from the framework
build. For the default cf route, include cf deploy --dry-run; a push to main
may deploy the tested staging build with cf deploy --prebuilt, using the
same mode as the build. For the approved framework deployment exception,
use its recorded validation and staging deployment commands instead.
Staging stays noindex. Production is a separate, approved action.
Check for pending database migrations and report them before making data
changes. Never point a preview workflow at production by accident.
Verify a staging run and its public URL. Report the token's scope and
expiry without its value, and document how I renew it. If a permission is
missing, identify that permission; do not request blanket account access.Other service keys
Cloudflare sign-in does not replace Stripe keys, Google service-account credentials, CMS secrets or form secrets. Those belong to their features, stored in the vault and/or Worker secrets as the relevant chapter describes. Never commit them or put them in browser code.
Checklist
On a phone, swipe left and right to turn pages.