jpskill.com
🛠️ 開発・MCP コミュニティ 🔴 エンジニア向け 👤 エンジニア・AI開発者

🛠️ Skill Rails Upgrade

skill-rails-upgrade

既存のWebシステムがRuby on Railsで開発

⏱ テスト計画作成 2時間 → 20分

📺 まず動画で見る(YouTube)

▶ 【衝撃】最強のAIエージェント「Claude Code」の最新機能・使い方・プログラミングをAIで効率化する超実践術を解説! ↗

※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。

📜 元の英語説明(参考)

Analyze Rails apps and provide upgrade assessments

🇯🇵 日本人クリエイター向け解説

一言でいうと

既存のWebシステムがRuby on Railsで開発

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o skill-rails-upgrade.zip https://jpskill.com/download/3502.zip && unzip -o skill-rails-upgrade.zip && rm skill-rails-upgrade.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/3502.zip -OutFile "$d\skill-rails-upgrade.zip"; Expand-Archive "$d\skill-rails-upgrade.zip" -DestinationPath $d -Force; ri "$d\skill-rails-upgrade.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して skill-rails-upgrade.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → skill-rails-upgrade フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-17
取得日時
2026-05-17
同梱ファイル
1

💬 こう話しかけるだけ — サンプルプロンプト

  • Skill Rails Upgrade を使って、最小構成のサンプルコードを示して
  • Skill Rails Upgrade の主な使い方と注意点を教えて
  • Skill Rails Upgrade を既存プロジェクトに組み込む方法を教えて

これをClaude Code に貼るだけで、このSkillが自動発動します。

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

このスキルを使用する場面

Railsアプリケーションを分析し、アップグレード評価を提供します。

Railsアプリケーションの分析やアップグレード評価の提供を行う際に、このスキルを使用してください。

Railsアップグレードアナライザー

現在のRailsアプリケーションを分析し、選択的なファイルマージを含む包括的なアップグレード評価を提供します。

ステップ1: Railsアプリケーションの検証

以下のファイルを探して、Railsアプリケーション内にいることを確認します。

  • Gemfile (存在し、「rails」が含まれている必要があります)
  • config/application.rb (Railsアプリケーション設定)
  • config/environment.rb (Rails環境)

これらのいずれかが欠落しているか、Railsアプリを示していない場合は、停止して、これがRailsアプリケーションではないと思われることをユーザーに通知します。

ステップ2: 現在のRailsバージョンを取得

現在のRailsバージョンを以下から抽出します。

  1. まず、Gemfile.lockで正確なインストールバージョンを確認します (rails (x.y.z)を探します)。
  2. 見つからない場合は、Gemfileでバージョン制約を確認します。

正確な現在のバージョン (例: 7.1.3) を報告します。

ステップ3: 最新のRailsバージョンを見つける

GitHub CLIを使用して、最新のRailsリリースを取得します。

gh api repos/rails/rails/releases/latest --jq '.tag_name'

これは最新の安定版バージョンのタグ (例: v8.0.1) を返します。比較のために「v」プレフィックスを削除します。

また、リリース状況を理解するために、最近のタグも確認します。

gh api repos/rails/rails/tags --jq '.[0:10] | .[].name'

ステップ4: アップグレードタイプを決定する

現在のバージョンと最新バージョンを比較して、アップグレードを分類します。

  • パッチアップグレード: メジャー.マイナーバージョンは同じで、パッチバージョンが異なる場合 (例: 7.1.3 → 7.1.5)
  • マイナーアップグレード: メジャーバージョンは同じで、マイナーバージョンが異なる場合 (例: 7.1.3 → 7.2.0)
  • メジャーアップグレード: メジャーバージョンが異なる場合 (例: 7.1.3 → 8.0.0)

ステップ5: アップグレードガイドを取得する

WebFetchを使用して、公式のRailsアップグレードガイドを取得します。

