sqldef-on-rails

sqldef-on-rails is a skill for Claude Code from sorah/config. It costs 182 tokens per session (2,045 once invoked), scanned A, original, MIT.

A guide for managing a Ruby on Rails application's PostgreSQL database structure with psqldef instead of Rails migration files. The desired structure is written in SQL files, and psqldef compares it with the live database before applying changes.

In plain words
What is it for?
Use it when setting up this approach, changing tables, replacing the db/migrate directory, or reviewing a database change plan.
Why use it?
It gives the project a clear source of truth for its database structure and helps reveal risky changes, such as an accidental table or column drop.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: mentions CLAUDE.md.

Part of the sorah-guides plugin — 19 skills, 3 commands, 1 agent shipped together

Good fit Use it when setting up this approach, changing tables, replacing the db/migrate directory, or reviewing a database change plan.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/sorah/config/sqldef-on-rails
View source ↗ sorah/config
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 sorah/config --skill sqldef-on-rails
Clone the repo
git clone --depth 1 https://github.com/sorah/config

Made for: Claude Code.

Or install sorah-guides, the plugin that ships this one along with the rest of its 19 skills, 3 commands, 1 agent.

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 sqldef-on-rails

README.md
[![agentmods](https://agentmods.dev/badge/skills/sorah/config/sqldef-on-rails/github.svg)](https://agentmods.dev/skills/sorah/config/sqldef-on-rails)
Your own site
<a href="https://agentmods.dev/skills/sorah/config/sqldef-on-rails"><img src="https://agentmods.dev/badge/skills/sorah/config/sqldef-on-rails/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for sqldef-on-rails

Your own site · 80×15
<a href="https://agentmods.dev/skills/sorah/config/sqldef-on-rails"><img src="https://agentmods.dev/badge/skills/sorah/config/sqldef-on-rails.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 182 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,045 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. 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.00182 $0.02045
Opus 5.5 $0.00073 $0.00818
Sonnet 5.5 $0.00036 $0.00409
Haiku 4.5 $0.00018 $0.00204

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

Security

Grade A, and why

sqldef-on-rails scanned grade A with 1 finding 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

( cd /tmp/psqldef && curl -SsfLO "https://github.com/sqldef/sqldef/releases/download/v3.11.20/psqldef_linux_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" ) \
claude/marketplace/plugins/sorah-guides/skills/sqldef-on-rails/SKILL.md · 120 lines

How it starts

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

psqldef on Rails

Running a Rails app's PostgreSQL schema with psqldef instead of ActiveRecord migrations: the desired schema is a set of CREATE statements, and psqldef diffs it against the live database and applies the difference. Project-specific conventions (CLAUDE.md, docs/) always take priority.

For Aurora DSQL, read /sorah-guides:dsql-on-rails as well; it builds on this setup and replaces several tasks.

The model

  • The schema is db/schema/*.sql, one file per table, holding its CREATE TABLE, its indexes and its GRANTs. The rake task concatenates the files in sorted order and hands psqldef one desired schema.
  • There is no db/migrate/ and no schema.rb/structure.sql. The .sql files are the source of truth, and reviewers read the diff of the desired state, not a migration.
  • A schema change ships in the same commit as the code that uses it, never as a preparatory commit.
  • rake db:migrate applies the files; rake db:migrate:status shows the plan (--dry-run). Read the plan before applying anything that drops or rewrites.
  • psqldef only expresses the end state, plus rename hints. Renaming a table or column without the hint looks like drop-and-add, and a backfill does not exist in the file at all (see below).
-- db/schema/widgets.sql
create table widgets (
    id uuid primary key default gen_random_uuid(),
    owner_id uuid not null references owners (id),
    name varchar(64) not null,
    created_at timestamp(6) with time zone not null default now(),
    updated_at timestamp(6) with time zone not null default now()
);

create index idx_widgets_owner_id on widgets (owner_id);

grant all privileges on widgets to app_admin;
grant select, insert, update, delete on widgets to app_user;

Write a comment on a column whose meaning the name does not carry (an enum's values, an encoded payload). It is the only schema documentation there is.

Rake tasks

references/database.rake is a complete lib/tasks/database.rake for plain PostgreSQL; copy it and adjust. What it does:

Read the full file on GitHub · 120 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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 · 120 lines · 182 tokens per session scan A 2eeacc6941d9

Subscribe to this mod's changes

sqldef-on-rails is a skill published in the GitHub repository sorah/config (31 stars, last pushed yesterday), licensed MIT. It adds 182 tokens to every session and 2,045 once invoked, about $0.0007 per session on Opus 5.5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-10-21.

Related

Other skills, from other repositories

db-migration-mysql-postgres

Migrate a Ruby on Rails application's primary database from MySQL to PostgreSQL — schema upgrades (JSON to JSONB for queryability, ENUMs to native types or check constraints, TINYINT to BOOLEAN, case-sensitivity changes), data export/import via pgloader, the dual-write cutover pattern, the gem switch (mysql2/trilogy…

sandeepmvl/rails-skills · 127 tokens

azure-resource-manager-postgresql-dotnet

Azure PostgreSQL Flexible Server SDK for .NET. Database management for PostgreSQL Flexible Server deployments. Use for creating servers, databases, firewall rules, configurations, backups, and high availability. Triggers: "PostgreSQL", "PostgreSqlFlexibleServer", "PostgreSQL Flexible Server", "Azure Database for…

microsoft/skills · 97 tokens

jpa-patterns

JPA/Hibernate patterns and common pitfalls (N+1, lazy loading, transactions, queries). Use when user has JPA performance issues, LazyInitializationException, or asks about entity relationships and fetching strategies.

piomin/claude-ai-spring-boot · 47 tokens

ecto-patterns

Use when a task touches Ecto, even a how-to question: schemas, changesets, validations, queries, preloads, Multi, migrations, constraints, money fields. Load it before writing Ecto code. Skip for Ash.

oliver-kriska/claude-elixir-phoenix · 51 tokens

kysely

Guidelines for developing with Kysely, a type-safe TypeScript SQL query builder with autocompletion support.

Mindrally/skills · 26 tokens

sql-query-performance

Use when writing or changing a query against PostgreSQL from Go — avoiding N+1 loops, reading EXPLAIN output, indexing, and keyset pagination.

makifbaysal/tasktrooper · 35 tokens