CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/drizzle-best-practices

Drizzle ORM patterns -- schema definition, indexes, relations, migrations, transactions, upserts, prepared statements, and connection setup

96

1.60x
Quality

96%

Does it follow best practices?

Impact

98%

1.60x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

criteria.jsonevals/scenario-1/

{
  "context": "Tests whether the agent defines relations() for the query API, uses correct drizzle-kit config with dialect (not driver), uses current migration commands (not old :dialect suffix), uses operator helpers for all conditions, uses desc()/asc() for ordering, passes schema to drizzle(), and applies proper schema practices. The task describes business features without naming any patterns.",
  "type": "weighted_checklist",
  "checklist": [
    {
      "name": "Relations defined for all FK tables",
      "description": "relations() objects are defined for posts (many comments, one author), comments (one post, one author), and authors (many posts, many comments) using one() and many() from drizzle-orm",
      "max_score": 12
    },
    {
      "name": "Query API used for nested data",
      "description": "At least the post detail function uses db.query.posts.findFirst() with { with: { comments: true, author: true } } or equivalent nested eager loading via the query API",
      "max_score": 10
    },
    {
      "name": "Operator helpers for all conditions",
      "description": "All WHERE conditions use imported operator helpers from 'drizzle-orm' (eq, and, inArray, etc.) -- no raw SQL strings for conditions",
      "max_score": 10
    },
    {
      "name": "desc/asc helpers for ordering",
      "description": "ORDER BY clauses use desc() or asc() helpers from 'drizzle-orm', not bare column references",
      "max_score": 8
    },
    {
      "name": "Indexes on FK columns",
      "description": "Foreign key columns (authorId on posts, postId and authorId on comments) have explicit indexes in the table's third-argument callback",
      "max_score": 10
    },
    {
      "name": "Indexes on filtered columns",
      "description": "Post status and publishedAt columns have indexes since they are used for filtering and sorting",
      "max_score": 6
    },
    {
      "name": "drizzle.config.ts uses dialect",
      "description": "drizzle.config.ts uses the 'dialect' field (e.g., 'sqlite'), NOT the removed 'driver' field",
      "max_score": 8
    },
    {
      "name": "defineConfig import",
      "description": "drizzle.config.ts imports and uses defineConfig() from 'drizzle-kit' for type-safe config",
      "max_score": 5
    },
    {
      "name": "Generate command is current",
      "description": "Migration guide uses 'npx drizzle-kit generate' (not the old 'generate:sqlite' or 'generate:pg' dialect-suffixed syntax)",
      "max_score": 7
    },
    {
      "name": "Migrate command is current",
      "description": "Migration guide uses 'npx drizzle-kit migrate' to apply migrations",
      "max_score": 5
    },
    {
      "name": "Schema passed to drizzle",
      "description": "The drizzle() call in db.ts passes { schema } to enable the query API (db.query.*)",
      "max_score": 7
    },
    {
      "name": "Enum for post status",
      "description": "Post status uses text('status', { enum: ['draft', 'published', 'archived'] }) pattern",
      "max_score": 5
    },
    {
      "name": "Migrations committed note",
      "description": "Migration guide mentions that migration files should be committed to version control (git)",
      "max_score": 7
    }
  ]
}

evals

scenario-1

criteria.json

task.md

tile.json