URL: https://guides.rubyonrails.org/upgrading_ruby_on_rails.html

バージョンジャンプに関連するセクションを探します。ガイドはターゲットバージョンごとに、以下のようなセクションで構成されています。

  • "Upgrading from Rails X.Y to Rails X.Z"
  • 破壊的変更
  • 非推奨の警告
  • 設定の変更
  • 必要なマイグレーション

ユーザーの特定のアップグレードパスに関連するセクションを抽出し、要約します。

ステップ6: Rails Diffを取得する

WebFetchを使用して、railsdiff.orgからバージョン間の差分を取得します。

URL: https://railsdiff.org/{current_version}/{target_version}

例: https://railsdiff.org/7.1.3/8.0.0

これにより、以下が表示されます。

  • デフォルト設定ファイルの変更
  • 追加する必要がある新しいファイル
  • 変更されたイニシャライザ
  • 更新された依存関係
  • bin/スクリプトの変更

主要なファイル変更を要約します。

ステップ7: JavaScript依存関係の確認

Railsアプリケーションには、Railsと同時に更新すべきJavaScriptパッケージが含まれていることがよくあります。これらの依存関係を確認し、報告します。

7.1: JSパッケージマネージャーの特定

アプリが使用しているパッケージマネージャーを確認します。

# package.json (npm/yarn) を確認
ls package.json 2>/dev/null

# importmap (Rails 7+) を確認
ls config/importmap.rb 2>/dev/null

7.2: Rails関連のJSパッケージの確認

package.jsonが存在する場合、以下のRails関連パッケージを確認します。

# Rails関連パッケージの現在のバージョンを抽出
cat package.json | grep -E '"@hotwired/|"@rails/|"stimulus"|"turbo-rails"' || echo "No Rails JS packages found"

確認すべき主要パッケージ:

パッケージ 目的 バージョンの一致
@hotwired/turbo-rails Turbo Drive/Frames/Streams Railsのバージョン時代と一致すべき
@hotwired/stimulus Stimulus JSフレームワーク Railsバージョン間で一般的に安定
@rails/actioncable WebSocketサポート Railsバージョンと一致すべき
@rails/activestorage ダイレクトアップロード Railsバージョンと一致すべき
@rails/actiontext リッチテキスト編集 Railsバージョンと一致すべき
@rails/request.js Rails UJSの代替 Railsのバージョン時代と一致すべき

7.3: 更新の確認

npm/yarnプロジェクトの場合、利用可能な更新を確認します。

# npmを使用
npm outdated @hotwired/turbo-rails @hotwired/stimulus @rails/actioncable @rails/activestorage 2>/dev/null

# または最新バージョンを直接確認
npm view @hotwired/turbo-rails version 2>/dev/null
npm view @rails/actioncable version 2>/dev/null

7.4: Importmapピンの確認 (該当する場合)

アプリがimportmap-railsを使用している場合、config/importmap.rbでピン留めされたバージョンを確認します。

cat config/importmap.rb | grep -E 'pin.*turbo|pin.*stimulus|pin.*@rails' || echo "No importmap pins found"

Importmapピンを更新するには:

bin/importmap pin @hotwired/turbo-rails
bin/importmap pin @hotwired/stimulus

7.5: JS依存関係の要約

アップグレードの要約に含めます。

### JavaScript Dependencies

**Package Manager**: [npm/yarn/importmap/none]

| Package | Current | Latest | Action |
|---------|---------|--------|--------|
| @hotwired/turbo-rails | 8.0.4 | 8.0.12 | Update recommended |
| @rails/actioncable | 7.1.0 | 8.0.0 | Update with Rails |
| ... | ... | ... | ... |

**Recommended JS Updates:**
- Run `npm update @hotwired/turbo-rails` (or yarn equivalent)
- Run `npm update @rails/actioncable @rails/activestorage` to match Rails version

ステップ8: アップグレードの要約を生成する

ステップ1〜7のすべての調査結果を含む包括的な要約を提供します。

