Build stateful Durable Objects for real-time apps, WebSocket servers, coordination, and persistent state. Use when: implementing chat rooms, multiplayer games, rate limiting, session management, WebSocket hibernation, or troubleshooting class export, migration, WebSocket state loss, or binding errors.
Auto-Discovery Skill for Claude Code CLI
Complete knowledge domain for Cloudflare Durable Objects - globally unique, stateful objects for coordination, real-time communication, and persistent state management.
Claude will automatically suggest this skill when you mention any of these keywords:
| Issue | Error Message | How Skill Prevents | |-------|---------------|-------------------| | Class not exported | "binding not found" | Always exports DO class with proper syntax | | Missing migration | "migrations required" | Templates include migration configuration | | Wrong migration type | Schema errors | Uses new_sqlite_classes for SQLite backend | | Constructor overhead | Slow hibernation wake | Shows blockConcurrencyWhile pattern | | setTimeout breaks hibernation | Never hibernates | Uses alarms instead of setTimeout/setInterval | | In-memory state lost | Data loss on hibernation | Persists to storage, restores in constructor | | Outgoing WebSocket | Not supported | Only server-side WebSockets hibernate | | Global uniqueness | Unexpected behavior | Explains class name global scope | | Partial deleteAll (KV) | Incomplete cleanup | Recommends SQLite backend for atomic ops | | Binding name mismatch | Runtime error | Ensures binding consistency | | State size exceeded | Storage limit | Documents 1GB SQLite, 128MB KV limits | | Migration not atomic | Deploy failures | Explains atomic migration requirement | | Location hint ignored | Wrong region | Clarifies hints are best-effort | | Alarm retry failures | Lost tasks | Shows idempotent alarm patterns | | Fetch during hibernation | Blocks hibernation | Ensures all I/O completes before idle |
Savings: ~66% token reduction (7,700 tokens saved)
# Scaffold new DO project
npm create cloudflare@latest my-app -- \
--template=cloudflare/durable-objects-template \
--ts --git --deploy false
// Define Durable Object class
import { DurableObject } from 'cloudflare:workers';
export class Counter extends DurableObject {
async increment(): Promise<number> {
let value: number = (await this.ctx.storage.get('value')) || 0;
value += 1;
await this.ctx.storage.put('value', value);
return value;
}
}
export default Counter;
// wrangler.jsonc
{
"durable_objects": {
"bindings": [
{
"name": "COUNTER",
"class_name": "Counter"
}
]
},
"migrations": [
{
"tag": "v1",
"new_sqlite_classes": ["Counter"]
}
]
}
~/.claude/skills/cloudflare-durable-objects/
├── SKILL.md # Complete DO documentation (1000+ lines)
├── README.md # This file (auto-trigger keywords)
├── templates/
│ ├── wrangler-do-config.jsonc # Complete wrangler configuration
│ ├── basic-do.ts # Simple counter example
│ ├── websocket-hibernation-do.ts # WebSocket chat room
│ ├── state-api-patterns.ts # SQL + KV storage examples
│ ├── alarms-api-do.ts # Scheduled tasks with alarms
│ ├── rpc-vs-fetch.ts # RPC vs fetch patterns
│ ├── location-hints.ts # Geographic routing
│ ├── multi-do-coordination.ts # Multiple DOs working together
│ └── package.json # TypeScript dependencies
├── references/
│ ├── wrangler-commands.md # Complete CLI reference
│ ├── state-api-reference.md # SQL + KV storage API
│ ├── websocket-hibernation.md # WebSocket API deep dive
│ ├── alarms-api.md # Alarms scheduling guide
│ ├── migrations-guide.md # Migration patterns
│ ├── rpc-patterns.md # RPC vs fetch decision guide
│ ├── best-practices.md # Production patterns
│ └── top-errors.md # 15+ documented issues
└── scripts/
└── check-versions.sh # Verify package versions
cloudflare-worker-base - Base Worker + Hono setupcloudflare-d1 - D1 serverless SQL databasecloudflare-kv - Key-value storagecloudflare-queues - Message queuescloudflare-agents - AI-powered agents (uses Durable Objects)Status: Production Ready ✅ Last Updated: 2025-10-22 Maintainer: Jeremy Dawes (Jezweb)
npx skills add ovachiever/克劳德弗莱尔-持久化对象下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer