Skip to content
AnswerWell geo Documentation

Research · 8 min read · Answerwell

Workers CLI: Wrangler Migration, Typed Configuration, and Deploy

How the Cloudflare CLI (cf) replaces or complements Wrangler: install, cloudflare.config.ts, migrate, dev, build, deploy, and verification.

This page summarizes Cloudflare documentation on the Cloudflare CLI (cf), a beta command-line interface for the public Cloudflare API and for Workers projects. If you already use Wrangler with wrangler.jsonc or wrangler.toml, most Worker concepts carry over; the main shift is typed project configuration in cloudflare.config.ts and optional migration with cf migrate.

The Cloudflare CLI, cf, is now in beta. cf is one command-line interface for the public Cloudflare API and for Workers projects. Use it to manage zones, DNS, storage, and security settings, and to create, develop, and deploy Workers, without switching between tools.

— Cloudflare, Cloudflare CLI is now in beta

cf is in beta: commands, configuration, and Build Output can change before a stable release.

cf CLI vs Wrangler: when to use which tool

Section titled “cf CLI vs Wrangler: when to use which tool”

cf is one interface for account-wide API tasks and for Workers projects that use cloudflare.config.ts. Wrangler remains the CLI for projects configured only with wrangler.jsonc or wrangler.toml.

Area Wrangler cf
Coverage Workers and a subset of Cloudflare products The public Cloudflare API (more than 2,900 commands)
Sign-in wrangler login cf auth login (separate credentials)
Project configuration wrangler.jsonc or wrangler.toml cloudflare.config.ts (TypeScript)
Environments env blocks with --env Modes with --mode
Build Wrangler’s bundler or the Cloudflare Vite plugin Same options, selected per project
Deployable artifact Internal to Wrangler Build Output in .cloudflare/output/v0/

If you build with Wrangler, most of what you know carries over to cf. This page explains what changes, how to use cf next to an existing Wrangler project, and when to migrate the project itself.

— Cloudflare, cf for Wrangler users

You can run resource commands (cf d1 list, cf r2 buckets list, and similar) in any directory, including an unmigrated Wrangler project, without migrating. Those commands do not read the Wrangler file; set CLOUDFLARE_ACCOUNT_ID or choose an account when prompted. Keep using wrangler dev and wrangler deploy until you migrate. In automation, both tools read CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID.

Common conclusion: use Wrangler for day-to-day deploy on legacy config; use cf for DNS, D1, R2, and other API work immediately, and for full project workflow after cf migrate.

What still requires Wrangler after you migrate

Section titled “What still requires Wrangler after you migrate”

cf is in beta and does not yet cover every Wrangler task:

Live logs: cf cannot stream live logs yet. Run npx wrangler tail <WORKER_NAME> instead of installing Wrangler. Single secrets: cf cannot set a single secret yet.

— Cloudflare, cf for Wrangler users

Wrangler does not read cloudflare.config.ts. If you still run Wrangler commands in a migrated project, keep the Wrangler configuration file until you no longer need those commands.

Install cf globally so the command is available in every directory:

npm install --global cf

The package also installs cloudflare as an alias if another cf is already on your PATH. Confirm installation with cf --version, then sign in:

cf auth login

cf prints a link and a one-time code, and opens the link in your browser. Approve the request to give cf access to your Cloudflare account.

— Cloudflare, Get started

cf keeps its own credentials and does not reuse a Wrangler login. On a headless machine, use cf auth login --no-browser. Projects created with cf init pin cf as a development dependency so collaborators and CI run the same version; loading cloudflare.config.ts requires Node.js 22.18 or later (Bun cannot load that file in-project).

cloudflare.config.ts: typed Workers configuration

Section titled “cloudflare.config.ts: typed Workers configuration”

cloudflare.config.ts is the typed configuration file for a Workers project. Its default export can define a Worker, Container applications, and account settings.

cloudflare.config.ts is the typed configuration file for a Workers project. Its default export can define a Worker, Container applications, and account settings. Because the file is a TypeScript module, it can use imports, functions, environment variables, and asynchronous values.

— Cloudflare, Programmatic configuration

Set "type": "module" in package.json. Import helpers from cf/config and use defineConfig() for the default export. A Worker that runs code needs at minimum worker.name, worker.compatibilityDate, and worker.entrypoint. The recommended entrypoint form imports the module with the cf-worker import attribute so editors infer binding and export types:

import { bindings, defineConfig } from "cf/config";
import * as entrypoint from "./src/index.ts" with { type: "cf-worker" };
export default defineConfig({
worker: {
name: "my-worker",
compatibilityDate: "2026-08-24",
entrypoint,
env: {
WORLD: bindings.text("World"),
},
},
});

Bindings live under worker.env (bindings.d1(), bindings.queue(), bindings.secret(), and others). Triggers (triggers.fetch(), triggers.scheduled(), triggers.queue(), and more) go in worker.triggers. Exports (exports.durableObject(), exports.workflow()) declare platform lifecycle for classes; bindings inject resources on env. The Configuration explorer documents every field.

Pass --mode (or -m) so a function-form config returns different values:

cf dev --mode staging
cf build --mode staging
cf deploy --mode staging

Return one complete configuration for each mode. Programmatic configuration does not merge environment blocks the way Wrangler environments do. A mode deploys a separate Worker only when it returns a different name.

