
Cloudflare Workers
Design and implement edge-first APIs and agents on Cloudflare Workers with Durable Objects, D1, KV, R2, AI bindings, and Vectorize using production patterns.
Overview
cloudflare-workers is an agent skill most often used in Build (also Operate, Ship) that teaches edge-first Workers patterns with Durable Objects, D1, KV, R2, AI, and Vectorize.
Install
npx skills add https://github.com/itallstartedwithaidea/agent-skills --skill cloudflare-workersWhat is this skill?
- Edge V8 isolate model: 300+ locations, sub-ms cold starts, no container/process assumptions
- Durable Objects as single-threaded actors with SQLite, WebSockets, and alarms for stateful coordination
- Production patterns from googleadsagent.ai stacks: AI orchestration, D1/Vectorize knowledge, edge content generation
- Guidance across KV, R2, D1, AI bindings, and Vectorize for correct globally distributed architecture
- 300+ edge locations
- Sub-millisecond cold starts cited in skill positioning
Adoption & trust: 1 installs on skills.sh; 18 GitHub stars; 3/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
What problem does it solve?
You want a global, low-latency backend or agent but keep generating Node-style servers, threads, or local disk patterns that do not run correctly on Workers.
Who is it for?
Indie builders shipping AI agents, APIs, or content engines on Cloudflare with D1, Vectorize, or Durable Objects.
Skip if: Pure static frontends on Vercel only, or teams committed to long-lived Kubernetes services with no edge interest.
When should I use this skill?
Building or refactoring Cloudflare Workers that need Durable Objects, distributed storage, or AI bindings instead of traditional server architecture.
What do I get? / Deliverables
You ship Worker handlers and Durable Object designs with correct bindings, storage choices, and coordination patterns suitable for production edge deploys.
- Worker route handlers with correct bindings
- Durable Object coordination design
- Storage binding choices documented in implementation
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Workers code is authored in Build; the skill’s primary shelf is backend because routing, storage bindings, and Durable Object coordination are core product implementation. Backend subphase fits serverless edge handlers, transactional state in DOs, and storage bindings—not frontend UI work.
Where it fits
Scaffold a Worker entry that routes chat requests to a Durable Object session with transactional SQLite state.
Wire AI and Vectorize bindings for a RAG-backed agent without calling external VMs for inference routing.
Validate cold-start and geographic latency assumptions before launch traffic hits the edge.
Adjust KV/R2/D1 usage and DO alarms when production coordination or storage costs shift.
How it compares
Platform architecture skill for Cloudflare Workers—not generic Express-on-a-VM backend tutorials.
Common Questions / FAQ
Who is cloudflare-workers for?
Solo builders using agent coding tools to deploy on Cloudflare who need Durable Objects, storage bindings, and AI at the edge without reinventing platform rules.
When should I use cloudflare-workers?
While building backend routes and agent orchestration in Build, when hardening global deploy and perf in Ship, and when iterating production Workers bindings in Operate.
Is cloudflare-workers safe to install?
It is documentation and patterns for your own Workers account—check the Security Audits panel on this page and never paste production API tokens into untrusted skill bundles.
SKILL.md
READMESKILL.md - Cloudflare Workers
# Cloudflare Workers Part of [Agent Skills™](https://github.com/itallstartedwithaidea/agent-skills) by [googleadsagent.ai™](https://googleadsagent.ai) ## Description Cloudflare Workers provides comprehensive guidance for building edge-first applications using Durable Objects, KV, R2, D1, AI bindings, and Vectorize. This skill encodes production patterns from real Workers powering googleadsagent.ai™, including buddy-agent (AI orchestration), buddy-brain (knowledge storage with D1/Vectorize), and blog-engine (static content generation at the edge). Workers run in V8 isolates at 300+ edge locations with sub-millisecond cold starts and no container overhead. This fundamentally changes application architecture: computation moves to the user, state lives in globally distributed storage, and traditional server concepts (processes, threads, file systems) do not apply. The agent must understand these constraints to produce correct, performant Worker code. Durable Objects provide the stateful coordination layer that Workers alone lack. Each Durable Object instance is a single-threaded actor with transactional SQLite storage, WebSocket support, and alarm scheduling. The combination of stateless Workers for routing and stateful Durable Objects for coordination is the foundational pattern for all non-trivial edge applications. ## Use When - Building serverless APIs on Cloudflare Workers - Implementing stateful coordination with Durable Objects - Storing data in KV, R2, D1, or Vectorize - Using Workers AI for inference at the edge - Deploying applications similar to googleadsagent.ai™'s architecture - Migrating from traditional server architectures to edge-first ## How It Works ```mermaid graph TD A[Client Request] --> B[Worker: Route + Auth] B --> C{Request Type} C -->|API| D[Durable Object: buddy-agent] C -->|Content| E[KV: Cached Pages] C -->|Upload| F[R2: Object Storage] C -->|Query| G[D1: SQLite Database] D --> H[Workers AI: Inference] D --> I[Vectorize: Embeddings] G --> J[buddy-brain: Knowledge Base] E --> K[blog-engine: Page Serving] H --> L[Response to Client] I --> L J --> L K --> L ``` The Worker acts as the stateless router. It authenticates requests, determines the appropriate binding, and delegates to the specialized storage or compute layer. Durable Objects handle coordination that requires strong consistency (sessions, queues, rate limiting). ## Implementation ```typescript export default { async fetch(request: Request, env: Env): Promise<Response> { const url = new URL(request.url); if (url.pathname.startsWith("/api/chat")) { const id = env.BUDDY_AGENT.idFromName("default"); const agent = env.BUDDY_AGENT.get(id); return agent.fetch(request); } const cached = await env.PAGE_CACHE.get(url.pathname); if (cached) return new Response(cached, { headers: { "Content-Type": "text/html", "Cache-Control": "public, max-age=3600" }, }); return new Response("Not Found", { status: 404 }); }, } satisfies ExportedHandler<Env>; export class BuddyAgent extends DurableObject { async fetch(request: Request): Promise<Response> { const body = await request.json<{ message: string }>(); const embedding = await this.env.AI.run("@cf/baai/bge-base-en-v1.5", { text: [body.message], }); const similar = await this.env.VECTORIZE.query(embedding.data[0], { topK: 5, returnMetadata: "all", }); const context = similar.matches.map(m => m.metadata?.text).join("\n"); const response = await this.env.AI.run("@cf/meta/llama-3.1-8b-instruct", { messages: [ { role: "system", content: `Context: ${context}` }, { role: "user", content: body.message }, ], });