Automatically validates Cloudflare Durable Objects usage patterns, ensuring correct state management, hibernation, and strong consistency practices
View on GitHubhirefrank/hirefrank-marketplace
edge-stack
plugins/edge-stack/skills/durable-objects-pattern-checker/SKILL.md
January 16, 2026
Select agents to install to:
npx add-skill https://github.com/hirefrank/hirefrank-marketplace/blob/main/plugins/edge-stack/skills/durable-objects-pattern-checker/SKILL.md -a claude-code --skill durable-objects-pattern-checkerInstallation paths:
.claude/skills/durable-objects-pattern-checker/# Durable Objects Pattern Checker SKILL
## Activation Patterns
This SKILL automatically activates when:
- Durable Object imports or exports are detected
- DO stub creation and usage patterns
- State management in Durable Objects
- ID generation patterns (`idFromName`, `newUniqueId`)
- Hibernation and lifecycle patterns
- WebSocket or real-time features with DOs
## Expertise Provided
### Durable Objects Best Practices
- **State Management**: Ensures proper state persistence and consistency
- **ID Generation**: Validates correct ID patterns for different use cases
- **Hibernation**: Checks for proper hibernation implementation
- **Lifecycle Management**: Validates constructor, fetch, and alarm handling
- **Strong Consistency**: Ensures DOs are used when strong consistency is needed
- **Performance**: Identifies DO performance anti-patterns
### Specific Checks Performed
#### ❌ Durable Objects Anti-Patterns
```typescript
// These patterns trigger immediate alerts:
// Using DOs for stateless operations
export default {
async fetch(request: Request, env: Env) {
const id = env.COUNTER.newUniqueId(); // New DO every request!
const stub = env.COUNTER.get(id);
return stub.fetch(request); // Overkill for simple counter
}
}
// Missing hibernation for long-lived DOs
export class ChatRoom {
constructor(state, env) {
this.state = state;
// Missing this.state.storage.setAlarm() for hibernation
}
}
```
#### ✅ Durable Objects Best Practices
```typescript
// These patterns are validated as correct:
// Reuse DO instances for stateful coordination
export default {
async fetch(request: Request, env: Env) {
const ip = request.headers.get('CF-Connecting-IP');
const id = env.RATE_LIMITER.idFromName(ip); // Reuse same DO
const stub = env.RATE_LIMITER.get(id);
return stub.fetch(request);
}
}
// Proper hibernation implementation
export class ChatRoom {
constructor(state, env) {
this.state = state;
this.env = env;
//