Commands
Execute Cloudflare CLI commands and automate Cloudflare workflows
What Is This?
Overview
Cloudflare provides a powerful command-line interface through its Wrangler tool, enabling developers to manage Workers, Pages, KV storage, R2 buckets, and other Cloudflare services directly from the terminal. Rather than navigating the Cloudflare dashboard for every configuration change or deployment, developers can script, automate, and integrate these operations into their existing workflows with precision and speed.
The Wrangler CLI serves as the primary interface for interacting with Cloudflare's developer platform. It supports the full lifecycle of serverless application development, from initializing a new project and running a local development server to deploying production-ready code and managing environment variables. Understanding the available commands and their options significantly reduces the time spent on repetitive tasks.
Cloudflare's CLI tooling integrates naturally with modern JavaScript and TypeScript ecosystems. Projects built with frameworks like Next.js, Remix, or plain Workers can be managed through a consistent set of commands, making it easier to maintain multiple projects under a unified workflow.
Who Should Use This
- Backend and full-stack developers building serverless applications on Cloudflare Workers
- DevOps engineers automating deployment pipelines for Cloudflare-hosted services
- Frontend developers deploying static sites and server-side rendered applications through Cloudflare Pages
- Platform engineers managing KV namespaces, R2 buckets, and Durable Objects at scale
- Teams adopting infrastructure-as-code practices who need repeatable, scriptable deployment commands
- Developers migrating existing applications to Cloudflare's edge network
Why Use It?
Problems It Solves
- Manual dashboard operations are slow and error-prone when deploying frequently or managing multiple environments
- Inconsistent deployments caused by clicking through UI steps can be eliminated by scripting Wrangler commands in CI/CD pipelines
- Local testing without proper tooling leads to bugs discovered only in production, which Wrangler's local dev server addresses directly
- Managing secrets and environment variables through a UI is impractical for teams, and Wrangler provides secure CLI-based secret management
- Coordinating multiple Cloudflare resources such as Workers, bindings, and storage requires a unified tool rather than separate dashboard sections
Core Highlights
- Initialize new Worker projects with preconfigured templates using a single command
- Run a local development server that closely mirrors the Cloudflare edge runtime
- Deploy Workers and Pages projects to production or staging environments
- Manage KV namespaces and write, read, or delete key-value pairs from the terminal
- Upload and manage files in R2 object storage buckets
- Handle secrets securely without exposing values in configuration files
- Tail live logs from deployed Workers for real-time debugging
- Generate TypeScript types from your Wrangler configuration automatically
How to Use It?
Basic Usage
Install Wrangler globally or use it through npx:
npm install -g wrangler
wrangler --versionAuthenticate with your Cloudflare account:
wrangler loginInitialize a new Worker project:
wrangler init my-workerDeploy a Worker to production:
wrangler deploySpecific Scenarios
Local Development with Live Reload
Start a local development server that watches for file changes and reloads automatically:
wrangler dev --localManaging KV Storage
Create a KV namespace and write a value:
wrangler kv namespace create MY_NAMESPACE
wrangler kv key put --namespace-id=<id> "user:123" '{"name":"Alice"}'Handling Secrets
Add a secret to a deployed Worker without storing it in plain text:
wrangler secret put API_KEYReal-World Examples
A deployment script in a CI pipeline might run wrangler deploy --env production after tests pass, ensuring only verified code reaches the edge. A developer debugging a live issue can run wrangler tail to stream request logs directly to the terminal. A team managing multiple environments can use wrangler deploy --env staging to push changes to a staging Worker before promoting to production.
When to Use It?
Use Cases
- Deploying serverless functions to Cloudflare's global edge network
- Automating deployments in GitHub Actions or other CI/CD systems
- Debugging production Workers using live log tailing
- Seeding or querying KV and R2 storage during development
- Managing multiple deployment environments with environment-specific configurations
- Rotating secrets and API keys without modifying source code
- Generating type definitions for Worker bindings in TypeScript projects
Important Notes
Requirements
- Node.js version 16.17.0 or higher must be installed on the local machine
- A Cloudflare account with appropriate permissions for the resources being managed
- Authentication via
wrangler loginor a validCLOUDFLARE_API_TOKENenvironment variable for CI environments
More Skills You Might Like
Explore similar skills to enhance your workflow
Positioning Ideas
Brainstorm product positioning ideas differentiated from competitors. Identifies top competitors and generates positioning statements with
Kotlin Specialist
Kotlin Specialist automation and integration for modern JVM and Android development
Competitive Ads Extractor
Extracts and analyzes competitors' ads from ad libraries (Facebook, LinkedIn, etc.) to understand what messaging, problems, and creative approaches ar
Hard Call
/em -hard-call — Framework for Decisions With No Good Options
Organization Best Practices
Configure multi-tenant organizations, manage members and invitations, define custom roles and permissions, set up teams, and implement RBAC using
Analyzing Prefetch Files for Execution History
Parse Windows Prefetch files to determine program execution history including run counts, timestamps, and referenced