Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Defines provenance-tracked rules for building and executing Postgres and analytics SQL safely in Supabase Studio.
27% 91%+64 ptsof test cases passed
Passed 20 of 22 test cases with the skill, and 6 of 22 without it.
In a Supabase Studio search view, I receive an unverified filter string directly from `searchParams.get('filter')`. I need to mark this string as untrusted for tracking before passing it to display utilities. Provide the TypeScript snippet to wrap this search parameter.
Imports untrustedSql from @supabase/pg-meta.
This test ran on v2. v3 is the current version and hasn’t been tested on gemini-3.6-flash yet.
3 of 3 safety checks passed
Studio runs SQL directly against the authenticated user's Postgres database and analytics logs. Our security model is proven authorship: users may run any SQL they explicitly authored or that is hardcoded in the app, but SQL influenced by external input (URL params, LLM output, auto-saved snippets) must never execute without sanitization or an explicit user run gesture.
Two intentionally disjoint branded type systems enforce this at compile time:
SafeSqlFragment from @supabase/pg-meta → executeSql (apps/studio/data/sql/execute-sql-mutation.ts)SafeLogSqlFragment from apps/studio/data/logs/safe-analytics-sql.ts → executeAnalyticsSql (apps/studio/data/logs/execute-analytics-sql.ts)@supabase/pg-meta)SafeSqlFragment: safe to execute (hardcoded via safeSql, sanitized via ident/literal/keyword, or user-authored via SafeSqlInput / acceptUntrustedSql). executeSql rejects plain string and UntrustedSqlFragment at compile time.WriteSqlFragment (asWriteSql): subtype of SafeSqlFragment propagated through safeSql and joinSqlFragments; executeSql requires a write grant (or Unguarded) to run it.UntrustedSqlFragment: externally influenceable SQL (URL params, LLM output, saved snippets), marked with untrustedSql(raw).DisplayableSqlFragment: union SafeSqlFragment | UntrustedSqlFragment — safe to display in the UI, not to execute.as SafeSqlFragment — even redundantly on a safeSql template literal (which already returns SafeSqlFragment). Assertions bypass provenance tracking; the sole narrow exception is promoting catalog definitions directly inside a data fetcher (below).Compose hardcoded SQL with safeSql and sanitize every dynamic value using @supabase/pg-meta helpers:
safeSql — tagged template accepting only SafeSqlFragment interpolationsident — sanitizes identifiers (schema, table, column names)literal — sanitizes literal valueskeyword — sanitizes SQL keywordsjoinSqlFragments (@supabase/pg-meta) & trimSafeSqlFragment (apps/studio/lib/sql.ts) — safe fragment manipulationimport { ident, literal, safeSql } from '@supabase/pg-meta'
// ✅ GOOD: hardcoded SQL + sanitized interpolations
const sql = safeSql`
SELECT *
FROM ${ident(userInputTableName)}
WHERE search_column = ${literal(userInputSearchString)}
`
Next to this one in the catalogue, plus more from the same author.