skills/db-naming-conventions/SKILL.md
Naming conventions for relational databases: databases, tables, columns, indexes, constraints, and enums. Applies to SQL migrations, sqlc queries, and ER diagrams in Mermaid. Trigger: When creating database tables, writing migrations, designing ER diagrams, or naming columns and constraints.
npx skillsauth add 333-333-333/agents db-naming-conventionsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
golang-migrate, Flyway, etc.).mmd files)| Skill | Purpose | Path |
|-------|---------|------|
| go-repository-pattern | Migration files, sqlc queries follow these naming rules | ../go-repository-pattern/SKILL.md |
| mermaid-diagrams | ER diagrams must use the same naming as SQL | ../mermaid-diagrams/SKILL.md |
One naming convention governs everything: ER diagrams, SQL migrations, sqlc queries, and application code mappings. Zero translation, zero ambiguity. What the diagram says is what the migration creates.
| Rule | Convention | Example |
|------|-----------|---------|
| Format | snake_case | bastet, bastet_production |
| Environment suffix | Only when multiple DBs on same server | bastet_dev, bastet_staging |
| Rule | Convention | Example |
|------|-----------|---------|
| Format | snake_case | users, pet_sitters |
| Plurality | Always plural | bookings, NOT booking |
| No prefixes | Never tbl_, t_ | users, NOT tbl_users |
| Join tables | Alphabetical order or semantic name | pets_services or pet_sitter_certifications |
| Rule | Convention | Example |
|------|-----------|---------|
| Format | snake_case | first_name, phone_number |
| Primary key | Always id | id UUID PRIMARY KEY |
| Foreign key | {singular_table}_id | user_id, pet_sitter_id |
| Booleans | Prefix is_ or has_ | is_active, has_premium |
| Timestamps | Suffix _at | created_at, updated_at, deleted_at |
| Counts | Suffix _count | booking_count, review_count |
| Monetary | Suffix _cents (store as integer) | price_cents, fee_cents |
| Type | Pattern | Example |
|------|---------|---------|
| Regular index | idx_{table}_{columns} | idx_users_email |
| Unique index | uq_{table}_{columns} | uq_users_email |
| Composite | idx_{table}_{col1}_{col2} | idx_bookings_user_id_status |
| Type | Pattern | Example |
|------|---------|---------|
| Primary key | pk_{table} | pk_users |
| Foreign key | fk_{source}_{target} | fk_bookings_users |
| Check | ck_{table}_{column} | ck_bookings_status |
| Unique | uq_{table}_{columns} | uq_users_email |
| Rule | Convention | Example |
|------|-----------|---------|
| Type name | snake_case | booking_status, payment_status |
| Values | UPPER_SNAKE_CASE | PENDING, IN_PROGRESS, COMPLETED |
ER diagrams MUST mirror SQL naming exactly. This means:
| Element | In SQL | In Mermaid ER | Match? |
|---------|--------|---------------|--------|
| Table name | users | users | Yes |
| Column name | first_name | first_name | Yes |
| Foreign key | user_id | user_id FK | Yes |
| Primary key | id | id PK | Yes |
| Data type | UUID | uuid | Lowercase in Mermaid |
See assets/example-er.mmd for a complete ER diagram following these conventions.
See assets/example-migration.sql for the matching SQL migration.
| Don't | Do | Why |
|-------|------|-----|
| UPPER_CASE entity names in ER | snake_case plural matching SQL | Diagram must match implementation |
| camelCase columns in ER diagrams | snake_case matching SQL | Zero translation between diagram and migration |
| userId as foreign key | user_id | Consistent snake_case |
| tbl_users, t_users | users | Prefixes add noise, zero value |
| booking (singular table) | bookings (plural) | Table holds a collection |
| active (boolean without prefix) | is_active | Prefix makes intent obvious |
| price DECIMAL | price_cents INTEGER | Integer cents avoid float rounding |
| data, info, details columns | Specific names | Vague names hide meaning |
| id INTEGER AUTO_INCREMENT | id UUID | UUIDs are safer for distributed systems |
# Create a migration with proper naming
migrate create -ext sql -dir migrations -seq create_bookings
# Validate table naming in existing migrations
rg "CREATE TABLE" migrations/ --no-heading
snake_case and pluralsnake_case and singularid (UUID){singular_table}_id patternis_ or has_ prefix_atidx_{table}_{columns} pattern{type}_{table}_{detail} pattern_cents suffixtesting
Review Flutter components and screens for UX/UI compliance. Trigger: When user invokes /ux-review command or requests UX audit.
development
TypeScript strict patterns and best practices. Trigger: When implementing or refactoring TypeScript in .ts/.tsx (types, interfaces, generics, const maps, type guards, removing any, tightening unknown).
testing
Testing philosophy and strategy for every feature: test pyramid, mandatory levels per change type, completion checklist, and skill delegation. Trigger: When planning tests for a feature, reviewing test coverage, defining acceptance criteria, or asking what tests a change needs.
development
Terraform security practices: sensitive variables, secret management, state protection, .gitignore patterns, and CI/CD credential handling. Trigger: When handling secrets in Terraform, configuring state backends, reviewing .gitignore for Terraform, or setting up CI/CD pipelines for infrastructure.