spec-sql-harness
Skill1 starsChanged 25 days agoBSD-3-ClauseView on GitHub
Proves SQL from design documents such as SCHEMA.md by loading it into the production Postgres image with smoke tests. Use when a spec repository defines a database in Markdown, or when a schema, migration, RLS policy or grant changes. Also use when asked whether the schema actually works.
- Reads credentials
In this repository52 other files it gives its agents.
- academic-research-assistantSkill
- answer-sheetSkill
- app-graphicsSkill
- app-landing-pageSkill
- app-screenshotsSkill
- break-uiSkill
- consumer-app-from-behaviorSkill
- cross-language-safetySkill
- dart-tool-scriptsSkill
- decision-sweepSkill
- engineering-diarySkill
- figma-review-loopSkill
- flutter-app-size-auditSkill
- flutter-async-at-the-edgeSkill
- flutter-async-cubit-safetySkill
- flutter-bloc-clean-architectureSkill
- flutter-clean-architecture-tddSkill
- flutter-cubit-smart-cachingSkill
- flutter-error-logging-conventionsSkill
- flutter-observability-instrumentationSkill
- flutter-paywall-and-review-timingSkill
- flutter-precommit-cleanupSkill
- flutter-router-decisionSkill
- flutter-runtime-safetySkill
- flutter-shorebird-otaSkill
- flutter-stream-architectureSkill
- flutter-strict-analysisSkill
- flutter-web-first-paintSkill
- forced-pivot-15-daySkill
- gplay-consoleSkill
- ios-distribution-feature-flagsSkill
- launch-readinessSkill
- launch-watchSkill
- locale-expert-reviewSkill
- market-pulseSkill
- mobile-ui-referenceSkill
- moscow-prioritizationSkill
- orchestrate-agentic-engineeringSkill
- parallel-agent-inboxSkill
- paywall-conversion-flowSkill
- paywall-transparencySkill
- proactive-crash-repair-loopSkill
- promise-auditSkill
- pr-preview-shippingSkill
- ship-first-dollar-appSkill
- slim-ios-simulator-fleetSkill
- store-launch-mastermindSkill
- sync-contextSkill
- task-blitzSkill
- techdebtSkill
- vendor-decisionSkill
- web-interface-reviewSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 60
Add suites as smoke/01.sql, smoke/02.sql, and so on.
- Very specific: line 74
Test the privacy promises directly: what another user can see, what deletion removes, and what the retention jobs purge (see promise-audit).
- Distinctive: line 76
Add a check for every bug you fix and every rule the decision-maker calls critical, so the regression cannot come back silently.
- Very specific: line 80
Run both bash tools/schema-test/run.sh and bash tools/schema-test/run.sh nodefaults after any schema change and before committing.
- Distinctive: line 84
Check for free disk space first, because a failed write looks like a schema failure.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Spec SQL harness
SQL in a design document is untested code. Loading it into the real database image and running the calls the app will make finds real bugs before any app exists. Typical classes of bug this finds:
- a function that reads a dropped column
- an index predicate using
now(), which Postgres rejects - a function that crashes on an empty input
- an RPC (database function the app calls) returning null where the app expects a row
- a privacy hole where a query returns another user's private field
The harness lives in the repository.
A harness kept in /tmp loses its checks between runs.
Remote code gate
Remote code gate. This step runs code fetched at run time.
Each time, download the exact version into an empty directory without running it, have a separate reviewer agent (the code-gate subagent where it exists) read its source, and run it only if the reviewer returns SAFE, from those reviewed files, never from a fresh download.
On UNSAFE or UNSURE, do not run it and tell the user why.
Covers:
docker runof thePG_IMAGEcontainer image inscripts/run.sh. Record the image digest as well as the tag, and review the image source before the first run and after any change of version.
Files
scripts/run.shextracts the SQL, starts a fresh container, loads stubs, the schema, and everysmoke/*.sqlin name order, printspassed/totalper suite, and exits non-zero on any failure.bash run.sh nodefaultsdoes the same after revoking the platform's default grants.scripts/extract_sql.pyprints every fenced block tagged exactlysqlfrom the given Markdown files. Tag illustrative snippets that must not run assql-example.references/smoke-template.sqlis the suite format: one row per check, holding a sentence and a boolean.references/supabase-stubs.sqlstands in for what Supabase's services create on a real project:auth.jwt(),auth.sessions,realtime.messages,realtime.send, andstorage.bucketsandobjects.references/supabase-nodefaults.sqlsimulates projects without default grants toanonandauthenticated.
Set up in a repository
- Create
tools/schema-test/. Copyrun.shandextract_sql.pyinto it, and add.schema.sqlto a.gitignorethere. Write
tools/schema-test/harness.env:SPEC_FILES="SCHEMA.md" # Markdown files with the SQL, in load order, relative to REPO_ROOT REPO_ROOT=../.. PG_IMAGE=supabase/postgres:<version> # pin the exact image and version production runs PG_ADMIN=supabase_admin # postgres for a plain Postgres image CONTAINER=myapp-schema-test- For Supabase, copy both reference SQL files in as
stubs.sqlandnodefaults.sql. For another platform, write stubs for whatever it provides outside the schema. - Add suites as
smoke/01.sql,smoke/02.sql, and so on. They run in one database in name order, so later suites may use earlier rows, and each suite's header says which it depends on. - Record the command in the project's
AGENTS.mdnext to the other checks.
Writing checks
- Name each check as a sentence about behaviour:
'07 a user cannot read another user's private row'. - Act as each role the app uses.
With Supabase that means
set role authenticatedwithrequest.jwt.claimsset,set role anon, and the service role for server paths. - For every table and function, test that the right role can, the wrong role cannot, and that server-only functions are closed to the app, with
has_function_privilege. On Supabase any role, includinganon, can execute a function by default, so checkanonas well asauthenticated. - For every column that grants access or money, such as an entitlement flag, a credit balance or a usage limit, test that
authenticatedcannot update it on its own row:'12 a user cannot set their own is_premium'. RLS restricts rows, not columns, so an owner UPDATE policy alone leaves every column of the owner's row writable. This check only proves something in the default-grants run, because undernodefaultsit passes trivially. - Test the privacy promises directly: what another user can see, what deletion removes, and what the retention jobs purge (see
promise-audit). - Wrap checks on queued side effects, such as pg_net or job queues, in one transaction, so a background worker cannot drain the queue before the check reads it.
- Add a check for every bug you fix and every rule the decision-maker calls critical, so the regression cannot come back silently.
Run it
- Run both
bash tools/schema-test/run.shandbash tools/schema-test/run.sh nodefaultsafter any schema change and before committing. Report the totals. KEEP=1leaves the container running for inspection.- It needs Docker and a few GB of disk. Check for free disk space first, because a failed write looks like a schema failure.
Platform notes
- Supabase planned to stop default grants to
anonandauthenticatedinpublicfor projects created after 30 Oct 2026, and legacy anon keys retire at the end of 2026. Re-check both on Supabase's changelog before relying on these dates. Grant explicitly in the schema, and keep thenodefaultsrun green. - Declare every extension the schema uses, such as
pg_net,pgcrypto, orpg_cron. The image may ship with it enabled while a fresh project does not. - Postgres rejects functions that are not immutable, such as
now(), in partial-index predicates.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

