db-defaults-generated

Audit database schema for correct column defaults and generated columns.

18|4|Updated Jun 16, 2026
One-click install
npx skills add https://github.com/Hainrixz/claude-db --skill db-defaults-generated
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: db-defaults-generated
Source: https://github.com/Hainrixz/claude-db/tree/main/skills/db-defaults-generated
Command: npx skills add https://github.com/Hainrixz/claude-db --skill db-defaults-generated

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill audits column defaults and generated columns, ensuring they are correctly configured to maintain data integrity and performance.

Core Features & Use Cases

  • Audit Timestamp Defaults: Checks for created_at/updated_at defaults set by application code instead of database defaults.
  • Derived Value Generation: Ensures derived values are stored as GENERATED ALWAYS AS ... STORED to prevent data drift.
  • Non-deterministic Defaults: Identifies defaults that should be dynamic or missing NOT NULL constraints.
  • Identity/Sequence Hygiene: Validates serial vs GENERATED ... AS IDENTITY usage and sequence ownership.
  • Use Case: Use this Skill to maintain a high-quality database schema by ensuring all defaults and generated columns are correctly implemented.

Quick Start

Run the db-defaults-generated skill to audit your database schema for correct column defaults and generated columns.

Frequently Asked Questions about db-defaults-generated

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I audit database schema for correct column defaults and generated columns?

You audit database schema for correct column defaults and generated columns by running a validation script that checks timestamp defaults, derived value constraints, and sequence ownership. This ensures your relational database maintains data integrity and query performance.

Why should generated columns use GENERATED ALWAYS AS STORED instead of application logic?

Generated columns should use GENERATED ALWAYS AS STORED to prevent data drift between derived values and their source columns. Storing derived values directly in the database schema ensures non-deterministic defaults remain consistent and maintain strict data integrity.

What is the difference between serial and GENERATED AS IDENTITY for database sequences?

The difference between serial and GENERATED AS IDENTITY for database sequences involves sequence ownership and syntax hygiene. Auditing identity and sequence configuration validates proper ownership constraints, ensuring reliable auto-incrementing behavior and optimal database performance.

How do I check if timestamp defaults are set by application code instead of the database?

You check if timestamp defaults are set by application code instead of the database by auditing the schema for missing created_at and updated_at default constraints. Correct database-level default configuration prevents inconsistent timestamp generation and improves data integrity.

Does this database schema audit work with any relational database?

This schema audit applies to relational databases supporting defaults and generated columns. It requires direct access to the database schema for analysis to validate non-deterministic defaults, NOT NULL constraints, and derived value configurations.

When should I not use generated columns for derived values in my database?

You should not use generated columns for derived values when your relational database lacks support for GENERATED ALWAYS AS STORED syntax. Auditing helps identify missing NOT NULL constraints and dynamic defaults that require alternative application-level configuration approaches.