Cursor Rules .mdc
Production-Ready Rule • worker/**/*.{ts,js}, src/**/*.{ts,js}

Cloudflare Workers & Hono Edge Serverless .cursorrules (.mdc)

High-performance .cursorrules and .cursor/rules/*.mdc configuration for Cloudflare Workers and Hono. Optimize edge startup times, D1 database queries, and KV caching.

.cursor/rules/cloudflare-workers.mdc
⚡ Open in Generator
---
description: Cloudflare Workers, Hono, D1, and Edge runtime engineering standards
globs: worker/**/*.{ts,js}, src/**/*.{ts,js}
alwaysApply: false
---

# Cloudflare Workers & Hono Standards

## Edge Runtime Constraints
- Never rely on persistent in-memory global state between requests.
- Use `c.env.DB` (D1) or `c.env.KV` for persistent storage and session management.
- Keep dependencies minimal to ensure sub-10ms worker cold startup times.

## Hono Framework Discipline
- Type your Hono instance with the environment bindings: `const app = new Hono<{ Bindings: Env }>()`.
- Always return typed JSON using `c.json({ ... }, 200)` and handle errors with `app.onError()`.
- Ensure all asynchronous background tasks use `ctx.waitUntil(...)` so execution completes reliably.
⭐ Using this rule in your open-source project? Reference in your README: https://cursor.pacebowl.com/rules/cloudflare-workers.html

Frequently Asked Questions & Implementation Notes

Why is global state forbidden in Workers?

Cloudflare Workers isolate instances and restart frequently. Relying on global in-memory variables leads to subtle state drift. The rules enforce using Cloudflare KV or D1 for persistence.

How does it handle Hono routing?

The rules provide lightweight TypeScript patterns for Hono middleware, type-safe environment bindings (`Env`), and sub-millisecond response generation.

PaceBowl Suite Matrix

Mothership Hub →
CF
ComfyUI Prompt Studio

Flux.1 & 1MP Empty Latent calculator.

🔥
AI Radar & Hotlist

24/7 automated tech intel & papers.

GEO
OpenGEO Attribution

Track Perplexity & ChatGPT conversions.