db-referential-integrity

db-referential-integrity is a skill for Claude Code from Hainrixz/claude-db. It costs 75 tokens per session (1,065 once invoked), scanned A, original, MIT.

A database review module for checking foreign-key integrity in relational databases. Foreign keys make sure that a reference, such as an order’s customer ID, points to a real row and does not become an orphan.

In plain words
What is it for?
Auditing missing foreign keys, ON DELETE and ON UPDATE actions, foreign-key cycles, and composite foreign keys, with extra severity for financial and authentication data.
Why use it?
It finds missing or unsafe database relationships, deletion rules, circular references, and mismatched multi-column references before they cause inconsistent data or migration problems.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the claude-db plugin — 36 skills, 6 agents, 1 hook shipped together

Good fit Auditing missing foreign keys, ON DELETE and ON UPDATE actions, foreign-key cycles, and composite foreign keys, with extra severity for financial and authentication data.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/hainrixz/claude-db/db-referential-integrity
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.

Any agent
npx skills add Hainrixz/claude-db --skill db-referential-integrity
Clone the repo
git clone --depth 1 https://github.com/Hainrixz/claude-db

Made for: Claude Code.

Or install claude-db, the plugin that ships this one along with the rest of its 36 skills, 6 agents, 1 hook.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for db-referential-integrity

README.md
[![agentmods](https://agentmods.dev/badge/skills/hainrixz/claude-db/db-referential-integrity.svg)](https://agentmods.dev/skills/hainrixz/claude-db/db-referential-integrity)
Your own site
<a href="https://agentmods.dev/skills/hainrixz/claude-db/db-referential-integrity"><img src="https://agentmods.dev/badge/skills/hainrixz/claude-db/db-referential-integrity.svg" alt="Measured on agentmods" height="20"></a>
Per session 75 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,065 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00075 $0.01065
Opus 5 $0.00037 $0.00532
Sonnet 5 $0.00015 $0.00213
Haiku 4.5 $0.00007 $0.00106

Measured 7d ago against content hash 7c6f5efa2b48, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

db-referential-integrity 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 7d 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.

skills/db-referential-integrity/SKILL.md · 54 lines

How it starts

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

db-referential-integrity (M3)

Foreign keys are the database enforcing that a reference points at something real — the cheapest, most durable guarantee against orphan data. Missing them pushes integrity into application code, where it silently rots. This module is both-axis: integrity on design, and join/planning behaviour on performance. It applies to FK-supporting relational engines only; the document/KV profiles drop it entirely (no false penalty).

What it checks

  • Missing FK: a column named/typed as a reference (*_id matching another table's PK) with no FOREIGN KEY constraint. On financial or auth tables (orders, payments, sessions, memberships) an orphan-enabling missing FK is the severity-5 cap case.
  • ON DELETE / ON UPDATE action: FK with no explicit referential action where the default (NO ACTION/RESTRICT) is wrong for the relationship, or a dangerous CASCADE that can mass-delete (e.g. deleting a user cascades to invoices). Each action must be intentional.
  • Reference cycles: FK cycles (A→B→C→A) that block ordered insert/delete and complicate migrations — severity 4.
  • Composite FK mismatch: multi-column FK whose column set/order does not match the referenced unique key, or partial composite references.
  • Untrusted/NOT VALID FK left unvalidated after a backfill (Postgres NOT VALID).

Axis & severity

  • Missing FK enabling orphan financial/auth rows: severity 5, fail, axis both, confidence established (caps).
  • FK cycle: severity 4, warn, axis both.
  • Missing/over-broad ON DELETE (silent RESTRICT blocking, or unintended CASCADE): severity 3–4, warn, axis design.
  • Composite-FK order mismatch: severity 3, warn.
  • Note: FK columns lacking a supporting index are owned by M11 (indexing), not here — cross-reference, do not double-count.

Tier-0 static check

Parse DDL via scripts/parse-schema.mjs: for each *_id-style column, check whether a matching FOREIGN KEY/REFERENCES clause exists; enumerate declared FKs and flag those without an explicit ON DELETE/ON UPDATE action; build the FK graph and detect cycles. Directional ORM-source parses never raise the sev-5 orphan cap.

Read the full file on GitHub · 54 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. 7d ago First seen · 54 lines · 75 tokens per session scan A 7c6f5efa2b48

Subscribe to this mod's changes

db-referential-integrity is a skill published in the GitHub repository Hainrixz/claude-db (19 stars, last pushed 2mo ago), licensed MIT. It adds 75 tokens to every session and 1,065 once invoked, about $0.0004 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-30.

Related

Other skills, from other repositories

malloy-lookml-review

Analyze LookML files as prior art for Malloy modeling. Used during Step 1 (DISCOVER) when .lkml files are present. Coordinates reference files that extract business logic, relationships, and curation decisions. Works with or without a database connection.

malloydata/publisher · 58 tokens

review-prs

Review a GitHub pull request in the googleapis/mcp-toolbox repo against the team's reviewer checklist: PR title/description conventions, linked issue, logic errors and unhandled edge cases, breaking changes, test coverage, docs updates, security (input handling), and new dependencies. Use whenever a maintainer asks…

googleapis/mcp-toolbox · 162 tokens

migration-review

Review database migration files when a change adds or modifies paths under migrations/. Use it before merge to collect forward, rollback, locking, and data-safety evidence.

rohitg00/ai-engineering-from-scratch · 35 tokens

malloy-review

Malloy semantic-model code review. Invoke when the user asks to review, audit, or critique a .malloy file, a folder of Malloy models, or a GitHub PR that touches Malloy. Enforces project modeling standards and emits a navigable review file.

malloydata/publisher · 60 tokens

migration-ready-schema

Data-model rules that make a schema importable from day one, so the migration-import-engineer is never blocked on missing columns. Every SMB Product-Builder product must let a customer bring their data from an incumbent (ServiceTitan/Toast/Mindbody/Shopify) — that requires provenance (sourceref) and rollback…

avelikiy/great_cto · 133 tokens

dynamodb

Use when modeling or operating a DynamoDB table: deriving partition/sort keys from access patterns, single-table vs table-per-entity, adding a GSI/LSI, on-demand vs provisioned capacity, or diagnosing hot-partition throttling. NOT relational schema/SQL/EXPLAIN (that is postgresdb), NOT aggregation-pipeline document…

ericrisco/rsc-harness · 82 tokens