cloudflare-worker — Claude Code command for Cloudflare Workers
Generate a Cloudflare Worker from a task description, with Wrangler configuration and sample requests. Useful for building an API, WebSocket service, or authentication middleware.
no license ★ 1,357 updated 2026-03-01
.claude/commands/cloudflare-worker.mdWhat cloudflare-worker does
Describe the task, and this command drafts a Cloudflare Workers solution. TypeScript and ES modules are the defaults. It asks for complete files rather than isolated edits, with output sections for the main Worker, wrangler.jsonc, types when needed, and usage or test examples.
The suggested Cloudflare service depends on the job: D1 is suited to relational data, while R2 is for object storage. The Wrangler configuration is expected to include the bindings used by the code, environment variables, and compatibility settings; the instructions set compatibility_date to 2025-03-07 and enable nodejs_compat. For WebSockets inside a Durable Object, the command calls for the hibernation API and dedicated message and close handlers. Ambiguous requirements should prompt a clarifying question.
What it helps with
- generate a REST API for Cloudflare Workers
- draft a Durable Objects WebSocket server
- write authentication middleware backed by Workers KV
- prepare Wrangler configuration with the bindings the code uses
Example prompts for the agent
- Create a Cloudflare Workers REST API that returns JSON data.
- Draft a Durable Objects WebSocket server with message handlers.
- Write authentication middleware using Workers KV.
How to install cloudflare-worker
Manually: put the files in place
.claude/commands/cloudflare-worker.mdCall it with /cloudflare-worker. For all projects use ~/.claude/commands/
Manually: put the files in place
~/.codex/prompts/cloudflare-worker.mdCall it with /prompts:cloudflare-worker. Codex marks this format deprecated in favour of skills
Manually: put the files in place
.github/prompts/cloudflare-worker.prompt.mdManually: put the files in place
.gemini/commands/cloudflare-worker.tomlGemini stores commands as TOML: the prompt text goes into the prompt field
Questions about cloudflare-worker
How do I install cloudflare-worker in Claude Code?
Copy the command file to .claude/commands/cloudflare-worker.md.
What does cloudflare-worker do?
It generates Cloudflare Workers code from a task description, along with Wrangler configuration and sample requests or tests. TypeScript and ES modules are the defaults.
How does it handle WebSockets in Durable Objects?
It uses the WebSocket hibernation API: this.ctx.acceptWebSocket(server) accepts the connection, while webSocketMessage() and webSocketClose() handle events.