durable-objects

Coordinate stateful logic on Cloudflare Workers using Durable Objects.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Cloudflare Durable Objects let you build stateful, coordinated logic at the edge. This Skill guides you through creating, reviewing, and applying best practices for DOs, including integration with Workers, SQLite storage, alarms, and WebSockets.

Core Features & Use Cases

  • Create and review Durable Objects for chat rooms, games, or per-entity state with deterministic routing.
  • Implement RPC-like methods, alarms, and WebSocket handlers; configure wrangler bindings and migrations.
  • Inspect and refine code against best practices, tests, and observability.
  • Use SQLite bindings and storage patterns to persist data across instances.

Quick Start

Define a Durable Object class, configure Wrangler bindings, and iterate on tests in a local development environment.

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 chat rooms with Cloudflare Workers and Durable Objects?

Use Durable Objects on Cloudflare Workers to coordinate deterministic routing and per-entity workflows. They are necessary when your edge logic requires coordinated state, such as for multiplayer game sessions, chat rooms, or alarm-based scheduling.

How do I configure Wrangler bindings and migrations for Cloudflare Durable Objects?

You configure Wrangler bindings and migrations by declaring the Durable Object class in your wrangler configuration file. Attach the binding to your Worker and execute migrations to properly provision the SQLite storage schema.

How do I test Cloudflare Durable Objects and WebSocket logic using Vitest?

Test Cloudflare Durable Objects using Vitest by defining your DO class and iterating on tests in a local development environment. This validates RPC-style methods, WebSocket handlers, and SQLite storage patterns before deployment.

Can I use SQLite storage with Cloudflare Durable Objects for per-entity state workflows?

Yes, you can use SQLite storage with Cloudflare Durable Objects to persist data for per-entity workflows. Apply SQLite bindings and storage patterns to maintain state deterministically across coordinated edge instances.

Does this approach support RPC-style methods and alarms for multiplayer sessions?

Yes, this approach supports RPC-style methods and alarms for multiplayer sessions. You implement these handlers within the Durable Object class to manage coordinated state and timed events on Cloudflare Workers.