OneSelf / drizzle-best-practices
AGENTS.md21 starsChanged 10 days agoMITView on GitHub
Comprehensive best practices guide for Drizzle ORM with PostgreSQL. Contains guidance across 8 categories, prioritized by impact to help AI agents generate correct, performant, and idiomatic Drizzle code. Reference these guidelines when: Read individual reference files for detailed explanations and code examples: Each reference file contains:
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,542 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository16 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .agents/skills/vercel-composition-patterns/AGENTS.mdAGENTS.md
- .agents/skills/drizzle-best-practices/CLAUDE.mdCLAUDE.md
- drizzle-best-practicesSkill
- frontend-designSkill
- honoSkill
- openspec-apply-changeSkill
- openspec-archive-changeSkill
- openspec-exploreSkill
- openspec-proposeSkill
- openspec-sync-specsSkill
- pnpmSkill
- vercel-composition-patternsSkill
- viteSkill
- vitestSkill
- oneselfSkill
The file
We split this AGENTS.md into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 25
Read SKILL.md for the main skill instructions
- Distinctive: line 61
Read individual reference files for detailed explanations and code examples:
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Drizzle ORM Best Practices (PostgreSQL)
Structure
drizzle-best-practices/
SKILL.md # Main skill file - read this first
AGENTS.md # This navigation guide
CLAUDE.md # Symlink to AGENTS.md
references/
engine-postgres.md # Postgres-specific types, features, and idioms
schema-*.md # Schema design patterns
query-*.md # Query patterns
relations-*.md # Relation definitions and relational queries
migrations-*.md # Drizzle Kit configuration and workflow
types-*.md # TypeScript type inference and custom types
perf-*.md # Performance optimization
driver-*.md # Driver setup and serverless configuration
advanced-*.md # Dynamic queries, raw SQL, power-user patterns
_sections.md # Full index of all reference filesUsage
- Read
SKILL.mdfor the main skill instructions - Browse
references/for detailed documentation on specific topics - Reference files are loaded on-demand — read only what you need
Comprehensive best practices guide for Drizzle ORM with PostgreSQL. Contains guidance across 8 categories, prioritized by impact to help AI agents generate correct, performant, and idiomatic Drizzle code.
When to Apply
Reference these guidelines when:
- Defining table schemas with
pgTable - Writing select, insert, update, or delete queries
- Setting up relations between tables
- Configuring
drizzle-kitfor migrations - Inferring TypeScript types from your schema
- Choosing between the SQL-like API and the relational query API
- Optimizing query performance
- Integrating Drizzle with serverless Postgres providers (Neon, Supabase, etc.)
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
| 1 | Schema Design | CRITICAL | schema- |
| 2 | Query Patterns | CRITICAL | query- |
| 3 | Relations | HIGH | relations- |
| 4 | Migrations | HIGH | migrations- |
| 5 | Type Safety | MEDIUM-HIGH | types- |
| 6 | Performance | MEDIUM | perf- |
| 7 | Database Drivers | MEDIUM | driver- |
| 8 | Advanced Patterns | LOW | advanced- |
How to Use
Read individual reference files for detailed explanations and code examples:
references/engine-postgres.md
references/schema-table-definitions.md
references/schema-column-types.md
references/schema-indexes-constraints.md
references/query-select-patterns.md
references/query-mutations.md
references/query-filters-operators.md
references/query-error-handling.md
references/relations-defining.md
references/relations-querying.md
references/migrations-config.md
references/migrations-workflow.md
references/types-inference.md
references/types-custom-types.md
references/types-validators.md
references/perf-prepared-statements.md
references/perf-batch-operations.md
references/driver-postgres.md
references/driver-serverless.md
references/advanced-dynamic-queries.md
references/advanced-sql-operator.md
references/_sections.mdEach reference file contains:
- Brief explanation of why it matters
- Incorrect code example with explanation
- Correct code example with explanation
- Links to official Drizzle documentation
References
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

