schema-gate

A database migration review command that performs static checks and read-only live-database checks. A migration is a scripted change to a database’s tables, columns, or indexes.

In plain words
What is it for?
Use it to review pending SQL migration files and receive a pass-or-fail result, with cached results for unchanged files.
Why use it?
It catches risky changes such as dropped data structures, unsafe renames, missing row-level security, oversized indexes, and compatibility problems before release.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/rajconnects/founder-stack/schema-gate
Clone the repo
git clone --depth 1 https://github.com/rajconnects/founder-stack
Per session 51 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 850 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00051 $0.00850
Opus 5 $0.00026 $0.00425
Sonnet 5 $0.00010 $0.00170
Haiku 4.5 $0.00005 $0.00085

Measured yesterday against content hash d7cc01aad6fd, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

schema-gate scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

workflow/commands/schema-gate.md · 40 lines

How it starts

The opening of the file, as written. The whole thing — 40 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are running the schema gate.

Arguments: $ARGUMENTS

Steps

  1. Resolve files. If $ARGUMENTS is empty or auto, read migrations from .claude/project.json and pick files in that dir modified within the last hour. Otherwise use the path/glob given. If none found: fail loudly.

  2. Cache check. For each migration file, compute sha256sum. If .claude/.schema-gate-cache/<sha>.md exists, print it, refresh .claude/.schema-gate-passed, and stop. Re-running the gate on unchanged files must not invoke the agent.

  3. Static pre-pass (deterministic, free). Run workflow/hooks/schema-static-scan.sh <file>.... If it exits non-zero, print its findings, remove .claude/.schema-gate-passed, and stop — these are unambiguous FAILs the agent cannot rescue.

  4. Resolve config and parse migration shape. Read .claude/project.json once. Extract stack.supabase_project_ref and migrations. Then parse the migration SQL to extract:

    • new_tablesCREATE TABLE [IF NOT EXISTS] <name> matches.
    • new_columnsALTER TABLE <t> ADD COLUMN <c> matches.
    • new_indexesCREATE [UNIQUE] INDEX [CONCURRENTLY] <n> ON <t> matches; record whether CONCURRENTLY is present. If the migration has none of these (e.g. function-only DDL), skip step 5 and emit verdict: PASS — no schema surface to audit.
  5. Launch schema-analyst with a self-contained prompt containing: the migration file paths, supabase_project_ref, the parsed new_tables / new_columns / new_indexes, and (if --notes <path> was passed) the evolution-notes path. Do NOT ask the agent to re-read project.json.

  6. Optional advisors pass. If --with-advisors was passed AND the agent returned verdict: PASS, call mcp__claude_ai_Supabase__get_advisors once from this slash command and append a one-line summary. Do not run advisors by default — they are project-wide and noisy.

  7. Cache and mark. Save the agent output to .claude/.schema-gate-cache/<sha>.md. On PASS, touch .claude/.schema-gate-passed. On FAIL, rm -f .claude/.schema-gate-passed.

  8. Print. On PASS, print one line: schema-gate: PASS — <N> tables, <M> columns, <K> indexes audited. On FAIL or PASS_WITH_WARNINGS, print the agent's terse output verbatim.

  9. Session hygiene hint (PASS only). Append one line: If the next task is unrelated to this migration, consider a session reset (in Claude Code: /clear). See docs/session-hygiene.md. Do not print on FAIL — the failure context is what the user needs to diagnose.

Read the full file on GitHub · 40 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 40 lines · 51 tokens per session scan A d7cc01aad6fd

Subscribe to this mod's changes

schema-gate is a command published in the GitHub repository rajconnects/founder-stack (2 stars, last pushed 1mo ago), licensed MIT. It adds 51 tokens to every session and 850 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.