/rails:migratefrom rails
This skill should be used when running Rails database migrations and committing the resulting schema changes. Ensures a clean schema diff by running migrations against the test database reset from main, not the potentially dirty development database. Activates on: "run migration", "run migrations", "migrate database", "commit migration", "db:migrate", "schema change", "clean schema diff", "migration workflow", "eseguire migrazione", "lanciare migrazione".
Ships in rails. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Run Rails database migrations with a clean schema diff by using the test database as the source of truth, avoiding dirty development database artifacts.
The development database schema (db/schema.rb) often drifts from main due to
experimental migrations, manual changes, or out-of-order branch switches. Running
db:migrate against development produces a noisy schema diff that includes
unrelated changes. This workflow uses the test database to produce a minimal,
correct schema diff containing only the migration's changes.
List migration files not yet committed or recently created:
git status db/migrate/
git diff --name-only main -- db/migrate/
If no pending migrations exist, inform the user and stop.
Restore db/schema.rb from main and rebuild the test database from scratch:
git restore --source=main --worktree db/schema.rb
RAILS_ENV=test bin/rails db:drop db:create db:schema:load
This ensures the test database matches the production schema before applying the new migration.
RAILS_ENV=test bin/rails db:migrate
Check that the schema diff contains only the expected changes:
git diff db/schema.rb
Verify:
version timestamp matches the new migrationIf the diff looks wrong, stop and report to the user.
If the migration uses change (reversible), verify it can be rolled back and
re-applied cleanly:
RAILS_ENV=test bin/rails db:migrate:redo
Then re-check the schema diff — it should be identical to Step 4:
git diff db/schema.rb
If the migration uses up/down explicitly, skip this step unless the user
requests it.
Stage and commit only the migration file(s) and db/schema.rb:
git add db/migrate/<migration_file> db/schema.rb
git commit -m "<message>"
Do not stage other files. The commit message should describe what the migration does (not that a migration was run).
Ask the user if they want to also run the migration in the development environment. If yes:
bin/rails db:migrate
Then discard any development-specific schema changes that differ from the already-committed clean schema:
git checkout db/schema.rb
This keeps the committed schema clean while ensuring the development database is up to date.
| Situation | Action |
|---|---|
| Test DB drop fails (connections) | Run RAILS_ENV=test bin/rails db:drop DISABLE_DATABASE_ENVIRONMENT_CHECK=1 |
| Schema load fails | Check for missing extensions or dependencies, report to user |
| Migration fails | Report the error, do not commit, leave test DB in failed state for debugging |
| Redo produces different diff | Migration is not cleanly reversible — warn the user |
| Unrelated schema changes appear | The main branch schema may have diverged — suggest rebasing first |
What SKILL.md sets; muted values are Claude Code's defaults
5 skills in this plugin
/debugrails:debugThis skill should be used when the user wants to debug performance issues,
investigate N+1 queries, analyze slow requests, profile memory usage, or
understand query patterns in a Ruby on Rails application.
Activates on: "debug performance", "N+1 queries", "slow request", "query analysis",
"memory profiling", "rails performance", "find slow queries", "bullet",
"why is this slow", "optimize queries", "eager loading", "database performance",
"debug rails", "profile request", "analizzare performance", "query lente".
/refactorrails:refactorThis skill should be used when the user wants to refactor Ruby on Rails code
by extracting service objects, concerns, query objects, form objects, or
DelegateClass wrappers. Identifies code smells and applies established Rails
refactoring patterns.
Activates on: "refactor", "extract service", "extract concern", "fat model",
"fat controller", "code smell", "service object", "query object", "form object",
"too complex", "simplify", "extract class", "single responsibility",
"rails refactor", "clean up code", "rifattorizzare", "estrarre servizio".
/testrails:testThis skill should be used when the user wants to write, scaffold, or improve
tests in a Ruby on Rails application. Covers RSpec organization, FactoryBot
patterns, request/model/service specs, VCR setup for HTTP stubbing, and
test-driven development workflows.
Activates on: "write tests", "add specs", "rspec", "factory bot", "test this",
"spec for", "scaffold test", "write spec", "missing tests", "test coverage",
"VCR cassette", "stub http", "testing strategy", "TDD", "test driven",
"rails test", "how to test", "scrivere test", "aggiungere spec".
/upgraderails:upgradeThis skill should be used when upgrading a Rails application from one minor
version to the next. Guides the full upgrade process: updating gems, running
app:update, booting the app, fixing deprecation warnings, running tests, and
progressively enabling new framework defaults. Enforces one minor version per
invocation following Rails' official recommendation.
Activates on: "upgrade rails", "upgrade to Rails", "rails upgrade",
"update rails version", "bump rails", "next rails version",
"rails version upgrade", "upgrade my rails app", "move to Rails",
"rails upgrade path", "aggiornare rails", "aggiornamento rails".
Other plugins' skills for the same job
npx claudepluginhub fabn/claude-plugins --plugin rails