jackspace/claudeskillz/cloudflare-agents
- community
Checking that the SKILL.md file is still in the repository.
Guide to the Cloudflare Agents SDK for building stateful AI agents on Workers plus Durable Objects. Covers the Agent class, this.setState and this.sql state, WebSocket and streaming chat via AIChatAgent and useAgentChat, scheduling with this.schedule (delays, dates, cron), triggering Workflows, Browser Rendering, RAG with Vectorize and Workers AI embeddings, MCP servers with McpAgent, human-in-the-loop review, and routing through routeAgentRequest, getAgentByName, useAgent and AgentClient. Documents 15+ pitfalls: missing new_sqlite_classes, non-atomic migrations, Agent class not exported, binding name mismatches, global uniqueness surprises, state size limits, MCP transport confusion and bypassed authentication. Use when building AI agents, chat agents, MCP servers or multi-agent systems on Cloudflare, or debugging Agent binding, migration and state-sync errors.
Install
npx vskill@latest install jackspace/claudeskillz/cloudflare-agentsSKILL.md
Cloudflare Agents SDK
Status: Production Ready ✅ Last Updated: 2025-10-21 Dependencies: cloudflare-worker-base (recommended) Latest Versions: agents@latest, @modelcontextprotocol/sdk@latest Production Tested: Cloudflare's own MCP servers (https://github.com/cloudflare/mcp-server-cloudflare)
What is Cloudflare Agents?
The Cloudflare Agents SDK enables building AI-powered autonomous agents that run on Cloudflare Workers + Durable Objects. Agents can:
- Communicate in real-time via WebSockets and Server-Sent Events
- Persist state with built-in SQLite database (up to 1GB per agent)
- Schedule tasks using delays, specific dates, or cron expressions
- Run workflows by triggering asynchronous Cloudflare Workflows
- Browse the web using Browser Rendering API + Puppeteer
- Implement RAG with Vectorize vector database + Workers AI embeddings
- Build MCP servers implementing the Model Context Protocol
- Support human-in-the-loop patterns for review and approval
- Scale to millions of independent agent instances globally
Each agent instance is a globally unique, stateful micro-server that can run for seconds, minutes, or hours.
Quick Start (10 Minutes)
1. Scaffold Project with Template
What this creates:
- Complete Agent project structure
- TypeScript configuration
- wrangler.jsonc with Durable Objects bindings
- Example chat agent implementation
- React client with useAgent hook
2. Or Add to Existing Worker
Then create an Agent class:
3. Configure Durable Objects Binding
Create or update wrangler.jsonc:
CRITICAL Configuration Rules:
- ✅
nameandclass_nameMUST be identical - ✅
new_sqlite_classesMUST be in first migration (cannot add later) - ✅ Agent class MUST be exported (or binding will fail)
- ✅ Migration tags CANNOT be reused (each migration needs unique tag)
4. Deploy
Your agent is now running at: https://my-agent.<subdomain>.workers.dev
Configuration Deep Dive
Complete wrangler.jsonc Example
Migrations Best Practices
Atomic Deployments: Migrations are atomic operations - they cannot be gradually deployed.
Migration Rules:
- ✅ Each migration needs a unique
tag - ✅ Cannot enable SQLite on existing deployed class (must be in first migration)
- ✅ Migrations apply in order during deployment
- ✅ Cannot edit or remove previous migration tags
- ❌ Never deploy new migrations gradually (atomic only)
Environment-Specific Migrations
Agent Class API
The Agent class is the foundation of the Agents SDK. Extend it to create your agent.
Basic Agent Structure
Accessing Agent Properties
Within any Agent method:
HTTP & Server-Sent Events
HTTP Request Handling
Server-Sent Events (SSE) Streaming
SSE vs WebSockets:
| Feature | SSE | WebSockets | |
|---|---|---|---|
| Direction | Server → Client only | Bi-directional | |
| Protocol | HTTP | ws:// or wss:// | |
| Reconnection | Automatic | Manual | |
| Binary Data | Limited | Full support | |
| Use Case | Streaming responses, notifications | Chat, real-time collaboration |
Recommendation: Use WebSockets for most agent applications (full duplex, better for long sessions).
WebSockets
Complete WebSocket Example
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/cloudflare-agents/SKILL.md
Popularity
- Repository stars
- 14
- Repository forks
- 6
- 7-day trend score
- 14
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 8 May 2026, 5 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/jackspace/claudeskillz/cloudflare-agents)