schema-drift-detector

Detect unrelated db/schema.rb changes by cross-referencing schema diffs with PR migrations.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/xbpk3t/ce-codex --skill schema-drift-detector-xbpk3t
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: schema-drift-detector
Source: https://github.com/xbpk3t/ce-codex/tree/main/skills/schema-drift-detector
Command: npx skills add https://github.com/xbpk3t/ce-codex --skill schema-drift-detector-xbpk3t

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Prevents accidental inclusion of unrelated db/schema.rb changes in pull requests by cross-referencing schema diffs against the migrations actually changed in the PR, reducing noisy diffs and merge conflicts.

Core Features & Use Cases

  • Identify PR migrations: Enumerates migration files changed in the PR and extracts migration timestamps for comparison.
  • Analyze schema diffs: Compares db/schema.rb changes against the PR base branch to surface version mismatches and new tables, columns, or indexes.
  • Cross-reference and report drift: Flags schema additions that lack corresponding create_table/add_column/add_index entries in PR migrations and produces actionable remediation steps.
  • Use Case: Run during Rails PR review to ensure schema.rb only contains changes introduced by the PR's migrations, preventing inadvertent carryover from other branches.

Quick Start

Compare the PR's db/schema.rb to the PR base and verify every added table, column, and index is introduced by a migration included in the PR.

Frequently Asked Questions about schema-drift-detector

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent unrelated schema.rb changes from showing up in a Rails pull request?

Prevent unrelated schema.rb changes by cross-referencing db/schema.rb diffs against the migrations actually included in the PR. This verifies every added table, column, and index originates from a corresponding PR migration file.

Why does my Rails PR include schema drift when I only modified one migration?

Schema drift occurs when db/schema.rb carries over changes from other branches. Comparing the PR's schema diffs against the resolved base branch identifies version mismatches and flags schema additions lacking corresponding PR migrations.

How do I check if a Rails migration timestamp matches the schema.rb version in a feature branch?

Check migration timestamps by enumerating changed migration files in the PR and comparing them against the schema.rb version diff. This surfaces version mismatches between the expected migration version and the committed schema state.

Can I validate db/migrate and schema.rb correspondence during automated code review?

Yes, you can validate migration and schema correspondence during code review by diffing db/migrate and db/schema.rb against the PR base branch. This requires repository git access and the resolved base branch reference to verify migration accuracy.

What is the best way to catch accidental schema.rb carryover in Rails hotfix branches?

The best way to catch accidental schema.rb carryover is to run schema drift detection during hotfix PR review. It cross-references schema additions with included migrations and produces actionable remediation steps for unrelated changes.