jackspace/claudeskillz
Overview
This skill is a concise, practical guide for the Cloudflare Agents SDK that helps you build AI-powered, stateful agents on Cloudflare Workers + Durable Objects. It covers setup, configuration rules, common pitfalls, APIs for HTTP, WebSockets, scheduling, RAG, Browser Rendering, MCP servers, and workflows. Use it to avoid known configuration errors and to implement reliable, scalable agents quickly.
How this skill works
The guide explains how to scaffold or add Agents to existing Workers, configure Durable Objects and migrations (including SQLite enablement), and implement Agent lifecycle hooks like onRequest, onConnect, onMessage, schedule, and custom methods. It documents bindings for AI, Vectorize, Browser, Workflows, D1, and R2, and shows how to persist state, stream events, manage WebSockets, and run asynchronous workflows and cron tasks. The content enumerates 15+ documented failure modes with concrete prevention steps.
When to use it
- Building AI-driven autonomous agents on Cloudflare Workers and Durable Objects
- Creating stateful agents with persisted SQLite state and SQL access
- Implementing real-time clients with WebSockets or SSE and streaming chat
- Scheduling tasks with cron, delays, or cloud workflows
- Building RAG systems with Vectorize and embeddings or running Browser Rendering
- Setting up MCP servers, human-in-the-loop flows, multi-agent orchestration
Best practices
- Always export the Agent class and ensure durable binding name and class_name match exactly
- Put new_sqlite_classes in the first migration; migrations are atomic and cannot be added later
- Use unique migration tags and avoid reusing or editing past tags
- Prefer WebSockets for interactive, long-lived sessions; use SSE for server→client streaming
- Limit agent state size and use D1/R2 for large or structured data; monitor state size limits
- Validate workflow and browser bindings at deploy time; fail early for missing bindings
Example use cases
- Chat agent with streaming responses and stateful conversation history
- Worker that spawns scheduled tasks for reminders, retries, or batch jobs
- RAG assistant using Vectorize index + Workers AI embeddings for retrieval-augmented answers
- MCP server implementation that exposes model context to clients and other agents
- Web-browsing agent using Browser Rendering + Puppeteer to fetch and summarize pages
FAQ
If SQLite is not enabled in the initial migration, you cannot enable it later for that class. Always include new_sqlite_classes in your first migration tag.
Why does my Durable Objects binding fail at deploy?
Most common causes: class not exported, mismatch between binding name and class_name, or reused migration tags. Verify exact string matches and export the class.
How do I avoid state size errors?
Keep in-memory state small, store large objects in D1 or R2, and paginate or compress logs. Monitor agent state growth and enforce limits within your code.
5 skills
This skill helps you build and manage Cloudflare AI agents with durable objects, WebSockets, and RAG, boosting scalable automation.
This skill searches Bilibili, downloads subtitles, and converts them to Markdown for easy analysis and sharing.
This skill analyzes errors, recalls past fixes, and provides immediate code-based resolutions with examples to speed debugging.
This skill helps you master TanStack Query v5 for efficient data fetching, caching, and mutations in React applications.
This skill helps you orchestrate CLI workflows, secure Bash usage, and automate Git tasks with robust patterns and hooks.