carakan/dotfiles/rails-conventions
Claude Code and agent skill by carakan/dotfiles
- community
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-conventionsSKILL.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
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
| What | Convention | Example | |
|---|---|---|---|
| Model class | Singular PascalCase | User | |
| Model file | Singular snake_case | user.rb | |
| Table | Plural snake_case | users | |
| Controller | Plural + Controller | UsersController | |
| View folder | Plural snake_case | views/users/ | |
| Route | Plural resource | resources :users | |
| Foreign key | model_id | user_id | |
| Join table | Alphabetical | posts_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
- SKILL.md in the repositoryCheckingpackages/opencode/skills/rails-conventions/SKILL.md
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
[](https://verified-skill.com/skills/carakan/dotfiles/rails-conventions)