Every gem you add is code you did not write but will have to upgrade, debug and secure. A good style guide does not just list favourite gems; it explains how a team decides whether a gem is worth it.
Questions to ask before adding a gem
- Could this be twenty lines of plain Ruby in
app/orlib/instead? - Is it actively maintained, and does it support the Rails and Ruby versions you plan to run next year?
- How many transitive dependencies does it pull in?
- Does it monkey-patch core classes or Rails internals?
- Is it only needed in development or test? If so, put it in the right group.
Categories that usually pay off
| Need | Typical choice |
|---|---|
| Testing | rspec-rails or Minitest, factory_bot_rails, capybara |
| Code quality | rubocop with rubocop-rails |
| Security checks | brakeman, bundler-audit |
| N+1 detection | bullet in development |
| Background jobs | sidekiq or a database-backed adapter |
Group gems deliberately
source "https://rubygems.org"
gem "rails", "~> 7.1"
gem "pg"
gem "puma"
group :development, :test do
gem "rspec-rails"
gem "factory_bot_rails"
end
group :development do
gem "bullet"
gem "rubocop-rails", require: false
gem "brakeman", require: false
end
group :test do
gem "capybara"
end
Use require: false for command-line tools that never need to be loaded into the running app. It keeps boot time down and avoids surprising side effects.
Keeping the list healthy
- Review the Gemfile when upgrading Rails and remove gems the framework now covers itself.
- Run a vulnerability audit in CI so known issues fail the build.
- Add a one-line comment above any gem whose purpose is not obvious. Future maintainers will thank you when deciding whether it can go.