← ClaudeAtlas

pg-schemalisted

Enforce PostgreSQL schema design conventions. Use this skill when editing **/migrations/*.sql, **/schema/*.sql, or when the user mentions table, column, primary key, foreign key, index, constraint, JSON column, jsonb, schema, ddl, CREATE TABLE, BIGSERIAL, UUID, timestamp. Forbids ad-hoc naming, missing FK constraints, SERIAL when BIGSERIAL works, missing timestamps, jsonb for structured first-class data, timestamp without time zone.
zhaojiannet/canon · ★ 1 · Web & Frontend · score 77
Install: claude install-skill zhaojiannet/canon
This skill enforces PostgreSQL schema design conventions. Pair this with `postgresql-migration-safety`—that skill covers change-safety; this skill covers naming and shape. Apply when authoring `CREATE TABLE` / `ALTER TABLE ... ADD CONSTRAINT` in migrations. ## Naming - **Table names**: `snake_case`, plural noun. `users`, `order_items`. Not `User`, `OrderItem`, `tbl_user`. - **Column names**: `snake_case`. `created_at`, `email_address`, `is_active`. No camelCase. - **Primary key**: always `id`. `BIGSERIAL` for auto-increment, `UUID` (with `gen_random_uuid()` default) for distributed/external-facing. - **Foreign keys**: `<referenced_table_singular>_id`. `users.org_id` references `organizations.id`. - **Boolean columns**: prefix with `is_` / `has_`. `is_active`, `has_paid`. Default a sensible value, not nullable. - **Timestamp columns**: `created_at`, `updated_at`, `deleted_at` (if soft delete). All `timestamptz`, never `timestamp`. Default `now()`. - **Index names**: `idx_<table>_<columns>`. `idx_users_org_id`, `idx_orders_user_id_created_at`. - **Constraint names**: explicit, not auto-generated. `users_email_key` (unique), `users_email_check` (check), `orders_user_id_fkey` (foreign key). ## Required columns on every business table ```sql CREATE TABLE users ( id BIGSERIAL PRIMARY KEY, -- business columns created_at timestamptz NOT NULL DEFAULT now(), updated_at timestamptz NOT NULL DEFAULT now() ); ``` `updated_at` is maintained by a trigger or by application code