durable-objects

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @cloudflare/vitest-pool-workers, vitest, and includes references (resource) components.

What problem does it solve? Building stateful, coordinated applications on Cloudflare Workers requires correct Durable Object patterns for sharding, SQLite storage, concurrency, alarms, and WebSockets, and mistakes like global singletons or broken write coalescing cause bottlenecks and data loss. ## Core Features & Use Cases - Durable Object Implementation: Create DO classes with RPC methods, SQLite storage, schema migrations, 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 unpersisted in-memory state. - Configuration & Testing: Set up wrangler bindings and migrations, plus Vitest tests with @cloudflare/vitest-pool-workers including alarm triggering and direct storage inspection. - Use Case: When building a multiplayer game or chat room on Cloudflare, use this Skill to scaffold a per-room Durable Object with SQLite persistence, typed RPC methods, and integration tests. ## Quick Start Create a Cloudflare Durable Object for a chat room 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 and run synchronous queries with ctx.storage.sql.exec.

How do I 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 instantly with runDurableObjectAlarm.

When should I use Durable Objects instead of plain Workers?▼

Use Durable Objects when you need coordination, strong consistency, per-entity storage, persistent WebSocket connections, or per-entity scheduled work. Plain Workers are better for stateless request handling and maximum global distribution.

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 is my Durable Object a bottleneck under load?▼

A single global DO instance serializes all requests and limits throughput. Model one DO per coordination atom such as a room or user using getByName, and avoid calling blockConcurrencyWhile on every request.

How do Durable Object alarms work?▼

Each DO supports one alarm at a time, and setAlarm replaces any existing alarm. Implement the alarm handler method to process scheduled work, reschedule as needed, and keep handlers idempotent since failed alarms auto-retry.