バージョン情報

  • 現在のバージョン: X.Y.Z
  • 最新バージョン: A.B.C
  • アップグレードタイプ: [パッチ/マイナー/メジャー]

アップグレードの複雑さの評価

アップグレードを以下の要素に基づいて、、またはに評価します。

要素
バージョンジャンプ パッチのみ マイナーバージョン メジャーバージョン
破壊的変更 なし 少数、十分に文書化されている 多数、重大
設定変更 最小限 中程度 広範囲
非推奨 アクティブなものなし 対処すべきものいくつか リファクタリングが必要なもの多数
依存関係 互換性あり いくつか更新が必要 主要な依存関係の更新

対処すべき主な変更点

ユーザーが対処する必要がある最も重要な変更点をリストアップします。

  1. 設定ファイルの更新
  2. 非推奨のメソッド/機能
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

When to Use This Skill

Analyze Rails apps and provide upgrade assessments

Use this skill when working with analyze rails apps and provide upgrade assessments.

Rails Upgrade Analyzer

Analyze the current Rails application and provide a comprehensive upgrade assessment with selective file merging.

Step 1: Verify Rails Application

Check that we're in a Rails application by looking for these files:

  • Gemfile (must exist and contain 'rails')
  • config/application.rb (Rails application config)
  • config/environment.rb (Rails environment)

If any of these are missing or don't indicate a Rails app, stop and inform the user this doesn't appear to be a Rails application.

Step 2: Get Current Rails Version

Extract the current Rails version from:

  1. First, check Gemfile.lock for the exact installed version (look for rails (x.y.z))
  2. If not found, check Gemfile for the version constraint

Report the exact current version (e.g., 7.1.3).

Step 3: Find Latest Rails Version

Use the GitHub CLI to fetch the latest Rails release:

gh api repos/rails/rails/releases/latest --jq '.tag_name'

This returns the latest stable version tag (e.g., v8.0.1). Strip the 'v' prefix for comparison.

Also check recent tags to understand the release landscape:

gh api repos/rails/rails/tags --jq '.[0:10] | .[].name'

Step 4: Determine Upgrade Type

Compare current and latest versions to classify the upgrade:

  • Patch upgrade: Same major.minor, different patch (e.g., 7.1.3 → 7.1.5)
  • Minor upgrade: Same major, different minor (e.g., 7.1.3 → 7.2.0)
  • Major upgrade: Different major version (e.g., 7.1.3 → 8.0.0)

Step 5: Fetch Upgrade Guide

Use WebFetch to get the official Rails upgrade guide:

URL: https://guides.rubyonrails.org/upgrading_ruby_on_rails.html

Look for sections relevant to the version jump. The guide is organized by target version with sections like:

  • "Upgrading from Rails X.Y to Rails X.Z"
  • Breaking changes
  • Deprecation warnings
  • Configuration changes
  • Required migrations

Extract and summarize the relevant sections for the user's specific upgrade path.

Step 6: Fetch Rails Diff

Use WebFetch to get the diff between versions from railsdiff.org:

URL: https://railsdiff.org/{current_version}/{target_version}

For example: https://railsdiff.org/7.1.3/8.0.0

This shows:

  • Changes to default configuration files
  • New files that need to be added
  • Modified initializers
  • Updated dependencies
  • Changes to bin/ scripts

Summarize the key file changes.

Step 7: Check JavaScript Dependencies

Rails applications often include JavaScript packages that should be updated alongside Rails. Check for and report on these dependencies.

7.1: Identify JS Package Manager

Check which package manager the app uses:

# Check for package.json (npm/yarn)
ls package.json 2>/dev/null

# Check for importmap (Rails 7+)
ls config/importmap.rb 2>/dev/null

7.2: Check Rails-Related JS Packages

If package.json exists, check for these Rails-related packages:

