Hono + Bun + Drizzle ORM + SQLite Cursor Rules Template for Cursor AI
Copyable Cursor Rules Template for Hono, Bun, Drizzle ORM, and SQLite to guide Cursor AI in safe, rapid code generation for a REST API stack.
Target User
Developers building APIs with Hono on Bun using Drizzle ORM and SQLite
Use Cases
- API backends with Hono on Bun
- SQLite-backed data stores with Drizzle ORM
- Cursor AI-guided code generation for server routes and data access
Markdown Template
Hono + Bun + Drizzle ORM + SQLite Cursor Rules Template for Cursor AI
cursorrules
version: 1
stack:
- hono
- bun
- drizzle-orm
- sqlite
frameworkRole: API middleware and routing with Hono on Bun; Drizzle ORM for SQLite
context: Cursor AI acts as a code assistant for building a REST API using Hono, Bun, Drizzle ORM, and SQLite
codeStyle: TypeScript with ESM; lint via ESLint; format via Prettier; strict typing
architecture:
directories:
- src/routes
- src/middleware
- drizzle
- db
- tests
patterns:
- repository -> service -> controller layering
- explicit imports and named exports
authentication:
type: jwt
header: Authorization
tokenStrategy: RS256
refresh: false
database:
orm: drizzle-orm
driver: sqlite
databaseFile: ./db/database.sqlite
migrationsDir: drizzle/migrations
patterns:
unitTests: Vitest
integrationTests: supertest-like http helper
linting: eslint + prettier precommit
security:
secrets: env vars only; do not hard-code
httpOnlyCookies: false
prohibited:
- avoid-mongoose-prisma
- do not use eval or dynamic import hacking
- do not bypass ORM; avoid raw string concatenation for SQL
notes: Cursor AI should avoid unsafe code patterns and clearly document any deviations from the templateOverview
This Cursor Rules Template documents a complete Cursor AI configuration for a Hono + Bun + Drizzle ORM + SQLite stack. It explains how Cursor AI should reason about routing, ORM usage, security, testing, and deployment patterns. The goal is predictable, auditable code generation with Cursor AI in the Cursor rules template style.
When to Use These Cursor Rules
- Starting a new API project with Hono as the router, Bun as the runtime, and SQLite via Drizzle ORM.
- Automatically generating consistent route handlers and ORM access patterns with Cursor AI.
- Enforcing security, testing, and linting constraints from the outset to prevent architectural drift.
- Onboarding new developers by providing a single source of truth for stack-specific conventions.
Copyable .cursorrules Configuration
cursorrules
version: 1
stack:
- hono
- bun
- drizzle-orm
- sqlite
frameworkRole: API middleware and routing with Hono on Bun; Drizzle ORM for SQLite
context: Cursor AI acts as a code assistant for building a REST API using Hono, Bun, Drizzle ORM, and SQLite
codeStyle: TypeScript with ESM; lint via ESLint; format via Prettier; strict typing
architecture:
directories:
- src/routes
- src/middleware
- drizzle
- db
- tests
patterns:
- repository -> service -> controller layering
- explicit imports and named exports
authentication:
type: jwt
header: Authorization
tokenStrategy: RS256
refresh: false
database:
orm: drizzle-orm
driver: sqlite
databaseFile: ./db/database.sqlite
migrationsDir: drizzle/migrations
patterns:
unitTests: Vitest
integrationTests: supertest-like http helper
linting: eslint + prettier precommit
security:
secrets: env vars only; do not hard-code
httpOnlyCookies: false
prohibited:
- avoid-mongoose-prisma
- do not use eval or dynamic import hacking
- do not bypass ORM; avoid raw string concatenation for SQL
notes: Cursor AI should avoid unsafe code patterns and clearly document any deviations from the template
Recommended Project Structure
project-root/
├── src/
│ ├── main.ts
│ ├── routes/
│ │ └── api.ts
│ ├── middleware/
│ │ └── auth.ts
│ │── lib/
│ │ └── db.ts
│ └── utils/
├── drizzle/
│ ├── schema.ts
│ └── migrations/
│ └── 001-init.ts
├── db/
│ └── sqlite/
│ └── database.sqlite
├── tests/
│ ├── unit/
│ └── integration/
Core Engineering Principles
- Explicit, auditable rules for Cursor AI code generation
- Security by default and least privilege
- Clear separation of concerns between routing, data access, and business logic
- Deterministic, testable code generated by Cursor AI
- Stable, documented project structure and conventions
Code Construction Rules
- Use TypeScript with strict types for request/response payloads
- Follow a repository -> service -> controller pattern for API routes
- Always parameterize SQL via Drizzle ORM; never interpolate user input into raw SQL strings
- Write unit tests for reducers and endpoints; include integration tests for API routes
- Maintain a single drizzle schema.ts and migrations folder with named migrations
- Document any AI-suggested code with comments and a brief rationale
- Do not use unused dependencies; keep the project lean
Security and Production Rules
- Store secrets in environment variables; never commit tokens
- Use JWT with short-lived tokens and proper validation on each request
- Limit endpoint exposure; implement RBAC for sensitive routes
- Enable proper logging and metrics without leaking secrets
- Protect against SQL injection by using Drizzle ORM and parameterized queries
Testing Checklist
- Unit tests for utilities and data transformations
- Integration tests for API endpoints using the Hono routes and Drizzle ORM mocks
- Migration tests to verify schema compatibility and rollback capability
- Linting and type-check in CI; fail on TS compile errors
- Smoke tests in CI to ensure basic API health
Common Mistakes to Avoid
- Using raw SQL with string concatenation; bypassing the ORM
- Hard-coding secrets or embedding credentials in code
- Overcomplicating routing with non-cohesive middleware
- Ignoring tests or skipping migrations in local development
FAQ
What is this Cursor Rules Template for Hono Bun Drizzle SQLite?
This Cursor Rules Template provides concrete, stack-specific guidelines for Cursor AI to generate, validate, and maintain code in a Hono + Bun + Drizzle ORM + SQLite environment. It defines architecture, security, testing, and data access patterns so AI-assisted development remains consistent and auditable.
Which stack does this template cover?
The template targets Hono as the router, Bun as the runtime, Drizzle ORM for SQLite data access, and an SQLite database file. It guides Cursor AI to operate within this stack’s conventions, including its folder structure and testing workflow.
How do I integrate the .cursorrules block into my project?
Copy the entire code block from the Copyable .cursorrules Configuration section and paste it into your repository root as a .cursorrules file. The AI rules will influence subsequent code generation, ensuring stack-consistent results.
What are the security considerations?
The rules emphasize environment-based secrets, JWT-based authentication, and parameterized database access via Drizzle ORM. Do not log secrets or expose sensitive tokens in code or logs; restrict endpoint access based on roles.
How do I run tests with this setup?
Use Vitest for unit tests and a short integration test suite to exercise API routes. Configure CI to run linting, type checks, and migrations as part of the pipeline.