All skills
simota avatar

/schema

@c805268
by shingo imotasimota/agent-skills85 stars
15

Designing database schemas, migrations, and multi-tenant architecture: RLS, tenant routing, provisioning, quotas, and isolation. Not for query-plan tuning (Tuner).

Use this Skill: https://skilld.dev/gh/simota/agent-skills/schema

This session only. Nothing lands on disk.

referenceschema-design-anti-patterns.md

≈694 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Schema Design Anti-Patterns

Purpose: Use this file when reviewing table structure, naming, constraints, or data-type choices.

  1. Core anti-patterns
  2. Data-type selection
  3. Constraint strategy
  4. Naming rules
  5. Design gates

Core Anti-Patterns

ID Anti-pattern Signal Safer pattern
SD-01 God Table 200+ columns, full scans dominate, many unrelated domains mixed together Split by domain or lifecycle
SD-02 Missing Primary Key Rows cannot be uniquely updated/deleted, ORM support breaks Add UUID or BIGINT surrogate PK
SD-03 FK Orphans *_id columns without FK constraints, ghost records remain Add FK plus deliberate ON DELETE strategy
SD-04 Wrong Data Type Date, money, boolean, or UUID stored as text Use semantic DB-native types
SD-05 Wide Table 150+ columns or many sparse attributes Vertical split, move sparse fields to JSONB only if justified
SD-06 Constraint Desert No CHECK, NOT NULL, or UNIQUE; app-only validation Enforce invariants in the DB
SD-07 Reserved Word Collision user, order, group, or other reserved names require quoting Use plural or scoped names

Data-Type Selection

Data kind Avoid Prefer
Money FLOAT, DOUBLE NUMERIC / DECIMAL
Date/time VARCHAR DATE, TIMESTAMP, TIMESTAMPTZ
Boolean INT, CHAR('Y'/'N') BOOLEAN
UUID VARCHAR(36) Native UUID
Status Free-form VARCHAR ENUM or CHECK
JSON payload TEXT JSON / JSONB

Constraint Strategy

  • DB constraints are the final integrity boundary.
  • App validation improves UX; it does not replace DB validation.
  • Name constraints explicitly so failure messages are actionable.
  • Use ON DELETE CASCADE only when bulk child deletion is intentional and bounded.

Naming Rules

Area Preferred Avoid
Tables plural snake_case singular, camelCase, reserved words
FKs {table_singular}_id ambiguous names like user or ref
Booleans is_*, has_* vague flags
Timestamps *_at mixed naming styles
Indexes idx_{table}_{columns} auto-generated opaque names
Constraints pk_, fk_, chk_, uniq_ prefixes unnamed or opaque defaults

Design Gates

  • 50+ columns in one table -> review for vertical split
  • Missing PK -> block the design
  • *_id without FK -> propose a FK or explain why the link is intentionally soft
  • Date/money/boolean stored as text -> propose a type migration
  • No CHECK / NOT NULL where business invariants exist -> add DB constraints
  • Reserved-word identifier -> rename before migration generation

Source: SKILL.md on GitHub

No alerts13d5 checks · Risk SAFE
  • Gen Agent Trust Hub13d

    The skill is a comprehensive database schema specialist that provides guidance on data modeling, migration planning, and multi-tenant architecture. It strictly follows security best practices, including enforcing Row-Level Security (RLS), recommending lock timeouts to prevent database outages, and using the expand-contract pattern for safe migrations. No malicious patterns, obfuscation, or unauthorized network operations were detected.

  • Socket13d

    No alerts

  • Snyk13d

    Risk: LOW · No issues

  • Runlayer6mo

    1/9 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at c805268. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 days ago.

Activeupdated 2 weeks ago

README badge

README badge for simota/agent-skills/schema