SkillOpen
wrangler-cli
Use Wrangler (Cloudflare Workers CLI) to develop, test, and deploy edge functions, manage KV stores, R2 buckets, and D1 databases. Use this instead of the Cloudflare MCP server.
Front matter
name: wrangler-cli
description: Use Wrangler (Cloudflare Workers CLI) to develop, test, and deploy edge functions, manage KV stores, R2 buckets, and D1 databases. Use this instead of the Cloudflare MCP server.Wrangler (Cloudflare Workers CLI)
Official CLI for Cloudflare Workers. Build and deploy edge functions, manage KV, R2, D1, and Queues.
- Official repo: https://github.com/cloudflare/workers-sdk
- Docs: https://developers.cloudflare.com/workers/wrangler/
Authentication
npx wrangler login # Browser-based OAuth
npx wrangler whoami # Check current user
# Or set CLOUDFLARE_API_TOKEN env varCommon Commands
Development
npx wrangler init my-worker # Create new worker
npx wrangler dev # Start local dev server
npx wrangler dev --local # Fully local (no Cloudflare)
npx wrangler dev --port 8787 # Custom portDeployments
npx wrangler deploy # Deploy worker
npx wrangler deploy --env staging # Deploy to environment
npx wrangler deployments list # List deployments
npx wrangler rollback # Rollback deployment
npx wrangler tail # Live tail logsKV Store
npx wrangler kv namespace list
npx wrangler kv namespace create MY_KV
npx wrangler kv key put --namespace-id ID "key" "value"
npx wrangler kv key get --namespace-id ID "key"
npx wrangler kv key list --namespace-id ID
npx wrangler kv key delete --namespace-id ID "key"R2 (Object Storage)
npx wrangler r2 bucket list
npx wrangler r2 bucket create my-bucket
npx wrangler r2 object put my-bucket/file.txt --file=./file.txt
npx wrangler r2 object get my-bucket/file.txtD1 (SQLite Database)
npx wrangler d1 create my-db
npx wrangler d1 list
npx wrangler d1 execute my-db --command "SELECT * FROM users LIMIT 10"
npx wrangler d1 execute my-db --file ./schema.sql
npx wrangler d1 migrations create my-db add_users
npx wrangler d1 migrations apply my-dbSecrets
npx wrangler secret put SECRET_NAME # Interactive value input
npx wrangler secret list
npx wrangler secret delete SECRET_NAMEAgent Best Practices
- Use
npx wranglerto always use the project-local version - Use
wrangler dev --localfor fast iteration without Cloudflare calls - Use
wrangler tailto debug production issues in real-time - Use
wrangler d1 executefor quick database queries - Set secrets before deploying - they persist across deployments
- Use
--envflag to manage staging/production environments
Example Workflows
Create and deploy a worker
npx wrangler init my-api
cd my-api
npx wrangler dev # Test locally
npx wrangler deployQuery D1 database
npx wrangler d1 execute my-db --command "SELECT COUNT(*) FROM users" --jsonSource: written by One Giant Leap.
Related entries
There are more like this in the members library
The Claude Code library holds 13,843 entries. Members can search all of them by meaning and read every one in full.