sql-sentinel

Audits SQL for cost and performance anti-patterns and scores warehouse query health.

Updated Aug 11, 2026
One-click install
npx skills add https://github.com/DucCuong159/Realtime-chatapp --skill sql-sentinel-duccuong159
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-sentinel
Source: https://github.com/DucCuong159/Realtime-chatapp/tree/main/.agent/skills/sql-sentinel
Command: npx skills add https://github.com/DucCuong159/Realtime-chatapp --skill sql-sentinel-duccuong159

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Data warehouse queries with anti-patterns like SELECT *, Cartesian joins, and non-sargable predicates silently inflate cloud bills and slow down dashboards. This Skill statically audits SQL files, scores query health from 0-100, and produces a prioritized cost-reduction plan before queries reach production. ## Core Features & Use Cases - 20-Rule Static Analysis: Detects SELECT *, full-table scans, Cartesian joins, the NOT IN NULL trap, non-sargable predicates, and 15 more anti-patterns across BigQuery, Snowflake, Redshift, and Postgres. - Health Scoring & Prioritized Plan: Scores each script 0-100 (grades A-F) weighted by severity and returns findings ordered by impact, each with a why, a concrete fix, and estimated savings. - Use Case: Before merging a dbt model or dashboard query, run the audit to catch a comma-join that could turn a $0.02 query into a $200 query, and get the exact rewrite needed. ## Quick Start Ask the assistant to audit your SQL file with sql-sentinel and return the health score plus the prioritized list of cost-saving fixes.

Frequently Asked Questions about sql-sentinel

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

FAQPage Schema
How do I audit SQL queries for performance anti-patterns?

Run the sql-sentinel script against your .sql file with node scripts/sql-sentinel.js path/to/query.sql, or call auditSql programmatically with a dialect option. It returns a health score, letter grade, and prioritized findings with fixes.

What SQL anti-patterns increase BigQuery or Snowflake costs?

The costliest patterns include SELECT * full column scans, missing WHERE clauses causing full table scans, Cartesian joins from comma syntax, leading-wildcard LIKE, functions on indexed columns, and DELETE or UPDATE without WHERE.

Does sql-sentinel support Snowflake, Redshift, and Postgres?

Yes, the analyzer works across BigQuery, Snowflake, Redshift, and Postgres, and also applies to Spark SQL review. You can pass a dialect option such as bigquery when calling the auditSql function programmatically.

Can static SQL analysis replace query plan inspection?

No. This is a static analyzer that reads SQL text only; it does not read query plans, row counts, or billing data. A flagged pattern on a small table may be harmless, so treat findings as preventive guidance rather than measured cost.

Why does NOT IN with a subquery cause wrong results in SQL?

NOT IN fails when the subquery returns any NULL, because NULL comparisons make the entire predicate evaluate to unknown and filter out all rows. The audit flags this as rule SQL008 and recommends NOT EXISTS instead.