# Extract current versions of Rails-related packages
cat package.json | grep -E '"@hotwired/|"@rails/|"stimulus"|"turbo-rails"' || echo "No Rails JS packages found"

Key packages to check:

Package Purpose Version Alignment
@hotwired/turbo-rails Turbo Drive/Frames/Streams Should match Rails version era
@hotwired/stimulus Stimulus JS framework Generally stable across Rails versions
@rails/actioncable WebSocket support Should match Rails version
@rails/activestorage Direct uploads Should match Rails version
@rails/actiontext Rich text editing Should match Rails version
@rails/request.js Rails UJS replacement Should match Rails version era

7.3: Check for Updates

For npm/yarn projects, check for available updates:

# Using npm
npm outdated @hotwired/turbo-rails @hotwired/stimulus @rails/actioncable @rails/activestorage 2>/dev/null

# Or check latest versions directly
npm view @hotwired/turbo-rails version 2>/dev/null
npm view @rails/actioncable version 2>/dev/null

7.4: Check Importmap Pins (if applicable)

If the app uses importmap-rails, check config/importmap.rb for pinned versions:

cat config/importmap.rb | grep -E 'pin.*turbo|pin.*stimulus|pin.*@rails' || echo "No importmap pins found"

To update importmap pins:

bin/importmap pin @hotwired/turbo-rails
bin/importmap pin @hotwired/stimulus

7.5: JS Dependency Summary

Include in the upgrade summary:

### JavaScript Dependencies

**Package Manager**: [npm/yarn/importmap/none]

| Package | Current | Latest | Action |
|---------|---------|--------|--------|
| @hotwired/turbo-rails | 8.0.4 | 8.0.12 | Update recommended |
| @rails/actioncable | 7.1.0 | 8.0.0 | Update with Rails |
| ... | ... | ... | ... |

**Recommended JS Updates:**
- Run `npm update @hotwired/turbo-rails` (or yarn equivalent)
- Run `npm update @rails/actioncable @rails/activestorage` to match Rails version

Step 8: Generate Upgrade Summary

Provide a comprehensive summary including all findings from Steps 1-7:

Version Information

  • Current version: X.Y.Z
  • Latest version: A.B.C
  • Upgrade type: [Patch/Minor/Major]

Upgrade Complexity Assessment

Rate the upgrade as Small, Medium, or Large based on:

Factor Small Medium Large
Version jump Patch only Minor version Major version
Breaking changes None Few, well-documented Many, significant
Config changes Minimal Moderate Extensive
Deprecations None active Some to address Many requiring refactoring
Dependencies Compatible Some updates needed Major dependency updates

Key Changes to Address

List the most important changes the user needs to handle:

  1. Configuration file updates
  2. Deprecated methods/features to update
  3. New required dependencies
  4. Database migrations needed
  5. Breaking API changes

Recommended Upgrade Steps

  1. Update test suite and ensure passing
  2. Review deprecation warnings in current version
  3. Update Gemfile with new Rails version
  4. Run bundle update rails
  5. Update JavaScript dependencies (see JS Dependencies section)
  6. DO NOT run rails app:update directly - use the selective merge process below
  7. Run database migrations
  8. Run test suite
  9. Review and update deprecated code

Resources


When to Use This Skill

Analyze Rails apps and provide upgrade assessments

Use this skill when working with analyze rails apps and provide upgrade assessments.

Step 9: Selective File Update (replaces rails app:update)

IMPORTANT: Do NOT run rails app:update as it overwrites files without considering local customizations. Instead, follow this selective merge process:

9.1: Detect Local Customizations

Before any upgrade, identify files with local customizations:

# Check for uncommitted changes
git status

# List config files that differ from a fresh Rails app
# These are the files we need to be careful with
git diff HEAD --name-only -- config/ bin/ public/

Create a mental list of files in these categories:

  • Custom config files: Files with project-specific settings (i18n, mailer, etc.)
  • Modified bin scripts: Scripts with custom behavior (bin/dev with foreman, etc.)
  • Standard files: Files that haven't been customized

