Skip to main content
Version: Next · development

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.

Alpha

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.

Set up with an AI agent

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).

Tested on a real account

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​

PathUse it toCommand 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 recipeA 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​

ValueWhere it goesHow to get it
Cloudflare account ID (32 hex characters)--account-idDashboard account home, or the accounts list in cf --profile golf auth whoami
Signed-in cf profile name--profilecf 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-idZone overview in the dashboard. Put both hostnames in this zone.
Control hostname, such as golf.example.com--hostnameChoose an unused name in that zone.
Preview hostname, such as golf-previews.example.com--preview-hostnameA different unused name. Each preview is served from a child hostname under it.
Owner email--emailAn 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-subdomainThe NAME in NAME.workers.dev, from the Workers & Pages overview. It must already exist.
Optional: administrator login--admin-loginDefaults to a login derived from the email (jane.doe@… → jane-doe).
Optional: Git author (Alchemy)--git-author-name, --git-author-emailDefault to the administrator login and email.
Optional: Access team domain (Alchemy)--access-team-domainRead from your Zero Trust organization when omitted.
Existing Secrets Store ID (only if the account already has a store)--secrets-store-idSecrets Store in the dashboard. If a store exists and you omit this flag, the install stops.
Optional: webhook receiver originsAlchemy enable-webhooks --origin https://…Your receiver's HTTPS origin. Receiver URLs and signing secrets are entered later in repository settings.
Optional: daily email limitAlchemy 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 pathAlchemy enable-ai --agent-path FILEThe one source file agents may change across the installation.
Optional: search vector sizeAlchemy enable-search --dimensions N (32–4096, default 1024)It must match the embedding model you select in AI model settings.
Optional: Actions workflow pathAlchemy enable-workflow --workflow-path .github/workflows/NAME.ymlYour workflow file.
Optional: anonymous read limitAlchemy enable-rate-limit --limit N --period 10|60Your 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​

RequirementNeeded forNotes
Workers PaidEverythingQueues, Containers and Artifacts require it.
ArtifactsGit storage (required)Open beta on Workers Paid. The deploy token needs the Artifacts Write permission.
ContainersTests and agent tasks (required)The runner image must be linux/amd64.
Workers for PlatformsWorker 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, WorkflowsRequiredEnable R2 for the account before the first deploy.
Secrets StoreRequiredThe account has one store, and Golf reuses it. Golf adds only secrets prefixed with the installation name and removes only those.
Zero Trust (Access) organizationRequiredNeeds 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 DNSRequiredCustom domains for the control Worker, the preview gateway and per-preview child hostnames.
Workers AI + AI GatewayOptional (enable-ai)Inference is billed by Cloudflare.
VectorizeOptional (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 AnalyticsOptionalEnabled 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 Write or Vectorize Write.
  • 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.

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​

ToolVersionNotes
Node.js24The cf CLI itself needs 22 or later.
cf CLIexactly 1.0.0-beta.13Install with npm install -g cf@1.0.0-beta.13. cloudflare/forge/prepare.mjs refuses other versions. Wrangler is not used.
DockerCurrent, with BuildKitBuilds the linux/amd64 runner image. Arm hosts need amd64 emulation.
Python3Runs the deploy scripts.
GitAny recent versionNeeded for the seed and checks.
Go1.27 (per go.mod)The cf CLI recipe builds the Golf CLI.
Outbound Internet accessn/aThe 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

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.

CommandTurns onAlso 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 proposalsrenew-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 searchNeeds enable-ai and migrate, then renew-deploy and deploy
enable-email [--email-limit N]Email Service sender golf@mail.HOSTNAMENeeds migrate, then renew-deploy and deploy. Not qualified live.
enable-webhooks --origin URLEncrypted signed webhooks to approved originsdeploy
enable-secretsRepository secrets and variables key in Secrets StoreNeeds migrate, then deploy. Stays unavailable until enable-workflow is set.
enable-workflow --workflow-path PATHPull-request tests from one approved Actions filedeploy. 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-letterDead-letter queue for evidence messagesdeploy
enable-operationsService probes and the Workers analytics feedrenew-deploy, then deploy
enable-observability1% redacted request logs and workspace latency historydeploy
enable-analyticsAnalytics Engine job metricsdeploy
enable-rate-limit [--limit N --period 10|60]Anonymous public-read throttledeploy. Not exercised on a hosted installation.
enable-public then seed-publicPublic repositories and profilesNeeds 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-deployReplaces the 8-hour deployment tokenn/a

Verify​

  1. Read the receipt's state and each recorded check. A failed or partial run is not acceptance.
  2. Sign in at https://CONTROL_HOSTNAME with the owner email (Access sends an email code). Golf admits only that mapped user.
  3. Open the runtime capability view and /admin/operations. A configured binding is not proof that a feature works.
  4. After any deploy, the edge Worker serves the new version right away (X-Golf-Worker-Release), but the Workspace Durable Object keeps old code until it is evicted. Close signed-in tabs, wait about two minutes, then probe again.
note

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:

  1. revokes previews
  2. removes owned Artifacts repositories and the namespace
  3. deletes CI registry tags
  4. runs Alchemy destroy
  5. 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 --remote checks what it can read.
  • Optional services on the cf path come only through the Alchemy hand-off, which replaces the installation.
  • cf installations include qualification fixtures: a workspace named alice and a second user bob, so --admin-login bob is refused. Alchemy init uses 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.py initializer in the native setup reference provisions nothing and leaves you to create D1, Artifacts, Access and the custom domain yourself. It requires --hostname and accepts --access-team-domain. This path is not qualified end to end.

The static marketing and docs deployment is independent of the product runtime.