bundler-patternslisted
Install: claude install-skill Mattakushi432/Claude-Code-Skills-Custom-DevTools-Pack
# Bundler Patterns
## When to Use
Managing a Ruby application's gem dependencies, authoring a gem's `.gemspec`, or auditing dependencies for known vulnerabilities.
## Core Patterns
### Gemfile Structure
```ruby
source "https://rubygems.org"
ruby "3.3.0"
gem "rails", "~> 7.1.0"
gem "pg", "~> 1.5"
gem "sidekiq", "~> 7.2"
group :development, :test do
gem "rspec-rails", "~> 6.1"
gem "factory_bot_rails"
gem "rubocop", require: false
end
group :test do
gem "vcr"
gem "webmock"
end
group :production do
gem "rack-timeout"
end
```
### Pessimistic Version Operator
```ruby
gem "rails", "~> 7.1.0" # allows 7.1.x, blocks 7.2.0 — pins to patch updates only
gem "rails", "~> 7.1" # allows 7.1.x AND 7.2.x, blocks 8.0 — pins to the major
gem "pg", ">= 1.5", "< 2" # explicit range, equivalent meaning, more readable to some teams
```
`~>` ("twiddle-wakka") is the idiomatic default — it allows safe updates while blocking breaking major/minor bumps depending on how many version segments you specify.
### Lockfile Discipline
```bash
bundle install # resolves and writes Gemfile.lock
bundle install --deployment # (legacy) or `--frozen` — fail if Gemfile.lock is out of sync
BUNDLE_FROZEN=true bundle install # CI: never silently re-resolve
```
Always commit `Gemfile.lock` for applications — it's what guarantees the same gem versions in dev, CI, and production. Never `.gitignore` it for an app (libraries/gems are the exception).
### Bundler Groups
```ruby
# L