Skip to content
Skill

Sqldef on rails

Guides a Rails app to manage its PostgreSQL schema as SQL files with psqldef

Sqldef on rails is an open-source agent skill for databases. It is available on Claude Code.

Scripts
None
Platforms
Claude Code
GitHub stars
31
Last commit
License
MIT
Listing updated

Similar skills

About Sqldef on rails

This skill sets up and maintains a Rails application whose PostgreSQL schema is described as declarative SQL files in db/schema instead of ActiveRecord migrations. The agent is shown the file layout, one file per table holding its create statement, indexes and grants, and how the rake tasks concatenate these files and hand them to psqldef to diff against the live database.

It covers the rake task setup that replaces the standard migration and schema dump tasks, including guarding drops behind an explicit flag, limiting grants to what is declared, and connection handling. It also explains how to express renames with psqldef annotations, when to run statements before the diff is applied, how to backfill data outside the schema files, and how to pin and install psqldef in mise and Docker builds.

The guidance also addresses deployment ordering and CI, such as applying the schema before new code serves traffic and posting dry-run plans on pull requests. It expects a Rails app on PostgreSQL, the psqldef command-line tool, and project conventions documented in the repository, which take priority over the skill's defaults.

When your agent uses it

This skill should be used when a Rails app manages its PostgreSQL schema declaratively with psqldef (sqldef) instead of ActiveRecord migrations, or when setting that up, changing a table, or replacing `db/migrate`. Signs include `db/schema/*.sql`, a `psqldef` call in a rake file, `BEFORE_APPLY_SQL`, `ENABLE_DROP`, no `db/migrate` directory or `schema.rb`, or the user mentioning "sqldef", "psqldef", "declarative schema", "schema as SQL", or "drop Rails migrations", even if they only say "add a column" in such an app. Provides the schema file layout, the rake tasks that replace migrations, psqldef configuration, non-declarative changes, and installation. Project-specific conventions always take priority.

From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.

What it can access

From a static check of its 2 files (11 KB) on GitHub on 4 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.

Check another skill before you install it.

Install

This skill ships in the sorah-guides plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

/plugin marketplace add sorah/config
/plugin install sorah-guides@sorah-marketplace

Or copy only this skill to ~/.claude/skills/sqldef-on-rails:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/sorah/config.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/sqldef-on-rails &&
cp -R "$tmp/claude/marketplace/plugins/sorah-guides/skills/sqldef-on-rails" ~/.claude/skills/sqldef-on-rails &&
rm -rf "$tmp"

For one project only, put the folder in .claude/skills/sqldef-on-rails inside it instead.

Claude Code docs on skills

Copy the skill folder to ~/.agents/skills/sqldef-on-rails to use it in every repository:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/sorah/config.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/sqldef-on-rails &&
cp -R "$tmp/claude/marketplace/plugins/sorah-guides/skills/sqldef-on-rails" ~/.agents/skills/sqldef-on-rails &&
rm -rf "$tmp"

For one repository only, put the folder in .agents/skills/sqldef-on-rails inside it instead.

Codex docs on skills

Copy the skill folder to ~/.cursor/skills/sqldef-on-rails to use it in every project:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/sorah/config.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/sqldef-on-rails &&
cp -R "$tmp/claude/marketplace/plugins/sorah-guides/skills/sqldef-on-rails" ~/.cursor/skills/sqldef-on-rails &&
rm -rf "$tmp"

For one project only, put the folder in .cursor/skills/sqldef-on-rails inside it instead.

Cursor docs on skills

Run in a terminal (add --scope workspace to install it for the current workspace only):

gemini skills install https://github.com/sorah/config.git --path claude/marketplace/plugins/sorah-guides/skills/sqldef-on-rails

Or copy the folder to ~/.gemini/skills/sqldef-on-rails yourself.

Gemini CLI docs on skills

For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/sqldef-on-rails:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/sorah/config.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/sqldef-on-rails &&
cp -R "$tmp/claude/marketplace/plugins/sorah-guides/skills/sqldef-on-rails" ~/.copilot/skills/sqldef-on-rails &&
rm -rf "$tmp"

For one project only, put the folder in .github/skills/sqldef-on-rails inside it instead.

VS Code docs on skills

Get the folder:

git clone --depth 1 https://github.com/sorah/config.git

Then copy config/claude/marketplace/plugins/sorah-guides/skills/sqldef-on-rails into your agent's skills folder as sqldef-on-rails. Agents that support SKILL.md read one folder per skill.

The SKILL.md format

What it does

Declarative schema layout
Organizes each table's definition, indexes and grants into its own SQL file under db/schema.
Replacement rake tasks
Supplies a database rake file that swaps Rails migration and schema dump tasks for psqldef runs.
Guarded destructive changes
Skips drops unless explicitly enabled, so reviewers can read the dry-run plan first.
Rename and pre-apply statements
Shows psqldef rename annotations and how to run extra SQL before a diff is applied.
Deployment and CI ordering
Describes backward-compatible rollouts, pre-deploy schema application and dry-run checks in CI.
psqldef installation pinning
Covers pinning the psqldef version in mise and verifying release checksums in Docker builds.

Good for

  • Replace ActiveRecord migrations with declarative SQL schema files in a Rails app
  • Add a column to a table defined in db/schema
  • Rename a table or column without losing data using psqldef
  • Set up psqldef in a Rails project's mise and Docker configuration
  • Preview schema changes with a dry run before deploying

Sqldef on rails FAQ

When does Sqldef on rails trigger?

It triggers when a Rails app manages its PostgreSQL schema with psqldef instead of migrations, such as when files appear under db/schema, when psqldef or sqldef is mentioned, or when a column is added in such an app.

Does Sqldef on rails drop tables automatically?

No. Drops are skipped unless ENABLE_DROP=1 is passed, and the skill recommends reading the dry-run plan before applying.

Does psqldef revoke permissions removed from the files?

No. Grants only widen, so narrowing a grant needs a manual REVOKE, which can be run through BEFORE_APPLY_SQL.

Which project rules take precedence?

Project-specific conventions in files such as CLAUDE.md or docs always take priority over the skill's guidance.

How do I install Sqldef on rails in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/sqldef-on-rails to use it in all your projects, or to .claude/skills/sqldef-on-rails in one project. Or install the sorah-guides plugin, which includes it: /plugin marketplace add sorah/config, then /plugin install sorah-guides@sorah-marketplace.

Does Sqldef on rails run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

Which AI agents can use Sqldef on rails?

Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.

What are the best alternatives to Sqldef on rails?

The closest alternatives to Sqldef on rails are Dsql on rails, Database migrations, Database migrations, Postgres database migration and Postgres.

Where this comes from

  • Description: from the skill's own SKILL.md.

More from sorah/config

  1. Guides an agent through maintaining sorah's aptly-managed APT repositories and their

    • Open source
    • 31 GitHub stars
    • Cloud and infrastructure
  2. Runs a chief-of-staff session that watches your coding agents and keeps work on track

    • Open source
    • 31 GitHub stars
    • Developer tools
  3. Applies language-agnostic coding conventions to code writing and review

    • Open source
    • 31 GitHub stars
    • Developer tools
  4. Guides the agent to write git commit messages and PR titles in a concise house style

    • Open source
    • 31 GitHub stars
    • Developer tools
  5. Guides an agent through building and testing Rails apps on Aurora DSQL

    • Open source
    • 31 GitHub stars
    • Developer tools
  6. Writes English text in the author's terse, direct technical voice for GitHub and email

    • Open source
    • 31 GitHub stars
    • Developer tools