durable-objects

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

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

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 migrations, and outdated assumptions lead to bottlenecks, lost state, and broken deployments. ## Core Features & Use Cases - Implementation Guidance: Provides patterns for Durable Object classes, RPC methods, SQLite storage, alarms, and WebSocket handlers with current Cloudflare documentation retrieval. - Configuration & Testing: Covers wrangler.jsonc/toml bindings, SQLite class migrations, and Vitest-based testing of RPC, storage, and alarm behavior. - Code Review Rules: Enforces critical rules and anti-patterns, such as one DO per coordination entity, persist-before-cache, and avoiding blockConcurrencyWhile across external I/O. - Use Case: When building a real-time chat room with per-room state, use this Skill to scaffold the Durable Object class, configure migrations, and write tests verifying state isolation between rooms. ## Quick Start Use the durable-objects skill to create a Durable Object class with SQLite storage and wrangler configuration for a per-user session store.

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. Configure the binding in wrangler.jsonc and add a migration with new_sqlite_classes listing your class name.

How to configure Durable Objects bindings in wrangler.jsonc?▼

Add a durable_objects.bindings array mapping a binding name to your class_name, then declare a migrations entry with a tag and new_sqlite_classes. The Worker accesses the namespace via env.MY_DO and creates stubs with getByName or idFromString.

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

Use Durable Objects for coordination, strong consistency, per-entity storage, persistent WebSocket connections, or scheduled per-entity work like alarms. Avoid them for stateless request handling, maximum global distribution, or high fan-out independent requests.

How do I test Durable Objects with Vitest?▼

Use Cloudflare's Vitest integration to run tests in the Workers runtime, covering RPC behavior, HTTP routing, instance separation, SQLite persistence, and alarms. Use the documented test helpers to trigger scheduled alarms without waiting for wall-clock time.

Why does my Durable Object lose in-memory state?▼

Durable Objects can be evicted or restarted, so any state held only in memory is lost. Always persist critical data to storage before updating in-memory caches, and ensure in-memory state is reconstructible from durable storage.

Can a Durable Object have multiple alarms scheduled?▼

No, each Durable Object supports only one alarm at a time. Calling setAlarm replaces any existing alarm, so reschedule inside the alarm handler if recurring work is needed, or use deleteAlarm to cancel.