kb-db

Standardize Drizzle ORM and Postgres database modeling with portable schemas and queries.

Updated May 19, 2026
One-click install
npx skills add https://github.com/TimeKast/AgendaInteligente --skill kb-db
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kb-db
Source: https://github.com/TimeKast/AgendaInteligente/tree/main/.claude/skills/kb-db
Command: npx skills add https://github.com/TimeKast/AgendaInteligente --skill kb-db

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It prevents slow, incorrect, and non-portable database implementations by providing a repeatable Drizzle ORM + Postgres blueprint for schemas, queries, mutations, transactions, indexes, pagination, and performance checks.

Core Features & Use Cases

  • Portable schema conventions: enforce a canonical Drizzle shape with $inferSelect/$inferInsert, snake_case DB columns, camelCase TS properties, and domain-based schema files.
  • Safe data modeling patterns: relations, enums, audit columns, soft delete rules, and dual-ID modeling with concurrency-safe human_id generation.
  • Query and mutation best practices: parameterized queries, correct upserts, consistent transaction usage, and N+1 avoidance via joins/relations.
  • Indexing and performance workflow: choose correct Postgres index types, order composite index columns by query shape, and require EXPLAIN ANALYZE before optimizing.

Quick Start

Use kb-db to implement or review a Drizzle ORM schema and queries for a Postgres-backed feature, ensuring timezone-aware timestamps, safe soft-delete reads, correct relations, and performance-validated indexing.

Frequently Asked Questions about kb-db

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent N+1 query issues when using Drizzle ORM with Postgres?

Avoid N+1 queries in Drizzle ORM by using relation-based joins and parameterized query construction to fetch associated data efficiently and prevent performance regressions.

What is the correct way to implement soft delete and audit columns in a Postgres schema?

Safe soft delete and audit column implementation in a Postgres schema requires enforcing timezone-aware timestamp columns and consistent transaction usage to maintain data correctness and prevent accidental hard deletes.

How do I choose the right Postgres index types and composite column ordering for query optimization?

Postgres index tuning requires selecting appropriate index types and ordering composite columns by query shape, validated through EXPLAIN ANALYZE before applying optimizations to prevent slow queries.

Does this Drizzle ORM schema design pattern work with self-hosted Postgres and Neon?

Yes, the Drizzle ORM schema design is portable and applies to any project using Neon or self-hosted Postgres, enforcing canonical shapes and safe typing.

Why do my Drizzle ORM TypeScript types not match my database columns correctly?

Drizzle ORM TypeScript type mismatches occur when schemas lack $inferSelect and $inferInsert typing alongside snake_case database columns and camelCase TypeScript properties.