Upgrade

Objective

Upgrade a Rails application to a new version with minimal risk, minimal downtime and clear rollback capability.

This playbook describes both the manual upgrade workflow and AI-assisted upgrade using the Ruby Upgrade Toolkit, a Claude Code plugin that automates Ruby and Rails upgrades.

Inputs

Prerequisites

Workflow

Step 1: Assess Compatibility

Step 2: Prepare the Codebase

Step 3: Upgrade Gems

Step 4: Run Tests

Step 5: Apply Configuration Changes

Step 6: Manual Verification

Step 7: Deploy

Step 8: Production Deployment

AI-Assisted Upgrade

The Ruby Upgrade Toolkit is a Claude Code plugin that packages skills and commands for AI-assisted Ruby and Rails upgrades. It follows the same phased methodology as this playbook but automates detection, fix application, and verification.

Installation

Add the marketplace and install the plugin in Claude Code:

/plugin marketplace add dhruvasagar/ruby-upgrade-toolkit
/plugin install ruby-upgrade-toolkit@dhruvasagar
/reload-plugins

Workflow Modes

The toolkit provides three modes of operation, each suited to different levels of control:

Mode 1: Fully Automated

/ruby-upgrade-toolkit:upgrade ruby:X.Y.Z [rails:X.Y]

One command runs everything: detects versions, validates compatibility, computes the full upgrade path with intermediate versions, applies fixes phase by phase (Ruby first, then Rails), verifies after each phase with the test suite and RuboCop, and pauses with a recovery menu if anything fails.

Use when you want to move quickly and trust Claude to sequence and execute the work.

Mode 2: Review First, Then Automate

/ruby-upgrade-toolkit:audit ruby:X.Y.Z [rails:X.Y.Y]   # understand the scope
/ruby-upgrade-toolkit:plan ruby:X.Y.Z [rails:X.Y.Y]    # review the phase sequence
/ruby-upgrade-toolkit:upgrade ruby:X.Y.Z [rails:X.Y.Y] # execute the plan

audit surfaces breaking changes and gives an effort estimate before touching any code. plan shows exactly which phases will run, in what order, with per-phase effort, risk, blast radius and confidence estimates derived from concrete grep counts. Once you approve, upgrade executes the sequence.

Use when you're doing a major version jump or want to understand scope before committing to execution.

Mode 3: Fully Manual (Per-Phase Control)

/ruby-upgrade-toolkit:audit ruby:X.Y.Z [rails:X.Y.Y]   # read-only scan
/ruby-upgrade-toolkit:plan  ruby:X.Y.Z [rails:X.Y.Y]   # roadmap + task list
/ruby-upgrade-toolkit:fix   next                         # apply next phase

plan creates a task list (one task per upgrade phase). fix next reads the list, applies the next pending phase, runs the test suite iteratively until green, runs RuboCop iteratively until clean, then prompts for a commit with a detailed message. Iterate fix next until all phases are complete.

Use when you want to inspect and approve changes phase by phase, or resume a partially completed upgrade.

How It Works

  1. Phase sequencing: Ruby upgrades complete before Rails upgrades begin. Intermediate minor versions are never skipped (e.g., 6.1 → 7.0 → 7.1 → 8.0, not 6.1 → 8.0).
  2. Per-phase verification: Each phase runs the full test suite and RuboCop before prompting for a commit. Failures pause with recovery options.
  3. Commit checkpoints: Each successful phase produces a detailed commit message itemising version pins, gem diffs, fix counts and verification results.
  4. Custom rules: Project-specific policies (gem pins, gem swaps, private-source substitutions, extra verification gates) can be declared in .ruby-upgrade-toolkit/rules.yml.

Command Reference

CommandPurpose
audit ruby:X.Y.Z [rails:X.Y]Read-only pre-upgrade assessment. Surfaces breaking changes, gem incompatibilities, effort estimate. Never modifies files.
plan ruby:X.Y.Z [rails:X.Y]Generates a phased upgrade roadmap with per-phase effort/risk/blast-radius estimates. Creates a task list that drives fix and upgrade.
fix nextApplies the next pending upgrade phase. Iterates test suite and RuboCop to green. Prompts for commit with detailed message.
upgrade ruby:X.Y.Z [rails:X.Y]Full automated pipeline: prerequisites, phased fixes with per-phase commits, final infra checks.
statusCurrent upgrade health dashboard: versions, test status, deprecation warnings, RuboCop offenses, Zeitwerk status.
rulesManage project-specific upgrade policies (gem pins, swaps, verification gates) in .ruby-upgrade-toolkit/rules.yml.

Relationship to Manual Workflow

The toolkit automates the same phases described in the manual workflow above. Understanding the manual process helps you:

The manual workflow remains the definitive reference for what each upgrade phase entails.

When to Use Each Approach

SituationRecommended Approach
Simple patch bumpManual or Mode 1 (automated)
Minor version jump, small codebaseMode 1 (automated)
Minor version jump, large codebaseMode 2 (review then automate)
Major version jumpMode 2 or Mode 3 (per-phase control)
First-time upgrade on unfamiliar codebaseMode 3 (full control)
Learning the upgrade processManual workflow first, then try the toolkit

Checklist

Rollback Plan

If the upgrade causes issues in production:

  1. Revert the Gemfile and Gemfile.lock to the previous version.
  2. Revert any configuration changes.
  3. Deploy the previous version.
  4. Investigate and document the issue.

Expected Outputs

Related Documents