— Cloudflare, Develop, build, and deploy

When you omit --mode, the Cloudflare Vite plugin uses development for cf dev and production for cf build and cf deploy. Build Output records the mode; prebuilt deploys must pass the same mode.

cf dev, cf build, and cf deploy: how the CLI runs your project

Section titled “cf dev, cf build, and cf deploy: how the CLI runs your project”

cf does not run a dev server or bundler itself. For cf dev, cf build, and every other command that builds first, cf hands the work to one of these tools: The framework’s own command … An installed Cloudflare build tool … the Cloudflare Vite plugin, or Wrangler 4.136.0 or later.

— Cloudflare, Develop, build, and deploy

Builds write Build Output to .cloudflare/output/v0/. cf does not run your package.json scripts; if you need tsc -b before Vite, chain it yourself (tsc -b && cf build). When cf forwards to a framework command (for example npx vite), it forwards only --mode—set ports and other flags in vite.config.ts or run Vite directly.

New projects start with:

cf init my-worker

cf init creates cloudflare.config.ts, vite.config.ts with @cloudflare/vite-plugin@beta, and scripts that call cf dev, cf build, and cf deploy. For CI, pass --package-manager and optionally --no-install as described in Deploy your first Worker.

cf migrate: move from wrangler.jsonc to cloudflare.config.ts

Section titled “cf migrate: move from wrangler.jsonc to cloudflare.config.ts”

Migrate when you want TypeScript configuration with inferred binding types, one CLI for project and account tasks, or build-once deploy-later workflows from CI.

  1. Commit or stash changes; install dependencies (Wrangler bundler path needs Wrangler 4.136.0+).
  2. Preview: cf migrate --dry-run (optionally --bundler vite or --bundler wrangler).
  3. Run: cf migrate in the directory with exactly one Wrangler config (or pass the file path).
  4. Resolve every [required] follow-up and remove TODO(@cloudflare) comments plus the top-level throw in cloudflare.config.ts.
  5. Update scripts to cf dev / cf build / cf deploy, add .cloudflare/ to .gitignore, and deploy with cf deploy.

cf migrate writes cloudflare.config.ts beside the Wrangler file, adds cf as a dev dependency, and optionally creates wrangler.config.ts for Wrangler-bundler build settings. It never overwrites an existing cloudflare.config.ts. Durable Object migrations history is not converted; replace with worker.exports declarations (Wrangler to cf reference). Wrangler env blocks become switch (ctx.mode) cases—use --mode instead of --env.

Find commands and documentation from the terminal

Section titled “Find commands and documentation from the terminal”

With more than 2,900 API-backed commands, discovery tools matter:

Task Command Credentials
Find a command cf cli search "create D1 database" Not required (local)
Inspect API shape cf schema d1 create Not required for schema
Search docs cf docs search "proxy a DNS record" Internet only; no login

Cloudflare CLI 1.0.0-beta.16 includes cf docs search, so you and your coding agent can find Cloudflare documentation without leaving the terminal.

— Cloudflare, Search Cloudflare documentation with the Cloudflare CLI

cf docs search returns up to five JSON results with title, description, and url. Fetch a page as Markdown with curl -H "Accept: text/markdown" "<url>". Command names use kebab-case in recent releases (for example cf accounts billing get-credits).

For coding agents, Cloudflare documents setup in Use cf with coding agents: prefer cf unless the repo still has only a Wrangler configuration file; use cf cli search and cf docs search without putting secrets in queries; preview destructive work with --dry-run.

cf in CI: pinning and non-interactive behavior

Section titled “cf in CI: pinning and non-interactive behavior”

Pin cf as a dev dependency and run npx cf <command> so CI matches local versions (Use cf in CI). Non-interactive runs use default answers for prompts, abort destructive commands without --force (exit 0 with Aborted. on stderr), and require explicit flags for cf init directory choice. Disable telemetry with CF_SEND_TELEMETRY=false or DO_NOT_TRACK=1.

Artifact-based pipelines can use @cloudflare/ci runners with cache inputs on lockfiles, then wrangler deploy or cf deploy with CLOUDFLARE_API_TOKEN—see Build and deploy on push for the workflow pattern.

  • Running cf build in an unmigrated Wrangler repo — can corrupt config; run cf migrate first or undo auto-generated files per cf for Wrangler users.
  • Expecting cf to run your package.json scripts — chain custom steps before cf build (Develop, build, and deploy).
  • Deploying prebuilt output with the wrong mode — rebuild or pass the mode recorded in .cloudflare/output/v0/config.json.
  • Using D1 database names with cf d1 query — cf expects API IDs; Wrangler often accepts names (cf for Wrangler users).
  • Leaving migration throw in cloudflare.config.ts — cf dev, cf build, and cf deploy fail until TODOs are resolved (Migrate a Wrangler project).
  • Trusting exit code 0 on destructive commands in CI — without --force, deletes abort with status 0; read stderr (Use cf with coding agents).
  1. Run cf --version and cf auth whoami after install and sign-in to confirm the CLI and account.
  2. In a cf project, run cf build and confirm .cloudflare/output/v0/config.json exists (Develop, build, and deploy).
  3. Run cf cli search "<your task>" and cf schema <command> to verify command discovery (Manage resources from the command line).
  4. Before migrating production, run cf migrate --dry-run and review required follow-ups (Migrate a Wrangler project).
  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about.