Skip to content
Back to skills

Drizzle Orm Best Practices

ASecurity

Dialect-aware Drizzle ORM conventions for safe query, mutation, and transaction boundaries. Use when writing or reviewing Drizzle schemas, queries, transactions, or raw SQL.

  • 12 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 6, 2026
databasesrustgosqlexpressgitdatabasedocumentation

Security analysis

A100/100

Pro scans all 10 files and shows the line behind each finding

Scanned September 6, 2026

npx -y skills add Casper-Studios/casper-marketplace --skill drizzle-orm-best-practices --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Drizzle Orm Best Practices?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Drizzle Orm Best Practices
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/casper-studios-drizzle-orm-best-practices/badge)](https://www.skillsdirectory.com/skills/casper-studios-drizzle-orm-best-practices)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: drizzle-orm-best-practices
description: Dialect-aware Drizzle ORM conventions for safe query, mutation, and transaction boundaries. Use when writing or reviewing Drizzle schemas, queries, transactions, or raw SQL.
license: MPL-2.0
metadata:
  author: 'Basti Ortiz <ortiz@bastidood.dev>'
  source: 'https://github.com/BastiDood/skills'
---

# Drizzle ORM Best Practices

Treat Drizzle as a typed SQL builder over SQL dialect and driver contracts. Search its builders, operators, and helpers before writing `sql`. Keep data scope and invariants in SQL, read mutation metadata from the configured driver, let the database own persisted current time, and decode every unavoidable raw result at runtime.

## Library Sources

- GitHub repository ID: `drizzle-team/drizzle-orm`
- Context7 library ID: `/drizzle-team/drizzle-orm-docs`
- DeepWiki repository ID: `drizzle-team/drizzle-orm`

Use Context7 for current documentation and DeepWiki when documentation is insufficient or conflicts with implementation.

## Effective Strategies for Drizzle ORM

Read the linked guidance that governs the current task before writing or reviewing Drizzle code.

1. Keep SQL construction, data scope, and write contracts in the database boundary.
   - Before introducing any raw SQL, exhaust the [built-in query builders and helpers](./references/built-in-query-helpers.md) so Drizzle keeps ownership of SQL generation, parameterization, and result decoding.
   - When a read exposes more data than its caller needs or checks access after retrieval, enforce [query scope at the database boundary](./references/query-scope.md).
   - When behavior depends on whether a write changed zero, one, or many rows, interpret [mutation cardinality from the driver result](./references/mutation-cardinality.md) without returning row data solely to count it.
   - When several statements preserve one invariant, define a [transaction boundary](./references/transaction-boundaries.md) that passes the transaction through every participating helper.
   - When persisted timestamps mean the database's current time, use [database-generated timestamps](./references/database-timestamps.md) instead of an application clock.
2. Treat every raw result as untrusted at the ORM boundary.
   - When an unavoidable `sql` expression returns a value, apply [runtime expression decoding](./references/sql-expression-decoding.md) and ban compile-time-only result annotations.
   - When a builder cannot represent a result-bearing operation, contain it behind [complete raw-result validation](./references/raw-query-results.md) rather than trusting a generic result type.

Files in this skill

  • LICENSE.txt16.3 KB
  • SKILL.md2.6 KB
  • agents/openai.yaml139 B
  • references/built-in-query-helpers.md4.3 KB
  • references/database-timestamps.md1.5 KB
  • references/mutation-cardinality.md1.7 KB
  • references/query-scope.md875 B
  • references/raw-query-results.md1.1 KB
  • references/sql-expression-decoding.md1.9 KB
  • references/transaction-boundaries.md1.6 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.