better-auth-add-plugin
Add a better-auth plugin to an existing project. Configures server and client plugins with proper imports.
Interactive Durable Objects pattern selection wizard. Helps choose the right DO pattern for your use case and generates implementation code with best practices.
$ npx -y skills add secondsky/claude-skills --agent claude-codeHow it fires
How this command gets triggered: by you, by Claude, or both.
/do-patternsContext preview
What this command does when you run it.
Interactive Durable Objects pattern selection wizard. Helps choose the right DO pattern for your use case and generates implementation code with best practices.
name: cloudflare-durable-objects:patterns description: Interactive Durable Objects pattern selection wizard. Helps choose the right DO pattern for your use case and generates implementation code with best practices.
Interactive wizard to help select and implement the optimal Durable Objects pattern for your specific use case.
This command guides you through: 1. Understanding your requirements 2. Recommending appropriate DO patterns 3. Generating pattern-specific implementation 4. Providing testing and deployment guidance
Use AskUserQuestion tool:
**header**: "Use Case" **question**: "What is your primary use case for Durable Objects?" **multiSelect**: false **options**:
description: "Chat rooms, collaborative editing, multiplayer games, live updates"
description: "Leader election, distributed locking, workflow orchestration"
description: "User sessions, shopping carts, user profiles, device state"
description: "API rate limiting, DDoS prevention, quota management"
description: "Analytics, counters, leaderboards, metrics collection"
description: "Distributed cache, cache-aside pattern, write-through cache"
**header**: "Scale" **question**: "What scale do you expect?" **multiSelect**: false **options**:
description: "Prototype, small app, specific use case"
description: "Growing app, moderate traffic"
description: "High traffic app, many users"
description: "Enterprise scale, global application"
**header**: "Persistence" **question**: "What are your data persistence requirements?" **multiSelect**: false **options**:
description: "Data can be lost, rebuilt from external sources"
description: "Data expires after period of inactivity"
description: "Data must persist indefinitely"
description: "Some data temporary, some permanent"
**header**: "Queries" **question**: "What type of data queries do you need?" **multiSelect**: false **options**:
description: "Get/set by key, no complex queries"
description: "Filter by single field, simple WHERE clauses"
description: "Multi-table queries, aggregations, GROUP BY"
description: "Search across text fields"
Based on answers, recommend appropriate pattern:
**When**: Real-time communication + Medium-Large scale **Storage**: Hybrid (connection state ephemeral, messages permanent) **Queries**: Basic filtering
**Key Features**:
**Template**: Load `templates/websocket-hibernation-do.ts`
**Implementation**:
import { DurableObject } from 'cloudflare:workers';
export class ChatRoom extends DurableObject {
private sessions: Map<WebSocket, { userId: string }> = new Map();
constructor(ctx: DurableObjectState, env: Env) {
super(ctx, env);
// Initialize SQL schema
this.ctx.blockConcurrencyWhile(async () => {
await this.ctx.storage.sql.exec(`
CREATE TABLE IF NOT EXISTS messages (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id TEXT NOT NULL,
content TEXT NOT NULL,
created_at INTEGER NOT NULL
)
`);
await this.ctx.storage.sql.exec(`
CREATE INDEX IF NOT EXISTS idx_created
ON messages(created_at DESC)
`);
});
}
async fetch(request: Request): Promise<Response> {
// Handle WebSocket upgrade
if (request.headers.get('Upgrade') === 'websocket') {
const pair = new WebSocketPair();
this.ctx.acceptWebSocket(pair[1]);
return new Response(null, { status: 101, webSocket: pair[0] });
}
// Handle HTTP requests (message history, etc.)
const url = new URL(request.url);
if (url.pathname === '/messages') {
const messages = await this.ctx.storage.sql.exec(
'SELECT * FROM messages ORDER BY created_at DESC LIMIT 50'
);
return Response.json(messages.rows);
}
return new Response('Not found', { status: 404 });
}
async webSocketMessage(ws: WebSocket, message: string) {
const data = JSON.parse(message);
const session = this.sessions.get(ws);
if (!session) return;
// Store message
await this.ctx.storage.sql.exec(
'INSERT INTO messages (user_id, content, created_at) VALUES (?, ?, ?)',
session.userId,
data.content,
Date.now()
);
// Broadcast to all connections
const broadcast = JSON.stringify({
userId: session.userId,
content: data.content,
timestamp: Date.now()
});
for (const [client] of this.sessions) {
client.send(broadcast);
}
}
async webSocketOpen(ws: WebSocket) {
const userId = crypto.randomUUID(); // Or from auth
this.sessions.set(ws, { userId });
}
async webSocketClose(ws: WebSocket) {
this.sessions.delete(ws);
}
}**wrangler.jsonc**:
{
"durable_objects": {
"bindings": [
{
"name": "CHAT_ROOM",
"class_name": "ChatRoom"
}
]
},
"migrations": [
{
"ta145 production-ready skills for Claude Code CLI 🔌 Platform / Harness Support These plugins ship as Claude Code marketplace plugins (.claude-plugin/ manifests) and Codex CLI plugins (.codex-plugin/ manifests).
Repo: secondsky/claude-skills
Add a better-auth plugin to an existing project. Configures server and client plugins with proper imports.
Interactive setup wizard for better-auth authentication. Guides through database, framework, OAuth providers, and plugin configuration.
Explain Better Auth error codes and provide solutions with code examples
Display Better Auth available authentication providers and their configuration