durable-objects

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

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

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's edge requires correct Durable Object design—sharding, concurrency control, SQLite migrations, alarms, and WebSocket handling—and mistakes like single global DOs or in-memory-only state cause production failures. This Skill provides retrieval-first guidance, code patterns, and review checklists for implementing and auditing Durable Objects correctly. ## Core Features & Use Cases - DO Implementation Guidance: Covers class modeling, RPC methods, blockConcurrencyWhile initialization, SQLite storage with schema migrations, alarms, and WebSocket hibernation. - Testing Support: Provides Vitest setup with @cloudflare/vitest-pool-workers, including unit tests, integration tests via SELF, alarm triggering, and direct storage inspection with runInDurableObject. - Workers Integration: Details wrangler.jsonc/toml configuration, bindings, migrations, TypeScript env types, request validation, and observability patterns. - Use Case: When building a multiplayer game backend, use this Skill to model one DO per game session, configure new_sqlite_classes migrations, implement RPC methods, and write isolated Vitest suites validating state transitions. ## Quick Start Use the durable-objects skill to create a chat room Durable Object with SQLite storage, wrangler bindings, and Vitest tests.

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, run schema setup inside the constructor using blockConcurrencyWhile, and add a migration with new_sqlite_classes in your wrangler config. Use this.ctx.storage.sql.exec for synchronous parameterized queries.

How do I test Durable Objects with Vitest?▼

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

When should I not use Durable Objects?▼

Avoid Durable Objects for stateless request handling, workloads needing maximum global distribution, or high fan-out independent requests. Plain Workers fit stateless cases better since DOs are anchored to a single location per instance.

Why is my Durable Object slow under load?▼

Common causes are a single global DO handling all requests or calling blockConcurrencyWhile on every request, which caps throughput around 200 requests per second. Model one DO per coordination atom and reserve blockConcurrencyWhile for constructor initialization only.

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 with a dedicated _sql_schema_migrations table, or use libraries like durable-utils or @cloudflare/actors that provide migration helpers.

How many alarms can a Durable Object have?▼

Each Durable Object supports exactly one alarm; calling setAlarm replaces any existing alarm. Design handlers to reschedule the next alarm after processing, and keep handlers idempotent since failed alarms auto-retry.