Claude 3.5 Sonnet Cloudflare Workers, D1 & Durable Objects Architect
Claude 3.5 Sonnet prompt for architecting low-latency Cloudflare Workers with SQLite Durable Objects, WebSocket hibernation, D1 SQL, and wrangler.toml bindings.
Parametric Customizer & Compiler Live Tool
Adjust the variables below. The prompt code and API payload update dynamically in real time.
Real-time stateful workload running at the edge
You are a Principal Edge Systems Engineer specializing in the Cloudflare Developer Platform (Workers, Durable Objects with SQLite backend, D1, R2, and Queues).
Architect and implement a production edge application under the following parameters:
- Edge Workload Type: {Multiplayer Collaborative Document Canvas (CRDT / Yjs synchronization + Presence Cursors)}
- Stateful Coordination Engine: {Durable Objects with Zero-Latency Embedded SQLite Storage (ctx.storage.sql)}
- Real-Time Transport Protocol: {WebSockets with Hibernation API (Zero Idle Compute Cost)}
- Framework & Type Safety: {Hono v4 + @hono/zod-validator + TypeScript 5.6}
### ARCHITECTURAL INVARIANTS:
1. **Single-Threaded Actor Serialization (Durable Objects)**:
- Extend `DurableObject` from `cloudflare:workers` using modern RPC methods instead of legacy HTTP fetch wrappers.
- Utilize embedded synchronous SQLite storage (`this.ctx.storage.sql.exec(...)`) for zero-latency ACID transactions inside the Durable Object.
2. **WebSocket Hibernation API**:
- Use `this.ctx.acceptWebSocket(server)` and implement `webSocketMessage()`, `webSocketClose()`, and `webSocketError()` so idle connections consume 0ms of billable wall-clock duration.
3. **Strict Env Bindings & Wrangler Configuration**:
- Provide complete `wrangler.toml` including `[[durable_objects.bindings]]` and `[[migrations]]` with `new_sqlite_classes`. Global serverless compute with 0ms cold starts across 330+ edge cities.
Leonardo Phoenix & Flux: Generate photorealistic studio assets with 150 daily free credits. Zero setup required.
πΈ Real Sample Outputs & Verified Results
Visual evidence and benchmark responses generated using this exact prompt formula.
π¬ Prompt Engineering Anatomy
Why this prompt consistently delivers high-tier results: technical parameter breakdown.
WebSocket Hibernation API Allows a Durable Object to evict from memory while keeping thousands of TCP WebSocket connections open at Cloudflare's edge, waking up in <5ms when a frame arrives.
Embedded SQLite in Durable Objects Because the SQLite engine runs inside the exact same single-threaded isolate as the Durable Object, queries execute in microseconds with zero network roundtrip.
π¬ Frequently Asked Questions
Troubleshooting common edge cases, model incompatibilities, and best practices.
How many requests per second can a single Durable Object handle?
A single Durable Object comfortably processes 1,000-2,500 requests/sec. Shard by room ID, workspace ID, or document ID for infinite horizontal scaling.
Does this avoid deprecated Cloudflare Worker syntax?
Yes, this prompt strictly enforces ES Modules syntax, native DurableObject RPC, and SQLite storage APIs introduced in 2025/2026.
Cursor AI & Claude 3.5 Sonnet Pro Bundle
Supercharge your workflow with instant codebase indexing, multi-file edits, and automated system rules.
Explore Related Coding & Architecture Prompts View all β
Claude 3.5 Sonnet Senior Staff Full-Stack Refactoring Architect
Specialized prompt framework for Claude 3.5 Sonnet and Claude 3.7. Transforms messy legacy codebases into modular, testable, high-performance systems with automated regression tests.
cursorCursor AI (.cursorrules) for Next.js 15, React 19 & Tailwind CSS
Stops Cursor from writing outdated Next.js 13 patterns, Pages Router syntax, or deprecated React hooks. Enforces strict TypeScript, Server Actions, and modular clean architecture.
deepseekDeepSeek-R1 Autonomous Deep Research & Synthesis Engine
DeepSeek-R1 chain-of-thought framework designed to force deep reflection, counterfactual auditing, and hypothesis testing before producing production-ready research reports.