Rails Preferences

Organize Rails model and controller components with deterministic ordering rules.

Updated Feb 14, 2026
One-click install
npx skills add https://github.com/martinstreicher/claude-skills --skill rails-preferences
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Rails Preferences
Source: https://github.com/martinstreicher/claude-skills/tree/main/rails
Command: npx skills add https://github.com/martinstreicher/claude-skills --skill rails-preferences

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Rails codebases often drift, creating inconsistencies and maintenance burdens. This Skill defines a set of conventions to keep models, controllers, and validations organized and readable.

Core Features & Use Cases

  • Alphabetical organization of associations and other sections where applicable.
  • Blank lines after associations and validations to improve readability.
  • Defined order for Rails model components (annotations, includes, constants, delegates, gems/plugins, callbacks, associations, validations, scopes, class methods, instance methods, private methods).
  • Use case: refactoring a large User model to enforce a consistent structure across a project.

Quick Start

Follow these conventions to maintain consistent structure across Rails models and controllers.

Frequently Asked Questions about Rails Preferences

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

FAQPage Schema
How do I organize Rails models to improve readability and consistency?

Organize Rails models by enforcing a deterministic file order: annotations, includes, constants, delegates, gems, callbacks, associations, validations, scopes, and methods. This structure ensures models remain readable and consistent across large codebases.

What is the best way to order associations and validations in a Rails model?

The best way to order associations and validations is to place associations after delegates and before validations, sorted alphabetically. Adding blank lines after these sections further improves code readability and maintenance.

How do I refactor a large Ruby on Rails model for better code quality?

Refactor large Ruby on Rails models by applying standardized ordering rules to model components like callbacks, validations, and associations. Enforcing a consistent file structure reduces drift and maintenance burdens across the project.

Do I need any external gems to enforce Rails coding conventions?

No external gems are required to enforce Rails coding conventions. This approach defines structural rules for models and controllers natively, applying deterministic ordering to associations, validations, and methods without additional dependencies.

Can I apply deterministic ordering rules to Rails controllers as well as models?

Yes, deterministic ordering rules apply to both Rails controllers and models. The conventions standardize file component structures across the entire project, ensuring that controllers maintain the same consistent readability as models.

When should I enforce a standard structure for Rails associations and callbacks?

Enforce a standard structure for Rails associations and callbacks when your codebase begins drifting and creating inconsistencies. Applying prescribed ordering rules early prevents maintenance burdens and keeps model organization predictable.