rails-models

Review ActiveRecord models and migrations for Rails conventions and best practices.

14|Updated Dec 16, 2025
One-click install
npx skills add https://github.com/Shoebtamboli/rails_claude_skills --skill rails-models-shoebtamboli
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rails-models
Source: https://github.com/Shoebtamboli/rails_claude_skills/tree/main/lib/generators/claude/skills_library/rails-models
Command: npx skills add https://github.com/Shoebtamboli/rails_claude_skills --skill rails-models-shoebtamboli

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides concise, actionable guidance to design, validate, migrate, and maintain ActiveRecord models so developers avoid common pitfalls like missing constraints, N+1 queries, and fragile callbacks.

Core Features & Use Cases

  • Model generation patterns and migration advice for schema design and indexes.
  • Validation, association, callback, scope, enum, and concern best practices with real-world examples.
  • Use Case: Review a User model to add necessary validations, optimize associations, add indexes, and suggest safer callback or service extraction strategies.

Quick Start

Use the rails-models skill to review a model file and recommend validations, associations, and migration changes to improve correctness and performance.

Frequently Asked Questions about rails-models

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

FAQPage Schema
How do I design ActiveRecord models and migrations to avoid N+1 queries and missing database constraints?

Designing robust ActiveRecord models requires adding necessary database constraints, indexes, and optimized associations during migrations. Following Rails conventions prevents common pitfalls like N+1 queries and fragile callbacks.

What are the best practices for ActiveRecord validations, associations, and callbacks in Rails?

ActiveRecord best practices include using real-world examples for validations, associations, scopes, and enums. For callbacks, it is recommended to use safer callback strategies or extract logic into service objects to maintain model robustness.

When do I need database indexes and migration changes for my Ruby on Rails models?

You need database indexes and migration changes when reviewing a model to improve correctness and performance. Adding indexes and constraints ensures efficient query patterns and maintains data integrity at the database level.

How do I refactor ActiveRecord models to follow Rails conventions and common best practices?

Refactoring ActiveRecord models involves reviewing validations, associations, and callbacks to align with Rails conventions. It includes recommending model refactors and safer callback strategies or extracting logic into dedicated service objects.

Can I use ActiveRecord scopes and enums to improve query patterns in Ruby on Rails?

Yes, you can use ActiveRecord scopes and enums to encapsulate query logic and improve query patterns. Applying these best practices ensures your Rails models maintain optimal performance and follow standard conventions.

Why do my ActiveRecord callbacks feel fragile, and how should I extract them into service objects?

ActiveRecord callbacks feel fragile when they cause unintended side effects or complex dependencies. You should extract them into service objects to isolate business logic, improving testability and preventing fragile model behavior.