DEVFLOW

Learn the Standard

Schema and SQL Standard

Use PostgreSQL types, constraints, query shapes, and indexes to encode real invariants.

Tables must express required facts

  • Use stable primary keys, not null for required facts, and foreign keys for required relationships.
  • Use check and unique constraints for state, range, idempotency, and duplicate prevention.
  • Use timestamptz for instants, date for calendar dates, and numeric rather than floating point for exact money.
  • Treat UUIDs as identifiers, never as authorization.
  • Use relational columns for understood integrity and ownership requirements; JSONB is not a shortcut around modeling.

Write queries from access paths

Every durable read or mutation needs an actor, required columns, tenant or visibility predicates, stable ordering, expected cardinality, pagination approach, and a security decision separate from frontend filtering.

Important writes must be atomic under retries and races. Prefer a constraint or conditional mutation over a sequence of “read, decide, write.”

Synthesize indexes from queries

An AI must not propose an index without identifying the query or RLS predicate it serves, selectivity assumptions, write/storage cost, and a validation procedure using representative data and query plans.

explain (analyze, buffers)
select id, title, published_at
from public.posts
where status = 'published'
order by published_at desc, id desc
limit 20;

Design for concurrency and replay

For bookings, quotas, payments, publication, invites, media processing, and jobs, state what happens when two requests race and when the same request is replayed. Use unique idempotency keys, atomic conditional updates, short transactions, deterministic lock ordering, or carefully justified isolation and retry behavior.