sql-query-conventions

Enforce SQL, PostgREST, and ORM conventions for scalable read-path queries.

4|1|Updated Mar 11, 2026
One-click install
npx skills add https://github.com/jcdendrite/claude-config --skill sql-query-conventions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-query-conventions
Source: https://github.com/jcdendrite/claude-config/tree/main/claude/.claude/skills/sql-query-conventions
Command: npx skills add https://github.com/jcdendrite/claude-config --skill sql-query-conventions

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents slow, costly, and subtly incorrect data-access patterns in read-path queries by enforcing practical SQL/PostgREST/ORM conventions that scale as your data grows.

Core Features & Use Cases

  • List-query safety: Enforces explicit limits, stable ordering for pagination, and correct single-row semantics to avoid unbounded reads and paging bugs.
  • Anti–N+1 guidance: Detects and prevents per-item async fetch loops by recommending batching, joins, or server-side aggregation approaches.
  • Bandwidth and correctness focus: Promotes explicit column selection instead of SELECT * to reduce coupling to schema growth and limit over-fetching.

Use it when you are reviewing or generating SELECT queries, PostgREST .from()/.select() chains, list-returning ORM calls, or pagination designs, especially for user-facing endpoints and background jobs that will hit real data volumes.

Quick Start

Apply the sql-query-conventions rules to the proposed SELECT query and point out any violations of limit, pagination ordering, N+1 patterns, and column selection.

Frequently Asked Questions about sql-query-conventions

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

FAQPage Schema
How do I prevent N+1 queries in my ORM list calls?

To prevent N+1 queries in ORM list calls, replace per-item async fetch loops with batched access, joins, or server-side aggregation. This avoids expensive round-trips and ensures your data access scales efficiently as your data volume grows.

How do I implement stable pagination in SQL SELECT queries?

To implement stable pagination in SQL SELECT queries, use deterministic ORDER BY clauses alongside explicit LIMITs with validated page sizes. This combination prevents unbounded reads and avoids paging bugs when users navigate through large datasets.

Why should I avoid SELECT * and use explicit column selection?

You should avoid SELECT * and use explicit column selection to reduce bandwidth over-fetching and limit coupling to schema growth. Specifying exact columns ensures your queries remain correct and performant even when the database schema expands.

Does this work with PostgREST .from() and .select() chains?

Yes, it works directly with PostgREST .from() and .select() chains by applying the same read-path conventions. It enforces explicit limits, stable ordering, and batched access to prevent inefficient data-access patterns in your PostgREST queries.

What are the limitations of relying on ORMs for query optimization?

Relying on ORMs for query optimization can lead to unbounded reads, unstable pagination, and N+1 round-trips if not explicitly constrained. You must enforce explicit LIMITs, deterministic ordering, and column selection to avoid these slow and costly data-access patterns.