Deploy native Golf to Cloudflare
This guide is for operators deploying Cloudflare-native Golf into their own Cloudflare account. It covers what you need to provide, the prerequisites, the two scripted deploy paths (the cf CLI recipe and Alchemy), optional services, verification and teardown.
Installing provisions real, billable resources in your account. Everything runs from a fresh clone with your own values: you choose the administrator, the hostnames and the content. Read What is not turnkey yet for the remaining limits.
Point your coding agent at agent-setup.md and it will walk you through these steps, check the prerequisites and ask for each value below.
Install with one command
After the account prerequisites are in place:
git clone https://github.com/mjtechguy/gitgolf.git golf && cd golf
npm install -g cf@1.0.0-beta.13
cf auth create golf # browser login
python3 scripts/golf_cloudflare.py doctor --fix --remote
python3 scripts/golf_cloudflare.py install # or: make cloudflare-install
doctor checks your tools, installs the locked npm dependencies and reads (never writes) your account: Workers Paid, the Zero Trust organization, an existing Secrets Store. install discovers your account, zone, Secrets Store, Access team domain and login method, then asks only for the hostnames, owner email, content and optional services. It shows a summary and waits for your confirmation before it creates anything.
Then it builds the CI image, deploys, seeds, enables each service you chose (running migrations and token renewals as needed), and verifies the Access sign-in. Expect 30–60 minutes. For a non-interactive run:
python3 scripts/golf_cloudflare.py install --yes --profile golf \
--hostname golf.example.com --preview-hostname golf-previews.example.com \
--email you@example.com --content example --with ai,search,public,observability
If a step fails, it prints the cause and the resume command (install --resume DIR). Afterwards: status DIR, update DIR after a git pull, update DIR --with email to add a service, and destroy DIR (asks you to type the installation name).
A one-command install completed on October 14, 2026 against an account that already hosted another Golf installation, with AI, search, public repositories and operations enabled. See the product ledger.
The sections below explain what the installer does, step by step, for operators who want to run each part themselves.
Choose a path
| Path | Use it to | Command authority |
|---|---|---|
| Alchemy (recommended) | Install into an empty account with init, then update, extend (AI, search, email, pipelines…) and tear down the same installation. | deploy/alchemy/README.md |
cf CLI recipe | A scripted first install with the cf CLI alone. Optional services need a hand-off to Alchemy, which replaces the installation. | deploy/demo/README.md |
Use one deployer per installation. Never have both manage the same resources.
What you provide
| Value | Where it goes | How to get it |
|---|---|---|
| Cloudflare account ID (32 hex characters) | --account-id | Dashboard account home, or the accounts list in cf --profile golf auth whoami |
Signed-in cf profile name | --profile | cf auth create golf, then complete the browser login. You don't paste an API token: the scripts mint short-lived, scoped tokens from this profile (see API permissions). |
| Zone ID of an active zone you own | --zone-id | Zone overview in the dashboard. Put both hostnames in this zone. |
Control hostname, such as golf.example.com | --hostname | Choose an unused name in that zone. |
Preview hostname, such as golf-previews.example.com | --preview-hostname | A different unused name. Each preview is served from a child hostname under it. |
| Owner email | --email | An email that can sign in to your Zero Trust organization through an email code. It becomes administrator user 1. |
| Content | --manifest PATH or --no-seed (required) | deploy/demo/example.json seeds a neutral sample organization; --no-seed starts empty apart from two CI and preview playground repositories. |
Workers subdomain (cf path only) | --workers-subdomain | The NAME in NAME.workers.dev, from the Workers & Pages overview. It must already exist. |
| Optional: administrator login | --admin-login | Defaults to a login derived from the email (jane.doe@… → jane-doe). |
| Optional: Git author (Alchemy) | --git-author-name, --git-author-email | Default to the administrator login and email. |
| Optional: Access team domain (Alchemy) | --access-team-domain | Read from your Zero Trust organization when omitted. |
| Existing Secrets Store ID (only if the account already has a store) | --secrets-store-id | Secrets Store in the dashboard. If a store exists and you omit this flag, the install stops. |
| Optional: webhook receiver origins | Alchemy enable-webhooks --origin https://… | Your receiver's HTTPS origin. Receiver URLs and signing secrets are entered later in repository settings. |
| Optional: daily email limit | Alchemy enable-email --email-limit N (1–5000, default 200) | Your choice. The sender is always golf@mail.CONTROL_HOSTNAME; you don't pick it. |
| Optional: agent file path | Alchemy enable-ai --agent-path FILE | The one source file agents may change across the installation. |
| Optional: search vector size | Alchemy enable-search --dimensions N (32–4096, default 1024) | It must match the embedding model you select in AI model settings. |
| Optional: Actions workflow path | Alchemy enable-workflow --workflow-path .github/workflows/NAME.yml | Your workflow file. |
| Optional: anonymous read limit | Alchemy enable-rate-limit --limit N --period 10|60 | Your choice (10–10,000 requests). |
You don't supply any of these. The scripts generate them and keep them in the installation's private directory or in Secrets Store:
- the Access applications, the email-code identity provider and the operator service token
- the Access team domain, which is read from your Zero Trust organization
- the signing, webhook and repository-value encryption keys
- the Golf machine credential
- the runtime API tokens
Container images go to Cloudflare's managed registry (registry.cloudflare.com), so you don't need a registry or registry credentials either.
Prerequisites
Account and products
| Requirement | Needed for | Notes |
|---|---|---|
| Workers Paid | Everything | Queues, Containers and Artifacts require it. |
| Artifacts | Git storage (required) | Open beta on Workers Paid. The deploy token needs the Artifacts Write permission. |
| Containers | Tests and agent tasks (required) | The runner image must be linux/amd64. |
| Workers for Platforms | Worker app previews (required by both scripted paths) | A separate subscription from Workers Paid. Both paths create a dispatch namespace unconditionally. |
| R2, D1, Durable Objects (SQLite), Queues, Workflows | Required | Enable R2 for the account before the first deploy. |
| Secrets Store | Required | The account has one store, and Golf reuses it. Golf adds only secrets prefixed with the installation name and removes only those. |
| Zero Trust (Access) organization | Required | Needs a team domain (https://TEAM.cloudflareaccess.com) and an available seat for the owner email. Golf creates its own email-code identity provider and two Access applications. It doesn't change account-wide policy. |
| Active zone on Cloudflare DNS | Required | Custom domains for the control Worker, the preview gateway and per-preview child hostnames. |
| Workers AI + AI Gateway | Optional (enable-ai) | Inference is billed by Cloudflare. |
| Vectorize | Optional (enable-search) | Needs enable-ai first. |
| Email Service (sending) | Optional (enable-email) | Not qualified live. Account eligibility, the Email Sending Write permission and DNS validation of the sending subdomain are unverified. |
| Browser Run, Analytics Engine, Workers rate limiting, Account Analytics | Optional | Enabled through the settings below. Hosted results vary; see the service inventory. |
API permissions
You authenticate the cf CLI with an OAuth profile. The scripts then create scoped tokens on your behalf. Your Cloudflare user must be allowed to create account API tokens with these permission groups. If a group isn't offered, the scripts stop with an "unavailable" error.
- Alchemy deployment token (8 hours, replaced by
renew-deploy):- Account:
Account Settings Read,Account API Tokens Write,Artifacts Write,D1 Write,Workers Scripts Write,Workers R2 Storage Write,Workers Containers Write,Queues Write,Secrets Store Write,Access: Apps and Policies Write,Access: Organizations, Identity Providers, and Groups Write,Access: Service Tokens Write. - Zone:
Zone Read,DNS Write,Workers Routes Write. - Optional services add
AI Gateway Write,Account Analytics Read,Email Sending WriteorVectorize Write.
- Account:
- Runtime tokens (stored in Secrets Store, 7 days):
- Management:
D1 Write,Workers Scripts Write,Workers R2 Storage Write,Secrets Store Write. - Registry:
Workers Containers Write. - Optional analytics:
Account Analytics Read.
- Management:
Unset CLOUDFLARE_API_TOKEN in your shell. cf prefers that variable over the profile, and the cf CLI recipe refuses to run unless the profile is the credential source.
Local tools
| Tool | Version | Notes |
|---|---|---|
| Node.js | 24 | The cf CLI itself needs 22 or later. |
cf CLI | exactly 1.0.0-beta.13 | Install with npm install -g cf@1.0.0-beta.13. cloudflare/forge/prepare.mjs refuses other versions. Wrangler is not used. |
| Docker | Current, with BuildKit | Builds the linux/amd64 runner image. Arm hosts need amd64 emulation. |
| Python | 3 | Runs the deploy scripts. |
| Git | Any recent version | Needed for the seed and checks. |
| Go | 1.27 (per go.mod) | The cf CLI recipe builds the Golf CLI. |
| Outbound Internet access | n/a | The seed imports pinned GitHub snapshots. |
Install the locked dependencies from the repository root:
npm --prefix cloudflare/agents ci
npm --prefix web ci
npm --prefix deploy/alchemy ci # Alchemy path only
Path 1: Alchemy (recommended)
Alchemy 2.0.0-beta.83 is pinned. Always use the wrapper; don't run bare alchemy commands or run Alchemy from the repository root.
Fresh install
git clone https://github.com/mjtechguy/gitgolf.git golf && cd golf
npm install -g cf@1.0.0-beta.13
npm --prefix cloudflare/agents ci && npm --prefix web ci && npm --prefix deploy/alchemy ci
cf auth create golf # browser login; keeps credentials in the cf profile
unset CLOUDFLARE_API_TOKEN
python3 scripts/cloudflare-demo-deploy.py build-image
python3 scripts/cloudflare_alchemy_demo.py init \
--account-id ACCOUNT_ID --profile golf --zone-id ZONE_ID \
--hostname golf.example.com --preview-hostname golf-previews.example.com \
--email you@example.com # prints NEW_DIRECTORY
python3 scripts/cloudflare_alchemy_demo.py plan NEW_DIRECTORY # read-only preview
python3 scripts/cloudflare_alchemy_demo.py deploy NEW_DIRECTORY
python3 scripts/cloudflare_alchemy_demo.py seed NEW_DIRECTORY --manifest deploy/demo/example.json # or --no-seed
init writes the private input under .tmp/cloudflare-forge/golf-alchemy-… (mode 0700). Keep that directory private and backed up; it holds credentials. Then add optional services from the table below.
Update
Run plan, then deploy. When the checkout adds schema migrations, deploy refuses until you run migrate:
python3 scripts/cloudflare_alchemy_demo.py migrate NEW_DIRECTORY
python3 scripts/cloudflare_alchemy_demo.py deploy NEW_DIRECTORY
migrate applies only the missing additive migrations in cloudflare/forge/migrations/, currently through 0038_source_commits.sql, oldest first. It reads each one back before advancing the private schema-receipt.json.
Move an existing installation to Alchemy
prepare reads an existing installation's receipt (for example one created by the cf recipe) and allocates a new private directory that reuses its hostnames. This replaces the installation: the old one is stopped and Alchemy creates fresh resources, so back up its D1 database if you need its history.
python3 scripts/cloudflare_alchemy_demo.py prepare /PATH/TO/OLD/ownership.json # prints NEW_DIRECTORY
python3 scripts/cloudflare_alchemy_demo.py plan NEW_DIRECTORY
python3 scripts/cloudflare-demo-deploy.py renew-authority /PATH/TO/OLD/ownership.json
python3 scripts/cloudflare_demo.py stop /PATH/TO/OLD/ownership.json # old Alchemy install: cloudflare_alchemy_demo.py destroy OLD_DIRECTORY
python3 scripts/cloudflare_alchemy_demo.py deploy NEW_DIRECTORY
python3 scripts/cloudflare_alchemy_demo.py seed NEW_DIRECTORY --manifest deploy/demo/example.json
Deleting the old custom domains leaves a DNS gap until resolvers' negative caching expires, which was 30 minutes in the hosted trial. Users must sign in to Access again.
Path 2: cf CLI recipe
git clone https://github.com/mjtechguy/gitgolf.git golf && cd golf
npm install -g cf@1.0.0-beta.13
npm --prefix cloudflare/agents ci && npm --prefix web ci
cf auth create golf
unset CLOUDFLARE_API_TOKEN
python3 scripts/cloudflare-demo-deploy.py build-image
python3 scripts/cloudflare-demo-deploy.py create \
--account-id ACCOUNT_ID --profile golf --workers-subdomain WORKERS_SUBDOMAIN \
--zone-id ZONE_ID --hostname golf.example.com \
--preview-hostname golf-previews.example.com --email you@example.com \
--manifest deploy/demo/example.json # or --no-seed; [--secrets-store-id ID] [--admin-login LOGIN]
create takes up to 45 minutes. It creates and checks these resources, then seeds the content you chose:
- an Artifacts namespace, a D1 database, R2 and Queues/Workflows
- the container runner and Durable Objects
- Workers for Platforms, Secrets Store entries and scoped tokens
- the Access applications and identity provider
- the control and preview custom domains
It prints the private receipt, .tmp/cloudflare-forge/golf-native-…/ownership.json. If seeding is interrupted, resume it; when the five-hour machine credential has expired, renew it first:
python3 scripts/cloudflare-demo-deploy.py apply .tmp/cloudflare-forge/NAME/ownership.json --manifest deploy/demo/example.json
python3 scripts/cloudflare-demo-deploy.py renew-authority .tmp/cloudflare-forge/NAME/ownership.json
create doesn't enable AI or other optional services, and its runtime provider tokens expire after seven days with no renewal command. For those, move the installation to Alchemy.
Optional services (Alchemy)
Each enable-* command only edits the private input; nothing changes until the next deploy. Run migrate first whenever a feature needs new tables. If an action below needs a new permission, run renew-deploy before deploy.
| Command | Turns on | Also run |
|---|---|---|
enable-ai [--agent-path FILE] | Private AI Gateway (authenticated, no logging or cache, 60 requests a minute, 500 cents a day), Workers AI, the <name>-ai Workflow and, with a path, agent proposals | renew-deploy, then deploy. The first deploy can stop with requires a resolved Durable Object namespace or WorkflowNotFound; deploy again. |
enable-search [--dimensions N] | Vectorize semantic search | Needs enable-ai and migrate, then renew-deploy and deploy |
enable-email [--email-limit N] | Email Service sender golf@mail.HOSTNAME | Needs migrate, then renew-deploy and deploy. Not qualified live. |
enable-webhooks --origin URL | Encrypted signed webhooks to approved origins | deploy |
enable-secrets | Repository secrets and variables key in Secrets Store | Needs migrate, then deploy. Stays unavailable until enable-workflow is set. |
enable-workflow --workflow-path PATH | Pull-request tests from one approved Actions file | deploy. Every PR head needs that file. |
enable-pipelines [--actions-url URL] | Stock Forgejo or GitLab runner pipelines (an R2 bucket, an intake queue with a dead-letter queue, and PipelineRun) | Needs migrate, then deploy, possibly twice |
enable-dead-letter | Dead-letter queue for evidence messages | deploy |
enable-operations | Service probes and the Workers analytics feed | renew-deploy, then deploy |
enable-observability | 1% redacted request logs and workspace latency history | deploy |
enable-analytics | Analytics Engine job metrics | deploy |
enable-rate-limit [--limit N --period 10|60] | Anonymous public-read throttle | deploy. Not exercised on a hosted installation. |
enable-public then seed-public | Public repositories and profiles | Needs migrate; deploy between the two commands |
renew-credentials [--days N] | Moves the 7-day runtime token expiry (1–30 days) | renew-deploy, then deploy |
renew-deploy | Replaces the 8-hour deployment token | n/a |
Verify
- Read the receipt's
stateand each recorded check. A failed or partial run is not acceptance. - Sign in at
https://CONTROL_HOSTNAMEwith the owner email (Access sends an email code). Golf admits only that mapped user. - Open the runtime capability view and
/admin/operations. A configured binding is not proof that a feature works. - After any deploy, the edge Worker serves the new version right away (
X-Golf-Worker-Release), but theWorkspaceDurable Object keeps old code until it is evicted. Close signed-in tabs, wait about two minutes, then probe again.
Cron delivery failed on the retained account. The Workspace Durable Object alarm provides the maintenance fallback, so don't assume a fresh installation has a healthy schedule.
Teardown
cf CLI recipe: run the read-only preflight, then stop:
python3 scripts/cloudflare_demo_cleanup.py .tmp/cloudflare-forge/NAME/ownership.json --check
python3 scripts/cloudflare_demo.py stop .tmp/cloudflare-forge/NAME/ownership.json
Alchemy:
python3 scripts/cloudflare_alchemy_demo.py destroy NEW_DIRECTORY
The wrapper refuses to run while jobs are active. It then:
- revokes previews
- removes owned Artifacts repositories and the namespace
- deletes CI registry tags
- runs Alchemy destroy
- deletes the runner build cache and the deployment token
This wrapper has not yet been exercised against the retained installation.
Both paths preserve the account's Secrets Store and remove only the installation's prefixed secrets. Inspect every cleanup result. Deleting a Worker alone is not enough, and certificates for removed custom domains can remain. Keep .tmp/ and .cloudflare/ directories, Alchemy state and keys out of Git, issues and documentation.
What is not turnkey yet
- One real account so far. The one-command install has completed on one real account (alongside an existing installation). Other accounts may surface plan- or region-specific gaps;
doctor --remotechecks what it can read. - Optional services on the
cfpath come only through the Alchemy hand-off, which replaces the installation. cfinstallations include qualification fixtures: a workspace namedaliceand a second userbob, so--admin-login bobis refused. Alchemyinituses your administrator login as the workspace.- Custom content is limited. The CI image knows only the packages listed in
scripts/fixtures/demo_project_ci.py, so a custom manifest should stick to those repositories for checks to pass. - A bare installation without either script: the manual
scripts/cloudflare_forge.pyinitializer in the native setup reference provisions nothing and leaves you to create D1, Artifacts, Access and the custom domain yourself. It requires--hostnameand accepts--access-team-domain. This path is not qualified end to end.
The static marketing and docs deployment is independent of the product runtime.