durable-objects

Create and review Cloudflare Durable Objects for stateful coordination, SQLite storage, alarms, and WebSockets.

Updated Mar 27, 2026
One-click install
npx skills add https://github.com/gmackie/agent-skills --skill durable-objects-gmackie
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: durable-objects
Source: https://github.com/gmackie/agent-skills/tree/main/skills/durable-objects
Command: npx skills add https://github.com/gmackie/agent-skills --skill durable-objects-gmackie

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building stateful, coordinated applications on Cloudflare's edge requires correct Durable Object patterns for sharding, storage, concurrency, and testing, and outdated API knowledge leads to anti-patterns like global bottlenecks or lost in-memory state. ## Core Features & Use Cases - Durable Object Implementation: Create DO classes with RPC methods, SQLite storage, alarms, and WebSocket hibernation following current best practices. - Code Review: Audit existing DO code for anti-patterns such as single global DOs, misused blockConcurrencyWhile, and broken write coalescing. - Testing with Vitest: Set up @cloudflare/vitest-pool-workers for unit tests, integration tests via SELF, and immediate alarm execution with runDurableObjectAlarm. - Use Case: When building a multiplayer game backend, use this Skill to model one DO per game session, configure wrangler migrations with new_sqlite_classes, and write isolated tests that verify SQLite state directly. ## Quick Start Use the durable-objects skill to create a chat room Durable Object with SQLite storage, RPC methods, and wrangler configuration.

Frequently Asked Questions about durable-objects

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a Cloudflare Durable Object with SQLite storage?▼

Extend the DurableObject class from cloudflare:workers and configure new_sqlite_classes in your wrangler migrations. Initialize tables inside the constructor using ctx.blockConcurrencyWhile with ctx.storage.sql.exec for synchronous SQL operations.

How to test Durable Objects with Vitest?▼

Use @cloudflare/vitest-pool-workers with defineWorkersConfig pointing at your wrangler config. Access stubs via env from cloudflare:test, inspect internals with runInDurableObject, and trigger alarms immediately with runDurableObjectAlarm.

When should I use Durable Objects vs plain Workers?▼

Use Durable Objects for coordination, strong consistency, per-entity storage, persistent WebSocket connections, and per-entity scheduled work. Use plain Workers for stateless request handling, maximum global distribution, or high fan-out independent requests.

Does Durable Objects SQLite support PRAGMA user_version for migrations?▼

No, PRAGMA user_version is not supported in Durable Objects SQLite storage. Track schema versions in a dedicated _sql_schema_migrations table and apply incremental migrations during constructor initialization.

Why does blockConcurrencyWhile hurt Durable Object performance?▼

blockConcurrencyWhile blocks all concurrency in the instance, so using it on every request caps throughput at roughly 200 requests per second. Reserve it for one-time initialization and never hold it across fetch calls or external I/O.

How do Durable Object alarms work?▼

Each DO supports one alarm at a time, and calling setAlarm replaces any existing alarm. The alarm handler runs with automatic retries on failure, so handlers should be idempotent and can reschedule by calling setAlarm again.