durable-objects

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

5|Updated Jan 31, 2026
One-click install
npx skills add https://github.com/nuggocto/dotfiles --skill durable-objects-nuggocto
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: durable-objects
Source: https://github.com/nuggocto/dotfiles/tree/main/opencode/skills/durable-objects
Command: npx skills add https://github.com/nuggocto/dotfiles --skill durable-objects-nuggocto

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building stateful, coordinated applications on Cloudflare's edge requires deep knowledge of Durable Objects APIs, concurrency rules, SQLite storage, and wrangler configuration, and outdated 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, 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 critical state. - Testing & Configuration: Set up Vitest tests with @cloudflare/vitest-pool-workers and configure wrangler bindings, migrations, and Workers handlers. - Use Case: When building a multiplayer game backend, use this Skill to design one DO per match with deterministic getByName routing, SQLite-backed state, and alarm-based game timeouts. ## Quick Start Ask the assistant to create a Durable Object class 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 access storage synchronously via this.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 scheduled per-entity 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 using a single global Durable Object a bad pattern?

A single global DO becomes a throughput bottleneck because all requests serialize through one instance. Model around coordination atoms instead, creating one DO per chat room, game, or user with getByName for deterministic routing.

Can a Durable Object have multiple alarms scheduled?

No, each Durable Object supports only one alarm at a time, and calling setAlarm replaces any existing alarm. Reschedule the next alarm inside the alarm handler after processing due work.