db-defaults-generated

Installation
SKILL.md

db-defaults-generated (M6)

Defaults and generated columns are correctness placed at the source: a created_at DEFAULT now() is true for every writer, and a GENERATED ALWAYS AS column can never drift from its inputs. Pushing this logic into the app means each writer can get it wrong differently. This module is design-axis (Tipos category). It applies to engines supporting defaults/generated columns.

What it checks

  • Timestamp defaults: created_at/updated_at set only by application code (no DEFAULT now()/CURRENT_TIMESTAMP, no ON UPDATE/trigger) — inconsistent across writers, missing on raw SQL inserts.
  • Derived value should be generated: a stored column computed from siblings (full_name, total = qty*price, search_vector) kept in sync by app code rather than GENERATED ALWAYS AS ... STORED — drift-prone (ties to M1 denormalization discipline).
  • Non-deterministic / wrong default: defaults that bake in a value that should be dynamic, or a default that masks a missing NOT NULL (e.g. status DEFAULT 'active' hiding required intent), or a DEFAULT '' standing in for NULL.
  • Identity/sequence hygiene: serial vs GENERATED ... AS IDENTITY; shared/incorrect sequence ownership.
  • Boolean/flag defaults missing, forcing three-valued logic where two was intended.

Axis & severity

  • Axis: design; magnitude banded, never invented drift rates.
  • Derived stored column maintained by app (drift risk): severity 3, warn, fixable: proposed.
  • Missing created_at/updated_at DB default: severity 2–3, warn, fixable: auto (additive default).
  • DEFAULT ''/sentinel masking NULL semantics: severity 2, warn.
  • M6 holds no sev-5 cap; it shapes the Tipos category value.
Installs
58
GitHub Stars
19
First Seen
Jun 17, 2026
db-defaults-generated — hainrixz/claude-db