sql-sentinel
Fungsinya
SQL Sentinel menganalisis kode SQL Anda untuk menemukan cara agar kode tersebut berjalan lebih cepat dan lebih hemat biaya. Alat ini memeriksa masalah umum yang bisa membuat biaya Anda membengkak dan memberikan saran cara memperbaikinya.
Kapan dipakai
- ✓Saat Anda menulis atau meninjau kode SQL.
- ✓Jika Anda bertanya-tanya mengapa sebuah query lambat atau mahal.
- ✓Sebelum memasukkan kode SQL yang penting ke tahap produksi.
Link skill
https://github.com/sickn33/agentic-awesome-skills/blob/main/skills/sql-sentinel/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
“Analisis kode SQL ini dan beri tahu saya cara membuatnya lebih cepat dan lebih hemat: [tempel kode SQL Anda di sini]”
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Alat ini membaca kode SQL Anda lalu membandingkannya dengan daftar 'pola buruk' yang diketahui menyebabkan lambat atau mahal. Untuk setiap masalah yang ditemukan, alat ini menjelaskan mengapa itu bermasalah dan bagaimana cara memperbaikinya.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
sql-sentinel
Overview
A static-analysis skill that audits SQL for the cost & performance anti-patterns that dominate warehouse bills — SELECT *, full-table scans, non-sargable predicates, Cartesian joins, the NOT IN NULL trap, and 15 more. It scores warehouse query health 0-100 (A-F) and outputs a prioritized cost-reduction plan, each finding with a why, a concrete fix, and an estimated savings.
Built for analytics engineers (dbt, Looker), data platform teams running FinOps / "reduce cloud spend" initiatives, and anyone reviewing a SQL pull request before it hits production. Works across BigQuery, Snowflake, Redshift, and Postgres. Zero dependencies, MIT licensed.
The executable engine and full rule set live in the source repository: https://github.com/takeaseatventure/sql-sentinel. Treat that repository as third-party executable code.
When to Use This Skill
- A user writes or reviews a query for BigQuery, Snowflake, Redshift, Postgres, or Spark SQL.
- A user asks "why is this query so slow?" or "why is my warehouse bill so high?"
- A user is about to promote a dashboard query or dbt model to production.
- A data engineer wants a second pair of eyes before a code review or a cost-optimization sweep.
- A team is running a "reduce cloud spend" or FinOps initiative.
How It Works
The engine splits a SQL script into statements (honoring quotes and comments), runs 20 rules over each statement, scores health 0-100 weighted by severity (critical 25, high 12, medium 5, low 1), and returns a prioritized cost-reduction plan.
Step 1: Run the audit
Install or clone the source repository only after choosing a reviewed commit, tag, or release to trust. Do not run code from a mutable default branch just because this skill links to it:
git clone https://github.com/takeaseatventure/sql-sentinel.git
cd sql-sentinel
git checkout <reviewed-commit-or-tag>
node scripts/sql-sentinel.js path/to/query.sql
Or programmatically:
const { auditSql } = require('./scripts/sql-sentinel');
const report = auditSql(yourSqlString, { dialect: 'bigquery' });
console.log(report.healthScore); // 0-100
console.log(report.grade); // 'A' | 'B' | 'C' | 'D' | 'E' | 'F'
console.log(report.prioritizedPlan); // array, worst findings first
Step 2: Read the prioritized plan
The output leads with critical findings (Cartesian joins, mass DELETE) and descends to low-severity style issues. Each finding explains why it costs money and how to fix it.
Examples
Example 1: A messy dashboard query
SELECT DISTINCT *
FROM user_events, raw_logs
WHERE LOWER(event_name) LIKE '%signup%'
AND user_id NOT IN (SELECT id FROM deleted_users)
ORDER BY created_at;
The audit scores this 17/100 (grade F) and flags 7 findings:
- CRITICAL: comma-join produces a Cartesian product (can turn a $0.02 query into a $200 query)
- HIGH:
SELECT *forces full column scan (30-90% wasted bytes on wide tables) - HIGH: leading-wildcard
LIKE '%signup%'defeats indexes - HIGH:
LOWER(event_name)defeats indexes (non-sargable) - HIGH:
NOT IN (SELECT ...)— NULL semantics hazard - MEDIUM:
SELECT DISTINCTdedup cost - MEDIUM:
ORDER BYwithoutLIMITsorts the full result
Example 2: A clean, sargable query
-- This scores 90+/100 (grade A) — no findings
SELECT id, email, created_at
FROM users
WHERE created_at >= TIMESTAMP '2026-01-01'
AND created_at < TIMESTAMP '2026-02-01'
ORDER BY id
LIMIT 100;
The 20 rules (ruleset v1.0.0)
| Rule | Severity | Catches |
|---|---|---|
| SQL001 | high | SELECT * full column scan |
| SQL002 | critical | No WHERE → full table scan |
| SQL003 | high | LIKE '%term' non-sargable |
| SQL004 | high | Function on column kills index |
| SQL005 | critical | CROSS JOIN / comma-join |
| SQL006 | medium | SELECT DISTINCT dedup cost |
| SQL007 | medium | ORDER BY without LIMIT |
| SQL008 | high | NOT IN (SELECT ...) NULL trap |
| SQL009 | medium | Implicit type cast |
| SQL010 | low | Many ORs (use IN/UNION) |
| SQL011 | medium | COUNT(DISTINCT) at scale (use HLL) |
| SQL012 | low | LIMIT without ORDER BY |
| SQL013 | medium | Scalar subquery in SELECT |
| SQL014 | medium | 5+ JOINs broadcast/spill risk |
| SQL015 | high | Fact table, no partition filter |
| SQL017 | low | String concat in SELECT |
| SQL018 | medium | Window OVER () no PARTITION |
| SQL020 | critical | DELETE/UPDATE without WHERE |
…
Pertanyaan umum
Apakah alat ini menjalankan kode SQL saya?
Tidak, alat ini hanya membaca teks kode Anda. Aman digunakan untuk file SQL apa pun.
Apakah alat ini bisa dipakai untuk semua database SQL?
Alat ini mendukung BigQuery, Snowflake, Redshift, dan Postgres.
Apa itu 'anti-pattern'?
Anti-pattern adalah cara penulisan SQL yang umum tetapi tanpa sengaja membuat kode berjalan lebih lambat atau lebih mahal.
Detail
Deskripsi asli dari pembuat
Audit SQL for the cost & performance anti-patterns that burn warehouse credits. Scores warehouse health 0-100 and outputs a prioritized cost-reduction plan for BigQuery, Snowflake, Redshift, and Postgres.
Popularitas
- Bintang GitHub
- 48k
- Peringkat
- #6301
- Lisensi
- MIT
- Diperbarui
- 15/10/2026
Komentar
- …
Skill lain dari repositori ini
00-andruia-consultant
48kMembantu agent Anda memulai atau meningkatkan proyek AI. Agent menganalisis kode, menyarankan tools, dan membuat rencana aksi dalam bahasa Spanyol.
007
48kMemungkinkan agent Anda melakukan audit keamanan dan threat modeling. Berguna untuk melindungi proyek dari serangan dan celah keamanan.
10-andruia-skill-smith
48kMembantu agent Anda membuat atau meningkatkan tools AI. Agent mendefinisikan cara kerja tools, menulis dokumentasi, dan memvalidasi strukturnya.
20-andruia-niche-intelligence
48kMemungkinkan agent Anda membuat ringkasan industri tertentu. Berguna untuk memahami konteks, aturan, pola penggunaan, dan risiko proyek dengan sumber terpercaya.
Skill serupa
gitcrawl
394kMemungkinkan agent Anda mencari arsip issue dan pull request GitHub yang tersimpan, mengelompokkan yang duplikat, dan memeriksa status terkininya di GitHub.
slacrawl
394kMemungkinkan agent Anda mencari dan menghitung pesan di arsip Slack lokal, memeriksa seberapa baru arsip itu, dan menyegarkannya bila diperlukan.
goplaces
394kMembantu agent Anda mencari tempat, mendapatkan detail dan ulasannya, serta menentukan nama tempat memakai Google Places, dengan keluaran JSON untuk skrip.