durable-objects

Design, implement, and review Cloudflare Durable Objects with storage, concurrency, and testing guidance.

1|Updated Jul 16, 2026
One-click install
npx skills add https://github.com/sota411/codex-config --skill durable-objects-sota411
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: durable-objects
Source: https://github.com/sota411/codex-config/tree/main/user-skills/durable-objects
Command: npx skills add https://github.com/sota411/codex-config --skill durable-objects-sota411

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building stateful, strongly consistent coordination on Cloudflare Workers requires correct use of Durable Objects APIs, and mistakes in concurrency, persistence, or migrations can silently corrupt state or lose data. ## Core Features & Use Cases - Design & Sharding Guidance: Model one Durable Object per coordination unit, use parent-child relationships, and apply location hints for latency-sensitive workloads. - Storage & Concurrency Rules: Apply SQLite storage, schema migrations via a _sql_schema_migrations table, input/output gates, write coalescing, and safe blockConcurrencyWhile usage. - Workers Integration & Testing: Configure wrangler bindings and migrations, typed RPC methods, alarms, WebSocket hibernation, and tests with @cloudflare/vitest-pool-workers including runInDurableObject and runDurableObjectAlarm. - Use Case: When adding a chat room feature to a Workers app, use this Skill to design the ChatRoom Durable Object, write its SQLite schema migration, wire wrangler bindings, and verify alarm behavior in isolated tests. ## Quick Start Use the durable-objects skill to review my Durable Object class for concurrency and persistence issues before I deploy it.

Frequently Asked Questions about durable-objects

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

FAQPage Schema
How do I design a Cloudflare Durable Object for my app?▼

Create one Durable Object per logical coordination unit such as a chat room, game session, or user, and access it with getByName using that entity's ID. Avoid a single global object, which becomes a bottleneck, and use parent-child objects for hierarchical data.

How do I run schema migrations in Durable Objects SQLite storage?▼

PRAGMA user_version is not supported, so track versions in a _sql_schema_migrations table and apply incremental changes inside blockConcurrencyWhile in the constructor. Libraries like durable-utils provide a SQLSchemaMigrations helper for production use.

How do I test Durable Objects with vitest?▼

Use @cloudflare/vitest-pool-workers with defineWorkersConfig pointing at your wrangler config. Tests can call stubs directly, use SELF.fetch for HTTP integration, runInDurableObject for internal storage assertions, and runDurableObjectAlarm to trigger alarms immediately.

When should I avoid using blockConcurrencyWhile?▼

Use blockConcurrencyWhile only for one-time initialization such as migrations, since it blocks all concurrency and roughly caps throughput at 200 requests per second. Never hold it across external I/O like fetch, R2, or KV calls.

Can a Durable Object have multiple alarms scheduled?▼

No, each Durable Object supports exactly one scheduled alarm, and calling setAlarm replaces the existing one. Coordinate all scheduled work through a single alarm handler that reschedules itself based on the next due task.

When should I not use a Durable Object?▼

Stateless request handlers and simple high-volume key lookups do not need a Durable Object; plain Workers with KV or D1 fit better. Durable Objects are justified when you need per-entity coordination, strongly consistent state, or persistent WebSocket connections.