How it works
Every text-to-SQL demo generates a query and prays. SQL Sentinel is the verification layer those demos skip: generate, then prove the SQL is safe and correct — against your real schema, before anything runs.
The two tabs
- Generate — ask in English. An LLM (your free key — Google Gemini or Groq, paste-once, stored only in this browser) writes the SQL for your dialect. Then the validator checks it: if there are errors, the error messages plus the schema go back to the model for a fix — up to 3 rounds. You watch the loop happen.
- Verify — paste any SQL (yours, a colleague's, an AI's) plus your schema. Instant validation report, plain-English explanation, and a guardrail verdict. No key, no account, zero network calls.
The checks
| Check | Severity | What it does |
|---|---|---|
UNKNOWN_TABLE / UNKNOWN_COLUMN | error | Every table and column must exist in your schema. Misspellings get a did-you-mean suggestion (Levenshtein). |
DESTRUCTIVE_NO_WHERE | error | DELETE/UPDATE without WHERE is blocked. DROP/TRUNCATE are always blocked. |
DESTRUCTIVE_WHERE | warning | DELETE/UPDATE with WHERE passes with a warning — preview with SELECT first. |
CROSS_JOIN / IMPLICIT_CROSS_JOIN | warning | Joins with no ON condition pair every row with every row. |
TYPE_MISMATCH | warning | Comparing a number column to a string literal, etc. (Date literals vs datetime columns are allowed — that's idiomatic.) |
AMBIGUOUS_COLUMN | warning | A column name exists in two joined tables — qualify it. |
PII_ACCESS | warning | Flags likely-PII columns (email, phone, SSN, …) by name heuristic. |
MISSING_LIMIT | warning | No LIMIT on a non-aggregated query — could return the whole table. |
SELECT_STAR | info | SELECT * returns everything, including future schema surprises. |
The verdict
- ✓ SAFE — no issues found.
- ⚠ NEEDS REVIEW — warnings only. Read them, then decide.
- ✕ BLOCKED — errors found. Fix before running.
Honest limits
- It never executes anything. "Safe" means "passes static checks", not "returns correct business answers". A query can be valid SQL against a real schema and still answer the wrong question.
- Ambiguous language stays ambiguous. If "active customer" isn't defined in your schema, the tool surfaces its assumptions in the plain-English explanation instead of guessing silently — but a human still has to confirm the business logic.
- PII detection is name-based. A column called
notesfull of phone numbers won't be flagged. It's a tripwire, not a guarantee. - Parsing is best-effort. Exotic dialect syntax may fail to parse; failures are reported as unknown, never silently passed.
- The Generate tab is only as good as the model. The validator catches mechanical errors (wrong names, types, dangerous ops) — it cannot catch a plausible-but-wrong interpretation of your question.
Privacy
100% client-side. Your schema and SQL never leave this browser. The only network call in the entire app is the one you trigger on the Generate tab, to your chosen provider's API, with your key. The Verify tab works fully offline.
Phase 2 — done
SQL Sentinel as a GitHub Action — the code reviewer for AI-written SQL. It validates SQL in pull requests (dbt models, migrations), explains the diff in plain English, and flags dangerous changes before merge. k1sh0r3/sql-sentinel-action