rails-best-practices-core
Installation
SKILL.md
Rails Best Practices Core
Use this as the default baseline for Rails work. Distilled from 37signals codebases (Campfire, Fizzy) and DHH's review patterns.
Core Defaults
- Prefer clear, explicit code over clever abstractions. Abstractions must earn their keep; if you can't point to 3+ variations that need it, inline it.
- Keep controllers thin and put domain behavior in models.
- Prefer Rails conventions and built-ins before adding gems.
- Model state and behavior with domain concepts, not ad-hoc flags.
- Scope tenant/user data through ownership boundaries.
- Favor database constraints for hard invariants; only validate in AR when you need user-facing error messages.
- Keep interfaces small; don't add public methods that aren't used anywhere.
- Prefer write-time computation over expensive read-time composition (counter caches, delegated types, precomputed roll-ups,
dependent: :delete_allwhen no callbacks needed). - Use
params.expect(...)for strong params in modern Rails. - Let it crash: bang methods (
create!), handle exceptions at boundaries. Only use!when a non-bang counterpart exists. - Fix root causes, not symptoms (e.g.
enqueue_after_transaction_commitover retry logic for races). - Ship tests in the same PR as behavior changes.