safe-sql-execution
Skill by supabase
Sets safe SQL execution rules for code that runs SQL against a user's Postgres database in Supabase Studio. It is aimed at developers who build query builders, endpoints or Run actions that handle external input.
Install safe-sql-execution
Built from the published package, never by AI.
git clone --depth 1 https://github.com/supabase/supabase /tmp/supabase && mkdir -p ~/.claude/skills && cp -r /tmp/supabase/.agents/skills/safe-sql-execution ~/.claude/skills/safe-sql-executionRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
git clone --depth 1 https://github.com/supabase/supabase /tmp/supabase && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/supabase/.agents/skills/safe-sql-execution ~/.gemini/antigravity-cli/skills/safe-sql-executionAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Skills can run scripts on your machine. Some need an API key: check the README.
About
The safe-sql-execution skill gives rules for writing SQL that runs against a user's real Postgres database in Supabase Studio. It should be loaded before code builds, returns, fetches or executes SQL, not only when reviewing a finished diff. It covers pg-meta query builders, endpoints that build SQL for tables, views, functions, triggers, indexes and RLS policies, and Run or Apply actions in the SQL editor, policy editor and snippet runner.
The skill describes a model called proven authorship. Users may run SQL they authored or that is hardcoded in the app. SQL influenced by external input, such as URL params, LLM output or auto-saved snippets, must be sanitized or run only after an explicit user action. Postgres and analytics SQL use separate branded types that are checked at compile time. The skill also covers analytics queries sent to Logs endpoints. It is written for developers working on Supabase Studio code.
Written from the project's SKILL.md and checked against it.
What it can do
- Postgres SQL fragment rulesExplains SafeSqlFragment, WriteSqlFragment and UntrustedSqlFragment and how executeSql treats each one.
- Safe fragment buildingShows how to compose hardcoded SQL with safeSql and sanitize values with ident, literal and keyword.
- User input handlingDescribes using SafeSqlInput for user-authored SQL instead of a raw input field.
- Round-tripped SQL handlingExplains when catalog definitions may be promoted and why user snippets are always treated as unsafe.
- Explicit run promotionShows using acceptUntrustedSql only inside a click handler, never in useQuery or useEffect.
- Analytics SQL helpersLists safeSql, analyticsLiteral, quotedIdent, keyword and joinSqlFragments for Logs queries.
- Analytics execution boundaryExplains that executeAnalyticsSql accepts only SafeLogSqlFragment values.
- Untrusted editor SQLDescribes marking editor text with untrustedLogSql and promoting it only from a Run gesture or approved AI tool call.
Try asking
- Write a pg-meta query that safely filters a table chosen by the user.
- Review my snippet runner so saved SQL only runs after a Run click.
- Build an analytics Logs query with sanitized table and id values.
Good to know
- Snippet SQL is always unsafe and must never run automatically.
- The ESLint rule does not catch indirect calls through logsAllEndpointUrl, so always route through executeAnalyticsSql.
- Casting values as SafeSqlFragment or SafeLogSqlFragment bypasses provenance tracking and is not allowed.
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: .agents/skills/safe-sql-execution/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
Inside the skill
-
SKILL.md10 KB
Alternatives to safe-sql-execution
All alternatives →Creates, configures and manages datasets on the Hugging Face Hub, including SQL-based querying and transformation. Built for people who edit dataset content and metadata directly, alongside the HF MCP server.
Diagnoses and repairs gbrain's Postgres access when a command or MCP result shows a GBRAIN_DB_ACCESS marker, or when the operator reports the brain database is down. It runs the hardcoded gbrain db-repair ladder and verifies the result with a re-probe.
Manages clusters, instances, and backups for AlloyDB for PostgreSQL. Built for creating, configuring, and administering AlloyDB databases, not general PostgreSQL or Cloud SQL instances.
Writes, reviews and migrates Supabase logs queries against the ClickHouse logs table served by the logs.all.otel endpoint. Built for developers who write Logs Explorer SQL or convert older BigQuery logs queries.
Diagnoses and fixes slow Paperclip PostgreSQL queries using Cloud and Neon evidence, local benchmarks, regression tests, and a pull request with passing checks. Built for engineers working on Paperclip.
Guides AI assistants through Prisma 8 projects built on @prisma/orm-postgres, @prisma/orm-sqlite, or @prisma/orm-mongo. It covers data contracts, migrations, typed queries and runtime setup for developers on Prisma 8.
Compare with hugging-face-datasets, db-repair or alloydb-basics
safe-sql-execution: common questions
When should I load the safe-sql-execution skill?
Load it before writing or editing code that builds, returns, fetches or executes SQL against a user's Postgres database. The source says this applies even when a task does not mention security or injection.
What is the difference between Postgres and analytics SQL rules here?
Postgres SQL uses SafeSqlFragment from pg-meta and runs through executeSql. Analytics SQL uses SafeLogSqlFragment and runs through executeAnalyticsSql, because the escape rules differ.
Can user snippets run automatically?
No. The source says snippets are auto-persisted and externally influenceable, so they must never be auto-run and must only be promoted from an explicit user action.
How do I install safe-sql-execution?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is safe-sql-execution free?
The code is published under the Apache-2.0 licence. The service it connects to may have its own pricing.
Is safe-sql-execution safe to use?
It scores 91 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to safe-sql-execution?
Similar skills: hugging-face-datasets, db-repair, alloydb-basics, clickhouse-logs-queries.
