durable-objects

Build, debug, and review Cloudflare Durable Objects code for persistent state and coordination.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing correct Cloudflare Durable Objects code requires up-to-date knowledge of storage APIs, concurrency rules, alarms, and wrangler configuration, and outdated assumptions lead to bottlenecks, lost state, and broken migrations. ## Core Features & Use Cases - Implementation Guidance: Provides patterns for Durable Object classes, RPC methods, SQLite storage, alarms, and WebSocket handlers with current Cloudflare documentation links. - Code Review Rules: Lists critical rules and anti-patterns such as avoiding single global objects, misusing blockConcurrencyWhile, and storing critical state only in memory. - Testing & Configuration References: Includes references for Vitest-based testing, wrangler.jsonc bindings and migrations, TypeScript environment types, and Worker handler patterns. - Use Case: When building a chat room with per-room state, use this Skill to design one Durable Object per room, configure SQLite migrations, and write tests that verify state persistence across calls. ## Quick Start Use the durable-objects skill to create a Durable Object class with SQLite storage and wire it up in wrangler.jsonc.

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 initialize tables inside the constructor using ctx.blockConcurrencyWhile with ctx.storage.sql.exec. Register the class in wrangler.jsonc migrations using new_sqlite_classes so the SQLite backend is enabled.

How do I route requests to a specific Durable Object instance?

Use env.MY_DO.getByName("room-123") for deterministic routing so the same name always maps to the same instance. For existing IDs use idFromString with get(), and for new entities use newUniqueId() while storing the mapping externally.

Should I use SQLite or KV storage for Durable Objects?

SQLite storage is recommended for new classes and is configured via new_sqlite_classes in migrations. Existing KV-backed classes can keep the legacy KV API, but you should inspect the backend of existing classes before selecting storage APIs.

How do I test Durable Objects with Vitest?

Use Cloudflare's Vitest integration to run Durable Objects in the Workers runtime, testing RPC methods, instance isolation, SQLite persistence, and alarms. The testing reference links to setup, migration guides, and helper APIs for triggering alarms without waiting for wall-clock time.

When should I not use Durable Objects?

Avoid Durable Objects for stateless request handling, maximum global distribution, or high fan-out independent requests; plain Workers fit those cases better. Also never use a single global Durable Object for all requests, since it becomes a bottleneck.

Why does blockConcurrencyWhile hurt Durable Object performance?

blockConcurrencyWhile blocks all other requests until it completes, so using it on every request kills throughput. It should only wrap schema initialization in the constructor and must never span fetch() calls or external I/O.