Cloudflare Wrangler
$ wrangler Official High RiskWrangler is Cloudflare's official developer CLI for building, locally simulating, and deploying Workers, Pages, D1 databases, KV namespaces, R2 buckets, and Durable Objects. Offers --dry-run deployment previews and --json outputs on inspection commands.
npm install -D wrangler Use wrangler for local project dev, D1 migrations, and Worker bundling/deploy; pair with Cloudflare MCP or cf for account-wide API queries.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Supports --json on D1/KV/secret/listing subcommands, --dry-run on deploy, and CI=true non-interactive behavior, though Node startup is slightly heavier than Go/Rust binaries.
wrangler deploy --dry-runandwrangler d1 execute --json- Respects
CI=1andNO_COLOR=1
Supports scoped CLOUDFLARE_API_TOKEN, --local sandboxed dev, --env isolation, and --dry-run, while remote operations carry real billing and production risks.
- Scoped
CLOUDFLARE_API_TOKEN+--localvs--remoteexplicit split - Production deploys and
d1 execute --remoterequire strict guardrails
Easy install via npm / npx across macOS, Linux, and Windows, requiring Node.js runtime.
- Standard Node.js package in
cloudflare/workers-sdk
Indispensable for Workers local runtime, bundling, and bindings—capabilities that pure API/MCP servers cannot replicate locally.
- Includes local Miniflare runtime (
wrangler dev) and asset bundling
Official Cloudflare flagship developer CLI with weekly releases.
- Maintained in
cloudflare/workers-sdkunder MIT/Apache-2.0
Detailed Cloudflare Developer Docs covering every command and binding.
- Official command docs at developers.cloudflare.com
Security, Auth & Guardrails
OAuth tokens stored under ~/.wrangler/config/ or scoped CLOUDFLARE_API_TOKEN + CLOUDFLARE_ACCOUNT_ID env vars.
CLI is free; remote deployments and Workers/D1/R2 usage follow Cloudflare account billing tiers.
# Cloudflare Wrangler Agent Rules - Always run `wrangler deploy --dry-run` before any live deploy. - Default D1/KV operations to `--local` unless `--remote` is explicitly requested. - Never execute `wrangler delete` or production `d1 execute --remote` without user approval.
Agent-Ready Command Recipes
Safe Read-Only Queries
wrangler d1 execute <db-name> --local --json --command "SELECT name FROM sqlite_master WHERE type='table';"
Runs SQL strictly against the local Miniflare D1 simulation with --json output.
wrangler deploy --dry-run --outdir dist-preview
Validates configuration and builds the Worker bundle locally without touching production.
Controlled Writes & Previews
wrangler deploy --env staging
Targets an isolated staging environment defined in wrangler.jsonc.
Strengths for Agents
- +
--localmode lets agents test D1/KV/R2 code safely without touching cloud state. - +
wrangler deploy --dry-runcatches config and bundling errors pre-flight. - + Clean
--envtargeting and scopedCLOUDFLARE_API_TOKENsupport.
Caveats & Pitfalls
- ! Requires Node.js and has noticeable cold-start overhead via
npx. - ! Not every subcommand outputs uniform JSON; some logs mix human status lines.