# Using `cf` instead of Wrangler [`cf`](https://developers.cloudflare.com/cf/) is Cloudflare's CLI for the whole public API. It can replace Wrangler for dgit, but not as a drop-in yet. This page records what works today, what needs a migration, and the migration steps for this repository. Checked against `cf` 1.0.0-beta.20 and the Cloudflare docs of October 2026. `cf` is in beta; commands and configuration can change. ## Compatibility at a glance | Task | Wrangler (today) | `cf` without migration | `cf` after `cf migrate` | | --- | --- | --- | --- | | Configuration file | `wrangler.jsonc` | not read | `cloudflare.config.ts` | | Sign in | `wrangler login` | `cf auth login` (separate credentials) | same | | Local dev | `wrangler dev` | **do not run** | `cf dev` | | Deploy | `wrangler deploy` | **do not run** | `cf deploy` | | Create the R2 bucket | `wrangler r2 bucket create dgit-pack-cache` | `cf r2 buckets create --name dgit-pack-cache` | same | | Set `GIT_TOKEN` | `wrangler secret put GIT_TOKEN` | not supported | `cf deploy --secrets-file ` | | Live logs | `wrangler tail` | not supported | not supported; use `npx wrangler tail git-cells` | | Versions, deployments | `wrangler versions/deployments` | `cf workers versions/deployments` | same | | celld (`wrangler.celld.jsonc`) | read by `celld deploy` | unaffected | unaffected | In short: - **Resource and account commands work now.** `cf r2 ...`, `cf workers deployments ...`, `cf durable-objects ...` and similar call the API directly and ignore `wrangler.jsonc`. They do not use its `account_id`: set `CLOUDFLARE_ACCOUNT_ID` or pick an account when `cf` asks. Both tools read `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` in CI. - **Project commands need a migration.** `cf dev`, `cf build`, and `cf deploy` read only `cloudflare.config.ts`. In this repository, without that file, they fail or run automatic configuration, which writes its own config and changes `package.json`. Do not run them until you have run `cf migrate`. - **Project commands still use Wrangler underneath.** With the Wrangler bundler, `cf build` and `cf deploy` run the project's own Wrangler, which must be 4.136.0 or later. The lockfile pins 4.123.0, so `cf deploy` currently stops with `cf requires wrangler@4.136.0 or newer`. ## Finding commands `cf` has more than 2,900 commands. Search instead of walking `--help`: ```sh cf cli search "create an r2 bucket" # five JSON matches cf r2 buckets create --help # flags for one match cf schema r2 buckets create # the underlying API request cf docs search "durable object exports" # Cloudflare docs, ranked ``` Keep search queries generic. Do not put account IDs, domains, or tokens in them. ## Use `cf` next to Wrangler (no migration) Keep deploying with Wrangler as the [README](../README.md) shows, and use `cf` for the resources around the Worker: ```sh cf auth login cf auth whoami cf r2 buckets create --name dgit-pack-cache # optional R2 pack offload cf r2 buckets list cf workers deployments list --worker git-cells ``` `cf` resource commands take the IDs the API expects, not friendly names, for most resources (for example, D1 database IDs). Check `--help` when a name is rejected. ## Migrate this repository to `cf` A dry run on this repository reports three required follow-ups: both Durable Object bindings (`REPO`, `REGISTRY`) and the `migrations` block. `cf migrate` keeps the Worker name, routes, R2 binding, `vars`, and limits. 1. Start from a clean worktree and a current Wrangler: ```sh git status # must be clean npm install --save-dev wrangler@latest # 4.136.0 or later git commit -am "chore(deps): update wrangler for cf" ``` 2. Preview, then migrate. Pass the path, because the directory also has `wrangler.celld.jsonc`: ```sh cf migrate wrangler.jsonc --dry-run cf migrate wrangler.jsonc ``` This writes `cloudflare.config.ts` (and `wrangler.config.ts` for build settings), adds `cf` as a dev dependency, and leaves `wrangler.jsonc` unchanged. The generated config starts with a `throw` until the follow-ups are resolved. 3. Resolve the Durable Object follow-ups. Both classes were created with `new_sqlite_classes`, so declare them with SQLite storage under `worker`: ```ts import { bindings, defineConfig, exports } from "cf/config"; // inside worker: { ... } exports: { RepoCell: exports.durableObject({ storage: "sqlite" }), Registry: exports.durableObject({ storage: "sqlite" }), }, ``` Check that each generated binding reads `bindings.durableObject({ worker: "git-cells", exportName: "RepoCell" })` (and `"Registry"`). Do not copy the `migrations` history; the `v1` tag is already applied. Then delete the `TODO(@cloudflare)` comments and the `throw` statement. 4. Declare the secret, so the Worker's `env` type includes it: ```ts // inside worker.env GIT_TOKEN: bindings.secret(), ``` 5. Finish the project: - In `package.json`, set `"dev": "cf dev"` and `"deploy": "cf deploy"`. (`"type": "module"` is already set.) - Add `.cloudflare/` to `.gitignore`. - Add `"cloudflare.config.ts"` and `".cloudflare/types"` to `include` in `tsconfig.json`, then generate types with `cf workers types`. 6. Validate without uploading, then deploy: ```sh cf dev # check that the index page loads, then stop it cf build cf deploy --dry-run # prints bindings; must show REPO, REGISTRY, PACK_CACHE cf deploy ``` The dry run must list the Worker as `git-cells`. A different name deploys a new, empty Worker, and the existing repositories stay bound to the old one. ## Secrets with `cf` `cf` cannot set one secret on its own yet. Choose one: - Upload with a deploy. Put the token in a file that git ignores (for example, `.dev.vars`, which is already in `.gitignore`) and run `cf deploy --secrets-file .dev.vars`. This makes a new Worker Version that includes the secret. - Keep using Wrangler for this one step: `npx wrangler secret put GIT_TOKEN --name git-cells`. Do not pass the token with `--text` on the command line; it stays in the shell history and the process list. ## Keep `wrangler.jsonc` After the migration, keep `wrangler.jsonc` while you still need Wrangler for `wrangler tail` or `wrangler secret put`: Wrangler does not read `cloudflare.config.ts`. While both files exist, change bindings, routes, and `vars` in both, or the two tools deploy different Workers. `wrangler.celld.jsonc` is for celld, not for `cf`. Keep it, and pass its path to `cf migrate` only if you want a `cf` config for that target too.