Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/dafthunk-com/dafthunk/07-database-developmentgit clone --depth 1 https://github.com/dafthunk-com/dafthunkWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.00536 |
| Opus 5 | $0.00000 | $0.00268 |
| Sonnet 5 | $0.00000 | $0.00107 |
| Haiku 4.5 | $0.00000 | $0.00054 |
Grade A, and why
07-database-development scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 72 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Database Design Best Practices
Use SQL-Compatible Types
- Cloudflare D1 uses SQLite under the hood.
- Use Drizzle's SQLite helpers (
integer(),text(),sqliteTable(), etc.). - Be mindful of SQLite's flexible typing and ensure type safety using Drizzle.
export const users = sqliteTable("users", {
id: integer("id").primaryKey({ autoIncrement: true }),
email: text("email").notNull().unique(),
createdAt: text("created_at").default(sql`CURRENT_TIMESTAMP`),
});
Model Relationships Carefully
- D1 (SQLite) does support foreign keys, but indexing is crucial for performance.
- Use
.references()in Drizzle to define relationships explicitly.
export const posts = sqliteTable("posts", {
id: integer("id").primaryKey({ autoIncrement: true }),
authorId: integer("author_id").references(() => users.id),
title: text("title").notNull(),
});
Use Enums Where Needed (with Caution)
- SQLite does not have native enum support.
- Instead, constrain values manually in your application or through custom Zod validation.
Use snake_case for SQL Fields
- Stick to
snake_casein table and column names. - Use
camelCasein TypeScript withInferModel.
export const tasks = sqliteTable("tasks", {
createdAt: text("created_at"),
});
Timestamps & Defaults
- Use SQL-level defaults like
CURRENT_TIMESTAMPto avoid time zone mismatches. - Avoid setting defaults in TypeScript for critical database fields.
Type Inference
- Always use Drizzle's
InferModelto export consistent types.
export type User = InferModel<typeof users>;
export type NewUser = InferModel<typeof users, "insert">;
Migrations
- Use
drizzle-kitto generate and run migrations. - Keep migrations version-controlled and consistent across environments.
- Don't mutate tables manually in production.
Avoid Nullable Unless Necessary
- Prefer strict types to nullable columns.
- Design schema around clear assumptions; nulls can be a source of bugs.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- yesterday First seen · 72 lines · 0 tokens per session scan A 512f03c3cc9c
07-database-development is a cursor rule published in the GitHub repository dafthunk-com/dafthunk (119 stars, last pushed 5d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 536 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other cursor rules, from other repositories
on-load-rule
This guide outlines the critical development principles for this Swift project.
analyze-pr-changes
Comprehensive analysis of Pull Request changes.
project-rules
Cursor rule "project-rules" from Ahmet-Ruchan/ML-Engineer-RoadMap, covering 🏗️ 1. general structure, 🧩 2. technology stack, ⚙️ 3. core principles, 🗄️ 4. database rules and core tables.
angular-20
This rule provides comprehensive best practices and coding standards for Angular development, focusing on modern TypeScript, standalone components, signals, and performance optimizations.
dev-standard
Apache Superset development standards and guidelines for Cursor IDE.
typescript
Changes to these high-fan-out internals can affect every message, delta, element, or rerun. Keep work in them minimal, and benchmark changes with representative stress-test apps.