Build stateful AI agents on Cloudflare Workers with WebSockets, persistent state, scheduling, and multi-agent coordination.
Works with
WebSocket-based real-time communication with automatic state synchronization across clients and devices; resumable streaming persists across disconnects and page refreshes
Built-in SQLite storage (up to 1GB per agent), task scheduling with cron expressions, and Durable Objects for globally unique, persistent agent instances
Multi-agent coordination via routeAgen
AI-first code editor with Composer
Before installing skills in Cursor, ensure your development environment meets these requirements:
node --versioncloudflare-agentsExecute the skills CLI command in your project's root directory to begin installation:
Fetches cloudflare-agents from jezweb/claude-skills and configures it for Cursor.
The CLI shows a list of agents. Use arrow keys and space to select Cursor:
Confirm successful installation by checking the skill directory location:
Restart Cursor to activate cloudflare-agents. Access via /cloudflare-agents in your agent's command palette.
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your environment. Always review source, verify the publisher, and test in isolation before production.
Submit your Claude Code skill and start earning
Automate repetitive workflows and reduce manual effort
Example
Generate reports, summarize documents, draft communications
Save 3-5 hours per week on routine tasks
Learn new skills, understand complex topics, get expert guidance
Example
Explain concepts, provide examples, suggest learning resources
Accelerate learning and skill development by 2x
Enhance output quality through reviews, suggestions, and refinements
Example
Review drafts, suggest improvements, catch errors
Improve work quality by 30-40% with less effort
0
total installs
0
this week
695
GitHub stars
0
upvotes
Run in your terminal
0
installs
0
this week
695
stars
Status: Production Ready ✅ Last Updated: 2026-01-09 Dependencies: cloudflare-worker-base (recommended) Latest Versions: [email protected], @modelcontextprotocol/sdk@latest Production Tested: Cloudflare's own MCP servers (https://github.com/cloudflare/mcp-server-cloudflare)
Recent Updates (2025-2026):
import { context } from agentsAIChatAgent now supports resumable streaming, enabling clients to reconnect and continue receiving streamed responses without data loss. This solves critical real-world scenarios:
Key capability: Streams persist across page refreshes, broken connections, and sync across open tabs and devices.
Implementation (automatic in AIChatAgent):
export class ChatAgent extends AIChatAgent<Env> {
async onChatMessage(onFinish) {
return streamText({
model: openai('gpt-4o-mini'),
messages: this.messages,
onFinish
}).toTextStreamResponse();
// ✅ Stream automatically resumable
// - Client disconnects? Stream preserved
// - Page refresh? Stream continues
// - Multiple tabs? All stay in sync
}
}
No code changes needed - just use AIChatAgent with [email protected] or later.
Source: Agents SDK v0.2.24 Changelog
The Cloudflare Agents SDK enables building AI-powered autonomous agents that run on Cloudflare Workers + Durable Objects. Agents can:
Each agent instance is a globally unique, stateful micro-server that can run for seconds, minutes, or hours.
STOP: Before using Agents SDK, ask yourself if you actually need it.
This covers 80% of chat applications. For these cases, use Vercel AI SDK directly on Workers - it's simpler, requires less infrastructure, and handles streaming automatically.
Example (no Agents SDK needed):
// worker.ts - Simple chat with AI SDK only
import { streamText } from 'ai';
import { openai } from '@ai-sdk/openai';
export default {
async fetch(request: Request, env: Env) {
const { messages } = await request.json();
const result = streamText({
model: openai('gpt-4o-mini'),
messages
});
return result.toTextStreamResponse(); // Automatic SSE streaming
}
}
// client.tsx - React with built-in hooks
import { useChat } from 'ai/react';
function ChatPage() {
const { messages, input, handleSubmit } = useChat({ api: '/api/chat' });
// Done. No Agents SDK needed.
}
Result: 100 lines of code instead of 500. No Durable Objects setup, no WebSocket complexity, no migrations.
This is ~20% of applications - when you need the infrastructure that Agents SDK provides.
Agents SDK IS:
Agents SDK IS NOT:
Think of it this way:
You can use them together (recommended for most cases), or use Workers AI directly (if you're willing to handle manual SSE parsing).
Building an AI application?
│
├─ Need WebSocket bidirectional communication? ───────┐
│ (Client sends while server streams, agent-initiated messages)
│
├─ Need Durable Objects stateful instances? ──────────┤
│ (Globally unique agents with persistent memory)
│
├─ Need multi-agent coordination? ────────────────────┤
│ (Agents calling/messaging other agents)
│
├─ Need scheduled tasks or cron jobs? ────────────────┤
│ (Delayed execution, recurring tasks)
│
├─ Need human-in-the-loop workflows? ─────────────────┤
│ (Approval gates, review processes)
│
└─ If ALL above are NO ─────────────────────────────→ Use AI SDK directly
(Much simpler approach)
If ANY above are YES ────────────────────────────→ Use Agents SDK + AI SDK
(More infrastructure, more power)
| Feature | AI SDK Only | Agents SDK + AI SDK |
|---|---|---|
| Setup Complexity | 🟢 Low (npm install, done) | 🔴 Higher (Durable Objects, migrations, bindings) |
| Code Volume | 🟢 ~100 lines | 🟡 ~500+ lines |
| Streaming | ✅ Automatic (SSE) | ✅ Automatic (AI SDK) or manual (Workers AI) |
| State Management | ⚠️ Manual (D1/KV) | ✅ Built-in (SQLite) |
| WebSockets | ❌ Manual setup | ✅ Built-in |
| React Hooks | ✅ useChat, useCompletion | ⚠️ Custom hooks needed |
| Multi-agent | ❌ Not supported | ✅ Built-in (routeAgentRequest) |
| Scheduling | ❌ External (Queue/Workflow) | ✅ Built-in (this.schedule) |
| Use Case | Simple chat, completions | Complex stateful workflows |
Start with AI SDK. You can always migrate to Agents SDK later if you discover you need WebSockets or Durable Objects. It's easier to add infrastructure later than to remove it.
For most developers: If you're building a chat interface and don't have specific requirements for WebSockets, multi-agent coordination, or scheduled tasks, use AI SDK directly. You'll ship faster and with less complexity.
Proceed with Agents SDK only if you've identified a specific need for its infrastructure capabilities.
npm create cloudflare@latest my-agent -- \
--template=cloudflare/agents-starter \
--ts \
--git \
--deploy false
What this creates:
cd my-existing-worker
npm install agents
Then create an Agent class:
// src/index.ts
import { Agent, AgentNamespace } from "agents";
export class MyAgent extends Agent {
async onRequest(request: Request): Promise<Response> {
return new Response("Hello from Agent!");
}
}
export default MyAgent;
Create or update wrangler.jsonc:
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "my-agent",
"main": "src/index.ts",
"compatibility_date": "2025-10-21",
"compatibility_flags": ["nodejs_compat"],
"durable_objects": {
"bindings": [
{
"name": "MyAgent", // MUST match class name
"class_name": "MyAgent" // MUST match exported class
}
]
},
"migrations": [
{
"tag": "v1",
"new_sqlite_classes": ["MyAgent"] // CRITICAL: Enables SQLite storage
}
]
}
CRITICAL Configuration Rules:
name and class_name MUST be identicalnew_sqlite_classes MUST be in first migration (cannot add later)npx wrangler@latest deploy
Your agent is now running at: https://my-agent.<subdomain>.workers.dev
Understanding what each tool does prevents confusion and helps you choose the right combination.
┌─────────────────────────────────────────────────────────┐
│ Your Application │
│ │
│ ┌────────────────┐ ┌──────────────────────┐ │
│ │ Agents SDK │ │ AI Inference │ │
│ │ (Infra Layer) │ + │ (Brain Layer) │ │
│ │ │ │ │ │
│ │ • WebSockets │ │ Choose ONE: │ │
│ │ • Durable Objs │ │ • Vercel AI SDK ✅ │ │
│ │ • State (SQL) │ │ • Workers AI ⚠️ │ │
│ │ • Scheduling │ │ • OpenAI Direct │ │
│ │ • Multi-agent │ │ • Anthropic Direct │ │
│ └────────────────┘ └──────────────────────┘ │
│ ↓ Prerequisites
Time Estimate
15-45 minutes depending on use case complexity
Steps
Common Pitfalls
✓ Do
✗ Don't
💡 Pro Tips
✓ Use when
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
✗ Avoid when
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
jezweb/claude-skills
jezweb/claude-skills
jezweb/claude-skills
jezweb/claude-skills
jezweb/claude-skills
jezweb/claude-skills
We added cloudflare-agents from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
Registry listing for cloudflare-agents matched our evaluation — installs cleanly and behaves as described in the markdown.
Keeps context tight: cloudflare-agents is the kind of skill you can hand to a new teammate without a long onboarding doc.
cloudflare-agents reduced setup friction for our internal harness; good balance of opinion and flexibility.
cloudflare-agents fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
Useful defaults in cloudflare-agents — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
cloudflare-agents reduced setup friction for our internal harness; good balance of opinion and flexibility.
I recommend cloudflare-agents for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
Registry listing for cloudflare-agents matched our evaluation — installs cleanly and behaves as described in the markdown.
I recommend cloudflare-agents for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
showing 1-10 of 36