database-conventions_skill

This skill helps you design multi-tenant databases with snake_case fields, RLS, and migrations for Drizzle and SQLModel across schemas.
  • Python

19

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill greyhaven-ai/claude-code-config --skill database-conventions

  • SKILL.md9.0 KB

Overview

This skill applies Grey Haven database conventions for Drizzle (TypeScript) and SQLModel (Python). It enforces snake_case fields, mandatory tenant_id for multi-tenancy, standard timestamps, RLS policies, and recommended indexing and migrations. Use it when designing schemas, writing models, creating migrations, or reviewing DB code to ensure consistency and safety.

How this skill works

The skill inspects schema and migration code for adherence to naming, tenancy, timestamp, and indexing rules. It checks that every table includes tenant_id, created_at and updated_at, and that columns use snake_case and proper suffix/prefix patterns. It verifies RLS enablement and suggests index patterns (tenant_id, foreign keys, unique fields) and migration steps for Drizzle Kit or Alembic. It outputs concrete fixes and template snippets for Drizzle and SQLModel when violations are found.

When to use it

  • Designing new database schemas or models
  • Creating Drizzle (TypeScript) or SQLModel (Python) models
  • Writing or reviewing database migrations
  • Setting up Row Level Security (RLS) for tenant isolation
  • Adding or auditing indexes and foreign keys
  • Reviewing PRs that mention database, schema, migration, RLS, tenant_id, snake_case, or foreign keys

Best practices

  • Always name database columns in snake_case; never camelCase
  • Include tenant_id on every table and enable RLS with a tenant isolation policy
  • Add created_at and updated_at to all tables; use deleted_at for soft deletes
  • Index tenant_id, foreign keys, and frequently queried fields; add unique constraints where appropriate
  • Use ORM migrations (Drizzle Kit for TypeScript, Alembic for SQLModel) — avoid inline raw SQL in application code
  • Prefix booleans with is_/has_/can_, timestamps with _at, and foreign keys with _id

Example use cases

  • Generate a Drizzle schema for a new users table that includes tenant_id, timestamps, and indexes
  • Convert an existing SQLModel model to follow snake_case and add RLS policies and migrations
  • Review a pull request to ensure tenant isolation, proper indexes, and migration files are present
  • Create Alembic or Drizzle Kit migration steps for schema changes and confirm onupdate behavior for updated_at
  • Draft RLS policies that use request JWT claims to enforce tenant-level access

FAQ

Yes. All tables, including join tables, must include tenant_id to guarantee tenant-level isolation and correct RLS enforcement.

Can I use camelCase in application models if DB is snake_case?

Avoid it. Prefer mapping in the ORM layer but keep database columns strictly snake_case to prevent confusion and ensure consistent SQL behavior.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
database-conventions skill by greyhaven-ai/claude-code-config | VeilStrat