carakan/dotfiles/rails-conventions

Claude Code and agent skill by carakan/dotfiles

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Use when creating new Rails files, naming models/controllers/views, organizing directories, or when unsure about Rails naming conventions. Also applies when reviewing code for convention violations like incorrect pluralization, wrong file locations, or non-standard naming. Covers file structure, naming patterns for models, controllers, views, routes, jobs, mailers, and migrations.

Install

npx vskill@latest install carakan/dotfiles/rails-conventions

SKILL.md

The same SKILL.md was published earlier as chaserx/cpc/rails-conventions.

Rails Conventions and Best Practices

Guidance for following Rails conventions, file organization, naming patterns, and "The Rails Way" for Rails 7+ applications.

Core Principles

Convention over Configuration

Rails provides sensible defaults. Follow conventions to benefit from:

  • Automatic file loading and discovery
  • Reduced configuration overhead
  • Consistency across Rails projects
  • Easier onboarding for new developers
The Rails Way
  • DRY (Don't Repeat Yourself): Extract shared logic into concerns, helpers, or services
  • Fat Models, Skinny Controllers: Business logic belongs in models, not controllers
  • RESTful Resources: Design around resources with standard CRUD actions
  • Prefer Convention: Only customize when Rails conventions don't fit

File Structure

Standard Directory Layout
app/
├── assets/ # CSS, images, fonts (managed by asset pipeline)
├── channels/ # Action Cable channels
├── components/ # ViewComponents (if used)
├── controllers/ # Request handlers
│ ├── concerns/ # Shared controller logic
│ └── api/ # API controllers (namespaced)
├── helpers/ # View helpers
├── javascript/ # JavaScript/Stimulus controllers
├── jobs/ # Background jobs
├── mailers/ # Email senders
├── models/ # ActiveRecord models
│ └── concerns/ # Shared model logic
├── services/ # Service objects (optional)
├── views/ # Templates and partials
│ ├── layouts/ # Application layouts
│ └── shared/ # Shared partials
config/
├── routes.rb # Routing configuration
├── database.yml # Database configuration
├── environments/ # Environment-specific settings
└── initializers/ # Startup configuration
db/
├── migrate/ # Database migrations
├── schema.rb # Current schema (auto-generated)
└── seeds.rb # Seed data
lib/
├── tasks/ # Rake tasks
└── generators/ # Custom generators
spec/ or test/ # Test files (mirrors app/ structure)

Naming Conventions

Models
  • Class: Singular, PascalCase (User, OrderItem, BlogPost)
  • File: Singular, snake_case (user.rb, order_item.rb, blog_post.rb)
  • Table: Plural, snake_case (users, order_items, blog_posts)
  • Foreign key: Singular model name + _id (user_id, order_item_id)
Controllers
  • Class: Plural, PascalCase + Controller (UsersController, OrderItemsController)
  • File: Plural, snake_case (users_controller.rb, order_items_controller.rb)
  • Actions: Lowercase (index, show, new, create, edit, update, destroy)
Views
  • Directory: Plural, snake_case (app/views/users/)
  • Template: Action name + format + handler (index.html.erb, show.json.jbuilder)
  • Partial: Underscore prefix (_form.html.erb, _user.html.erb)
Routes
  • Resource: Plural (resources :users, resources :order_items)
  • Singular Resource: Singular (resource :profile, resource :dashboard)
Jobs, Mailers, and Migrations
  • Job class: Descriptive + Job (SendWelcomeEmailJob, ProcessPaymentJob)
  • Mailer class: Descriptive + Mailer (UserMailer, OrderMailer)
  • Mailer methods: Descriptive action (welcome_email, order_confirmation)
  • Migration file: Timestamp + descriptive name (20240101120000_create_users.rb)
  • Migration class: Descriptive PascalCase (CreateUsers, AddEmailToUsers)

Quick Reference

WhatConventionExample
Model classSingular PascalCaseUser
Model fileSingular snake_caseuser.rb
TablePlural snake_caseusers
ControllerPlural + ControllerUsersController
View folderPlural snake_caseviews/users/
RoutePlural resourceresources :users
Foreign keymodel_iduser_id
Join tableAlphabeticalposts_tags

Follow these conventions consistently to create maintainable Rails applications that are easy to understand and extend.

Additional Resources

Reference Files

For detailed code examples and patterns, consult:

  • `references/restful-design.md` — Standard REST actions table, custom actions, nested resources, namespace/scope patterns, and controller structure
  • `references/model-controller-examples.md` — Association naming, polymorphic/self-referential associations, validation patterns, scope naming and chaining, callback conventions, and concern patterns
Related Skills
  • `service-patterns` — Service objects, form objects, query objects, and interactors
  • `active-record-patterns` — ActiveRecord query and association patterns in depth
  • `action-controller-patterns` — Controller design patterns and advanced techniques
  • `rails-antipatterns` — Common anti-patterns, code smells, and refactoring guidance

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/carakan/dotfiles/rails-conventions/badge)](https://verified-skill.com/skills/carakan/dotfiles/rails-conventions)

Something wrong with this skill or its page? Tell us.