durable-objects

Design Cloudflare Durable Object classes with RPC methods, alarms, and WebSocket handlers.

1|Updated Apr 6, 2025
One-click install
npx skills add https://github.com/david-driscoll/stargate-command-cluster --skill durable-objects-david-driscoll
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: durable-objects
Source: https://github.com/david-driscoll/stargate-command-cluster/tree/main/.agents/skills/durable-objects
Command: npx skills add https://github.com/david-driscoll/stargate-command-cluster --skill durable-objects-david-driscoll

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Durable Objects help you implement stateful, coordinated application logic on Cloudflare’s edge without relying on centralized databases or ad-hoc in-memory state that breaks under scaling and eviction.

Core Features & Use Cases

  • Stateful coordination: design one Durable Object per logical coordination atom (room, game session, user, tenant) to avoid bottlenecks.
  • Strong consistency storage: use Durable Objects SQLite storage and follow best practices for migrations, atomic writes, and concurrency.
  • Operational correctness: implement alarms, RPC-style methods (instead of fetch handlers), deterministic stub routing, and WebSocket handling patterns.
  • Wrangler integration & testing: configure durable object bindings and SQLite migrations in wrangler, and test using @cloudflare/vitest-pool-workers.

Quick Start

Tell the AI to review your Durable Object design by checking routing (getByName), storage/migrations, RPC method structure, and how you will test alarms and WebSocket or RPC interactions.

Frequently Asked Questions about durable-objects

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

FAQPage Schema
How do I build stateful coordination on Cloudflare Workers without a centralized database?

Durable Objects provide per-entity durable SQLite storage and concurrency controls on the Cloudflare edge, enabling stateful application logic without centralized databases or ad-hoc in-memory state. You design one Durable Object per logical atom like a room or user session.

How do I configure wrangler durable object bindings and SQLite migrations?

You configure wrangler durable object bindings and SQLite migrations in your wrangler configuration file to ensure strong consistency storage. This setup allows atomic writes and proper schema management for your edge application's stateful data.

Can I use Vitest to test Cloudflare Durable Objects alarms and RPC methods?

Yes, you can test Cloudflare Durable Objects using @cloudflare/vitest-pool-workers. This approach validates patterns for deterministic stub routing, RPC methods, alarms, and WebSocket handlers to ensure operational correctness.

What is the best way to route requests to a specific Durable Object instance?

The best way to route requests is by using deterministic stub routing via getByName to target a specific Durable Object. This ensures stateful coordination is handled by the correct per-entity instance without bottlenecks.

Why should I implement RPC methods instead of fetch handlers in Durable Objects?

Implementing RPC methods instead of fetch handlers in Durable Objects provides structured operational correctness for stateful coordination. This pattern integrates cleanly with alarms and WebSocket handling while maintaining strong consistency storage rules.

When should I not use Durable Objects for stateful edge applications?

You should avoid Durable Objects if your stateful edge application requires cross-entity queries or complex relational joins, as Durable Objects provide per-entity SQLite storage designed for isolated coordination atoms rather than global querying.