Agent Skill

Cloudflare Durable Objects
Create stateful coordination systems on Cloudflare with Durable Objects for chat rooms, multiplayer games, booking systems, and real-time collaboration
What is Cloudflare Durable Objects?
This skill instructs agents on building stateful, coordinated applications using Cloudflare Durable Objects, which provide strongly consistent, single-threaded compute instances with persistent storage. The skill covers defining Durable Object classes with RPC methods for client invocation, implementing SQLite storage for persistent state management, using alarms for scheduled operations, handling WebSocket connections for real-time bidirectional communication, integrating Durable Objects with Workers for routing and coordination, configuring wrangler for development and deployment, and testing with Vitest. The agent learns architectural patterns for common use cases like chat rooms requiring message broadcasting, multiplayer games needing conflict-free state updates, booking systems demanding strong consistency to prevent double-booking, and collaborative editing requiring coordination between concurrent users. The skill establishes boundaries around when to use Durable Objects versus simpler storage like KV—choose Durable Objects when you need coordination, transactions, or real-time features, not just key-value retrieval. Trade-offs include understanding the single-threaded execution model's implications for performance, managing the lifecycle of Durable Object instances, and balancing between storage in memory versus SQLite for different durability guarantees.
