Guidelines
Use page descriptions to select pages before loading them. After loading a conditional page, apply it only when its Activation section matches.
Foundations
- House style and Postgres philosophy - load for overall posture: integrity in the database, logic in the application, normalized-first modeling, and version assumptions.
- Identifier casing and quoting - load when creating any named object; covers snake_case, quoting bans, reserved words, and length limits.
- Object naming - load when naming tables, columns, constraints, indexes, functions, triggers, or views.
- Schema layout and search_path - load when choosing schemas, qualifying references, or handling
search_path. - SQL formatting and comments - load for keyword casing, commas, indentation, aliases, and
COMMENT ON.
Schema Design and Data Types
- Primary keys and row identity - load when choosing PK types,
uuidv7()vs identity columns, or natural vs surrogate keys. - Foreign keys and relationships - load when adding references, choosing
ON DELETEactions, or modeling hierarchies. - Scalar types - load when choosing string, numeric, integer, or boolean column types.
- Temporal data and time zones - load when adding timestamps, dates, intervals, or validity periods.
- JSONB, arrays, and normalization - load when deciding between relational columns,
jsonb, and arrays. - Enums, domains, and lookup tables - load when modeling status fields, categories, or reusable scalar validation.
- Standard columns and row lifecycle - load for
created_at/updated_at, defaults, generated columns, and soft vs hard delete.
Constraints and Indexes
- Constraints and NULL semantics - load for
NOT NULLpolicy,CHECKconstraints, uniqueness, and temporal constraints. - Index basics - load when adding ordinary indexes, indexing FKs, or choosing unique constraint vs unique index.
- Advanced indexes - load for partial, expression, multicolumn, covering, or GIN indexes.
Query Style
- SELECT structure and join style - load when writing joins, qualifying columns, or deciding on
SELECT *. - Subqueries, EXISTS, and LATERAL - load for semi-joins,
NOT INtraps,ANY, andLATERAL. - CTEs and query decomposition - load when structuring nontrivial queries or considering materialization.
- Aggregation, window functions, and pagination - load for
GROUP BY, ranking, ordering, and pagination. - DML, upserts, and RETURNING - load when writing
INSERT/UPDATE/DELETE, upserts,MERGE, orRETURNING.
Database Logic
- Functions and procedures - load when writing database functions; covers language choice, volatility, and security modes.
- Views and materialized views - load when adding views or materialized views and their refresh strategies.
- Triggers - load when a trigger is proposed; covers the minimal-trigger doctrine and the narrow valid cases.
Security
- Roles, privileges, and row-level security - load when configuring roles, grants, default privileges, or RLS.