9.2: Analyze Required Changes from Railsdiff

Based on the railsdiff output from Step 6, categorize each changed file:

Category Action Example
New files Create directly config/initializers/new_framework_defaults_X_Y.rb
Unchanged locally Safe to overwrite public/404.html (if not customized)
Customized locally Manual merge needed config/application.rb, bin/dev
Comment-only changes Usually skip Minor comment updates in config files

9.3: Create Upgrade Plan

Present the user with a clear upgrade plan:

## Upgrade Plan: Rails X.Y.Z → A.B.C

### New Files (will be created):
- config/initializers/new_framework_defaults_A_B.rb
- bin/ci (new CI script)

### Safe to Update (no local customizations):
- public/400.html
- public/404.html
- public/500.html

### Needs Manual Merge (local customizations detected):
- config/application.rb
  └─ Local: i18n configuration
  └─ Rails: [describe new Rails changes if any]

- config/environments/development.rb
  └─ Local: letter_opener mailer config
  └─ Rails: [describe new Rails changes]

- bin/dev
  └─ Local: foreman + Procfile.dev setup
  └─ Rails: changed to simple ruby script

### Skip (comment-only or irrelevant changes):
- config/puma.rb (only comment changes)

9.4: Execute Upgrade Plan

After user confirms the plan:

For New Files:

Create them directly using the content from railsdiff or by extracting from a fresh Rails app:

# Generate a temporary fresh Rails app to extract new files
cd /tmp && rails new rails_template --skip-git --skip-bundle
# Then copy needed files

Or use the Rails generator for specific files:

bin/rails app:update:configs  # Only updates config files, still interactive

For Safe Updates:

Overwrite these files as they have no local customizations.

For Manual Merges:

For each file needing merge, show the user:

  1. Current local version (their customizations)
  2. New Rails default (from railsdiff)
  3. Suggested merged version that:
    • Keeps all local customizations
    • Adds only essential new Rails functionality
    • Removes deprecated settings

Example merge for config/application.rb:

# KEEP local customizations:
config.i18n.available_locales = [:de, :en]
config.i18n.default_locale = :de
config.i18n.fallbacks = [:en]

# ADD new Rails 8.1 settings if needed:
# (usually none required - new defaults come via new_framework_defaults file)

9.5: Handle Active Storage Migrations

After file updates, run any new migrations:

bin/rails db:migrate

Check for new migrations that were added:

ls -la db/migrate/ | tail -10

9.6: Verify Upgrade

After completing the merge:

  1. Start the Rails server and check for errors:

    bin/dev  # or bin/rails server
  2. Check the Rails console:

    bin/rails console
  3. Run the test suite:

    bin/rails test
  4. Review deprecation warnings in logs


Step 10: Finalize Framework Defaults

After verifying the app works:

  1. Review config/initializers/new_framework_defaults_X_Y.rb
  2. Enable each new default one by one, testing after each
  3. Once all defaults are enabled and tested, update config/application.rb:
    config.load_defaults X.Y  # Update to new version
  4. Delete the new_framework_defaults_X_Y.rb file

When to Use This Skill

Analyze Rails apps and provide upgrade assessments

Use this skill when working with analyze rails apps and provide upgrade assessments.

Error Handling

  • If gh CLI is not authenticated, instruct the user to run gh auth login
  • If railsdiff.org doesn't have the exact versions, try with major.minor.0 versions
  • If the app is already on the latest version, congratulate the user and note any upcoming releases
  • If local customizations would be lost, ALWAYS stop and show the user what would be overwritten before proceeding

Key Principles

  1. Never overwrite without checking - Always check for local customizations first
  2. Preserve user intent - Local customizations exist for a reason
  3. Minimal changes - Only add what's necessary for the new Rails version
  4. Transparency - Show the user exactly what will change before doing it
  5. Reversibility - User should be able to git checkout to restore if needed

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.