check-drift

A command that compares a live Postgres database schema with the code and documents that describe it. A database schema defines tables, columns, relationships, and constraints.

In plain words
What is it for?
Use it after database migrations or before database-related edits to check ORM table definitions, query fields, schema documents, and the technology inventory.
Why use it?
It finds schema drift, meaning the database and its code or documentation no longer agree.

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/jonathanmr22/pact/check-drift
Clone the repo
git clone --depth 1 https://github.com/jonathanmr22/pact
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 611 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.00000 $0.00611
Opus 5 $0.00000 $0.00305
Sonnet 5 $0.00000 $0.00122
Haiku 4.5 $0.00000 $0.00061

Measured 2d ago against content hash 33854b338eb2, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

check-drift 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 2d ago.

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.

plugins/pact-schema-safety/commands/check-drift.md · 31 lines

What it actually says

Run schema drift detection — compare the live Postgres schema against ORM table definitions, backend function .select() calls, the schema doc, and the tech_stack inventory.

Run this PROACTIVELY when:

  • Last scripts/RUN_LOG.yaml entry for check_schema_drift.py is older than 7 days
  • About to edit any ORM table definition file
  • About to write or modify a backend function that queries the database
  • After a migration that touched DDL (apply_migration via MCP, manual ALTER, etc.)
  • The schema_verify checkpoint's <last_drift_check> field is stale

Steps:

  1. Run: python scripts/check_schema_drift.py

    • Defaults: regenerates the schema doc (path from pact-schema-safety.config.yaml or default), writes/updates a bug file in bugs/schema/ if drift detected, appends to scripts/RUN_LOG.yaml, updates .claude/memory/PENDING_WORK.yaml § schema_drift_detected when criticals exist.
    • Add --no-cache to force a live fetch (skips the 12-hour cache).
    • Add --no-doc to skip doc regeneration (use for quick checks).
    • Add --no-bug to skip bug file write (use for dry runs).
    • Add --quiet to suppress non-drift output.
    • Add --json to emit a machine-readable summary.
  2. Read the resulting bug file (if any) at bugs/schema/schema-drift-{date}.yaml. Each diffs[] entry has:

    • severity (critical | warning | high), kind, source, table, column, expected, actual, location, suggested_fix
    • Apply each suggested_fix per diff. Critical drift in source: drift → rename ORM column or its alias. Critical drift in source: ef → fix the .select(...) string + redeploy. Critical fk_target_drift → fix the .references() target.
  3. After applying fixes, rerun /check-drift to confirm the bug file count drops to zero, then mark the bug file status: resolved with the commit hash.

  4. If a diff is intentional/acceptable (deprecated column being phased out, ORM-only local table with no DB counterpart), add it to scripts/.schema_drift_ignore.yaml with a reason and added date.

Reads: live Postgres schema via SCHEMA_SAFETY_DB_URL (or DATABASE_URL) env var. Writes: schema doc (regenerated), bugs/schema/*.yaml, scripts/RUN_LOG.yaml, scripts/.cache/live_schema_*.json, .claude/memory/PENDING_WORK.yaml.

Reference: plugins/pact-schema-safety/README.md for installation + configuration + adapting to other stacks.

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. 2d ago First seen · 31 lines · 0 tokens per session scan A 33854b338eb2

Subscribe to this mod's changes

check-drift is a command published in the GitHub repository jonathanmr22/pact (15 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 611 tokens. 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-30.