sk-db

Official

Ship consistent DB patterns with guardrails

AuthorTimeKast
Version1.0.0
Installs0

System Documentation

What problem does it solve?

This Skill solves the inconsistency and fragility of database code by standardizing audit fields, soft-deletes, dual human/technical IDs, pagination, deletion eligibility, and the migration workflow so your Next.js/Drizzle projects behave predictably in production.

Core Features & Use Cases

  • Enforces mandatory audit fields: Adds createdAt/createdBy/modifiedAt/modifiedBy via auditFields and documents how to populate them using the kit’s injected userId from server action wrappers.
  • Implements soft delete conventions: Adds deletedAt/deletedBy with softDeleteFields and guarantees reads filter out deleted rows via notDeleted().
  • Standardizes dual-ID human identifiers: Provides generateHumanId, atomic sequence-based getNextHumanId, gap-resilient getNextHumanIdSeq, and race-safe withHumanIdRetry() including the required SAVEPOINT behavior when called inside a parent transaction.
  • Provides safe pagination primitives: Uses parsePaginationParams, buildPaginationSQL, and createCachedCount with revalidation tagging to prevent stale totals.
  • Adds hard-delete eligibility checks: Uses canHardDeleteUser to prevent permanent deletion when downstream references exist.
  • Gives repeatable migration and DB inspection workflow: Establishes db:generate → review SQL → db:migrate, and read-only inspection via pnpm db:query.

Quick Start

Use the sk-db helpers when creating new Drizzle schema files and mutations to ensure every table includes auditFields, applies softDeleteFields where appropriate, and uses the kit’s pagination, human-id, and migration conventions.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: sk-db
Download link: https://github.com/TimeKast/AgendaInteligente/archive/main.zip#sk-db

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.