Store
AI Rules FileArchive

Drizzle ORM + Hono Cloudflare Workers Bundle

For Developers building Cloudflare Workers APIs with Hono and Drizzle

A complete CLAUDE.md rules file for building Cloudflare Workers APIs with Hono and Drizzle ORM — covers D1, KV, R2, RPC mode, and the 10 mistakes every model makes.

Created

Description

Hono + Drizzle + D1 is one of the most hallucination-prone TypeScript stacks — models use the wrong Drizzle adapter, generate process.env code that fails in Workers, break RPC client chains, and skip relations() which silently kills relational queries. This bundle corrects all of it. 1,198 lines covering schema patterns, D1 batch queries, transactions, Hono middleware, JWT auth, Zod validation, KV caching, R2 uploads, the full RPC type chain, migration workflow, testing with vitest-pool-workers, and a 16-item pre-ship checklist.

What's included

  • CLAUDE.md rules file (1,198 lines)
  • README.md — installation for Claude Code, Cursor, Windsurf, Copilot
  • CUSTOMIZATION.md — how to trim and extend the rules for your project

Sample content

  • D1 adapter requires the binding, not a connection string

    `drizzle(c.env.DB)` — not a connection string. The D1 binding is passed directly. Using a connection string fails at runtime with no helpful error.

  • Drizzle transactions on D1 use batch, not .transaction()

    D1 doesn't support multi-statement transactions via `.transaction()`. Use `db.batch([...])` for atomic multi-statement operations. The API looks like transactions but it's D1 batch.

  • Hono RPC + Drizzle type chain

    For end-to-end type safety: export the app type from the Worker, import it in the client, use `hc<AppType>()`. Any break in the chain — split routes, re-export — silently loses types.

3 of 1 included items previewed above.

Delivery

Instant download after Stripe checkout. File: nightforge-drizzle-hono-bundle.zip