rails-upgrade
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRails Upgrade Assistant Skill
Rails升级助手技能
Skill Identity
技能信息
- Name: Rails Upgrade Assistant
- Purpose: Intelligent Rails application upgrades from 2.3 through 8.1
- Skill Type: Modular with external workflows and examples
- Upgrade Strategy: Sequential only (no version skipping)
- Methodology: Based on FastRuby.io upgrade best practices and "The Complete Guide to Upgrade Rails" ebook
- Attribution: Content based on "The Complete Guide to Upgrade Rails" by FastRuby.io (OmbuLabs)
- 名称: Rails Upgrade Assistant
- 用途: 支持Rails 2.3到8.1版本的智能应用升级
- 技能类型: 模块化设计,包含外部工作流和示例
- 升级策略: 仅支持顺序升级(禁止跨版本升级)
- 方法论: 基于FastRuby.io升级最佳实践和《Rails升级完全指南》电子书
- 归属: 内容基于FastRuby.io(OmbuLabs)出品的《Rails升级完全指南》
Dependencies
依赖项
- rails-load-defaults skill (github.com/ombulabs/claude-code_rails-load-defaults-skill) — Handles incremental updates with tiered risk assessment (Tier 1: low-risk, Tier 2: needs codebase grep, Tier 3: requires human review). Must be installed for Step 2 of the upgrade workflow.
load_defaults - dual-boot skill (github.com/ombulabs/claude-code_dual-boot-skill) — Sets up and manages dual-boot environments using the gem. Covers setup,
next_railscode patterns, CI configuration, and post-upgrade cleanup. Must be installed for Step 4 of the upgrade workflow.NextRails.next?
- rails-load-defaults skill (github.com/ombulabs/claude-code_rails-load-defaults-skill) — 处理的增量更新,附带分级风险评估(1级:低风险,2级:需要代码库检索,3级:需要人工审核)。升级工作流的第2步必须安装此依赖。
load_defaults - dual-boot skill (github.com/ombulabs/claude-code_dual-boot-skill) — 使用gem搭建和管理双启动环境,覆盖配置、
next_rails代码模式、CI配置、升级后清理等能力。升级工作流的第4步必须安装此依赖。NextRails.next?
Core Methodology (FastRuby.io Approach)
核心方法论(FastRuby.io 方案)
This skill follows the proven FastRuby.io upgrade methodology:
- Incremental Upgrades - Always upgrade one minor/major version at a time
- Assessment First - Understand scope before making changes
- Dual-Boot Testing - Test both versions during transition using gem
next_rails - Test Coverage - Ensure adequate test coverage before upgrading (aim for 80%+)
- Gem Compatibility - Check gem compatibility at each step using RailsBump
- Deprecation Warnings - Address deprecations before upgrading
- Backwards Compatible Changes - Deploy small changes to production before version bump
Key Resources:
- DELEGATE to the skill for dual-boot setup with
dual-boot(see Dependencies)next_rails - See for managing deprecations
reference/deprecation-warnings.md - See for maintaining upgrades over time
reference/staying-current.md
本技能遵循经过验证的FastRuby.io升级方法论:
- 增量升级 - 每次仅升级一个次版本/主版本
- 评估优先 - 变更前先明确升级范围
- 双启动测试 - 过渡阶段使用gem同时测试两个版本
next_rails - 测试覆盖 - 升级前确保足够的测试覆盖率(目标80%以上)
- Gem兼容性 - 每一步都使用RailsBump检查gem兼容性
- 弃用警告处理 - 升级前先解决所有弃用警告
- 向后兼容变更 - 版本升级前先将小型变更部署到生产环境
核心资源:
- 双启动环境搭配的配置请委托给
next_rails技能处理(见依赖项)dual-boot - 弃用项管理可查看
reference/deprecation-warnings.md - 长期维护升级节奏可查看
reference/staying-current.md
CRITICAL: Dual-Boot Code Pattern with NextRails.next?
NextRails.next?重要说明:搭配NextRails.next?
的双启动代码模式
NextRails.next?When proposing code fixes that must work with both the current and target Rails versions (dual-boot), always use from the gem — never use or other feature-detection patterns.
NextRails.next?next_railsrespond_to?DELEGATE to the skill for:
dual-boot- Setup and initialization (,
next_rails --init)Gemfile.next - code patterns and examples
NextRails.next? - CI configuration for dual-boot testing
- Post-upgrade cleanup (removing dual-boot branches)
DEPENDENCY: Requires the dual-boot skill
当提供需要同时兼容当前和目标Rails版本(双启动)的代码修复方案时,必须使用 gem提供的方法 — 禁止使用或其他特性检测模式。
next_railsNextRails.next?respond_to?以下场景请委托给技能处理:
dual-boot- 环境配置和初始化(、
next_rails --init)Gemfile.next - 代码模式和示例
NextRails.next? - 双启动测试的CI配置
- 升级后清理(移除双启动分支)
依赖要求: 需要安装dual-boot skill
Core Workflow (5-Step Process)
核心工作流(5步流程)
Step 0: Verify Latest Patch Version (MANDATORY PRE-STEP)
第0步:确认当前最新补丁版本(强制前置步骤)
- CRITICAL: Before any upgrade work begins, verify the app is on the latest patch release of its current Rails series
- Read to find the exact current Rails version (e.g.,
Gemfile.lock)3.2.19 - Compare against the latest patch for that series:
- EOL series (≤ 6.1): Use the static table in
reference/multi-hop-strategy.md - Active series (≥ 7.0): Query the RubyGems API at runtime (see for commands)
reference/multi-hop-strategy.md
- EOL series (≤ 6.1): Use the static table in
- If the app is NOT on the latest patch:
- Inform user: "Your app is on Rails X.Y.Z but the latest patch is X.Y.W — you should upgrade to the latest patch first"
- Guide user through updating the Gemfile and running
bundle update rails - Run test suite after patch upgrade to verify nothing broke
- Deploy patch upgrade before proceeding with the minor/major version hop
- If the app IS on the latest patch → Proceed to Step 1
- Why: Patch releases contain security fixes, bug fixes, and additional deprecation warnings that make the next version hop safer and easier to debug
- 重要提醒: 开始任何升级工作前,必须确认应用运行在当前Rails系列的最新补丁版本上
- 读取获取当前准确的Rails版本(例如
Gemfile.lock)3.2.19 - 与当前系列的最新补丁版本对比:
- 已停止维护的系列(≤ 6.1): 使用中的静态对照表
reference/multi-hop-strategy.md - 仍在维护的系列(≥ 7.0): 运行时查询RubyGems API(命令参考)
reference/multi-hop-strategy.md
- 已停止维护的系列(≤ 6.1): 使用
- 如果应用未运行在最新补丁版本:
- 告知用户:「您的应用当前运行在Rails X.Y.Z版本,最新补丁版本为X.Y.W — 您应该先升级到最新补丁版本」
- 引导用户更新Gemfile并运行
bundle update rails - 补丁升级后运行测试套件确认没有功能损坏
- 补丁版本部署后再继续次版本/主版本升级
- 如果应用已经运行在最新补丁版本 → 进入第1步
- 设计原因: 补丁版本包含安全修复、bug修复和额外的弃用警告,能让后续版本升级更安全,也更易调试问题
Step 1: Run Test Suite (MANDATORY FIRST STEP)
第1步:运行测试套件(强制第一步)
- CRITICAL: Before any upgrade work begins, run the existing test suite
- Claude executes or
bundle exec rspecto verify baselinebundle exec rails test - All tests MUST pass before proceeding with any upgrade
- If tests fail, stop and help user fix failing tests first
- Record test count and coverage as baseline metrics
- See for details
workflows/test-suite-verification-workflow.md
- 重要提醒: 开始任何升级工作前,必须运行现有测试套件
- Claude执行或
bundle exec rspec确认基准功能正常bundle exec rails test - 所有测试必须全部通过才能继续升级流程
- 如果测试失败,暂停升级先协助用户修复失败的测试
- 记录测试数量和覆盖率作为基准指标
- 详细流程可查看
workflows/test-suite-verification-workflow.md
Step 2: Verify load_defaults Matches Current Rails Version
第2步:确认load_defaults与当前Rails版本匹配
- CRITICAL: Check if in
load_defaultsmatches the current Rails gem versionconfig/application.rb - DELEGATE to the skill for detection and incremental update
rails-load-defaults - That skill handles tiered, per-config updates with test runs between each change
- If matches current Rails version → Proceed to Step 3
load_defaults - DEPENDENCY: Requires the rails-load-defaults skill
- 重要提醒: 检查中的
config/application.rb配置是否与当前Rails gem版本匹配load_defaults - 检测和增量更新请委托给技能处理
rails-load-defaults - 该技能会处理分级的逐配置更新,每次变更后都会运行测试
- 如果与当前Rails版本匹配 → 进入第3步
load_defaults - 依赖要求: 需要安装rails-load-defaults skill
Step 3: Run Breaking Changes Detection (DIRECT)
第3步:运行破坏性变更检测(直接执行)
- Claude runs detection checks directly using Grep, Glob, and Read tools
- No script generation - Claude searches the codebase in real-time
- Finds issues with file:line references
- Collects all findings immediately
- See for patterns to search
workflows/direct-detection-workflow.md
- Claude直接使用Grep、Glob和读取工具运行检测检查
- 无需生成脚本 - Claude实时检索代码库
- 定位问题并返回「文件:行号」引用
- 立即收集所有检测结果
- 检索模式可查看
workflows/direct-detection-workflow.md
Step 4: Generate Reports Based on Findings
第4步:基于检测结果生成报告
- Comprehensive Upgrade Report: Breaking changes analysis with OLD vs NEW code examples, custom code warnings with ⚠️ flags, step-by-step migration plan, testing checklist and rollback plan
- app:update Preview Report: Shows exact configuration file changes (OLD vs NEW), lists new files to be created, impact assessment (HIGH/MEDIUM/LOW)
- 全面升级报告:包含新旧代码示例对比的破坏性变更分析、带⚠️标识的自定义代码警告、分步迁移计划、测试检查清单和回滚方案
- app:update预览报告:展示准确的配置文件变更(新旧对比)、待创建的新文件列表、影响程度评估(高/中/低)
Trigger Patterns
触发模式
Claude should activate this skill when user says:
Upgrade Requests:
- "Upgrade my Rails app to [version]"
- "Help me upgrade from Rails [x] to [y]"
- "What breaking changes are in Rails [version]?"
- "Plan my upgrade from [x] to [y]"
- "What Rails version am I using?"
- "Analyze my Rails app for upgrade"
- "Find breaking changes in my code"
- "Check my app for Rails [version] compatibility"
Specific Report Requests:
- "Show me the app:update changes"
- "Preview configuration changes for Rails [version]"
- "Generate the upgrade report"
- "What will change if I upgrade?"
当用户发出以下请求时,Claude应该激活本技能:
升级请求:
- "Upgrade my Rails app to [version]" / 「将我的Rails应用升级到[版本]」
- "Help me upgrade from Rails [x] to [y]" / 「帮我把Rails从[x]版本升级到[y]版本」
- "What breaking changes are in Rails [version]?" / 「Rails[版本]有哪些破坏性变更?」
- "Plan my upgrade from [x] to [y]" / 「帮我规划从[x]到[y]的升级方案」
- "What Rails version am I using?" / 「我当前用的是哪个Rails版本?」
- "Analyze my Rails app for upgrade" / 「分析我的Rails应用升级可行性」
- "Find breaking changes in my code" / 「找出我代码里的破坏性变更」
- "Check my app for Rails [version] compatibility" / 「检查我的应用和Rails[版本]的兼容性」
特定报告请求:
- "Show me the app:update changes" / 「展示app:update的变更」
- "Preview configuration changes for Rails [version]" / 「预览Rails[版本]的配置变更」
- "Generate the upgrade report" / 「生成升级报告」
- "What will change if I upgrade?" / 「升级后会有哪些变化?」
CRITICAL: Sequential Upgrade Strategy
重要说明:顺序升级策略
⚠️ Version Skipping is NOT Allowed
⚠️ 禁止跨版本升级
Rails upgrades MUST follow a sequential path. Examples:
For Rails 5.x to 8.x:
5.0.x → 5.1.x → 5.2.x → 6.0.x → 6.1.x → 7.0.x → 7.1.x → 7.2.x → 8.0.x → 8.1.xYou CANNOT skip versions. Examples:
- ❌ 5.2 → 6.1 (skips 6.0)
- ❌ 6.0 → 7.0 (skips 6.1)
- ❌ 7.0 → 8.0 (skips 7.1 and 7.2)
- ✅ 5.2 → 6.0 (correct)
- ✅ 7.0 → 7.1 (correct)
- ✅ 7.2 → 8.0 (correct)
If user requests a multi-hop upgrade (e.g., 5.2 → 8.1):
- Explain the sequential requirement
- Break it into individual hops
- Generate separate reports for each hop
- Recommend completing each hop fully before moving to next
Rails升级必须遵循顺序升级路径,示例:
从Rails 5.x升级到8.x:
5.0.x → 5.1.x → 5.2.x → 6.0.x → 6.1.x → 7.0.x → 7.1.x → 7.2.x → 8.0.x → 8.1.x禁止跨版本升级,示例:
- ❌ 5.2 → 6.1(跳过6.0版本)
- ❌ 6.0 → 7.0(跳过6.1版本)
- ❌ 7.0 → 8.0(跳过7.1和7.2版本)
- ✅ 5.2 → 6.0(正确)
- ✅ 7.0 → 7.1(正确)
- ✅ 7.2 → 8.0(正确)
如果用户请求多跳升级(例如5.2 → 8.1):
- 告知用户必须顺序升级的要求
- 将升级拆分为多个单独的升级步骤
- 为每个步骤生成单独的报告
- 建议用户完成一个步骤的全部升级后再进入下一个步骤
Supported Upgrade Paths
支持的升级路径
Legacy Rails (2.3 - 4.2)
旧版本Rails(2.3 - 4.2)
| From | To | Difficulty | Key Changes | Ruby Required |
|---|---|---|---|---|
| 2.3.x | 3.0.x | Very Hard | XSS protection, routes syntax | 1.8.7 - 1.9.3 |
| 3.0.x | 3.1.x | Medium | Asset pipeline, jQuery | 1.8.7 - 1.9.3 |
| 3.1.x | 3.2.x | Easy | Ruby 1.9.3 support | 1.8.7 - 2.0 |
| 3.2.x | 4.0.x | Hard | Strong Parameters, Turbolinks | 1.9.3+ |
| 4.0.x | 4.1.x | Medium | Spring, secrets.yml | 1.9.3+ |
| 4.1.x | 4.2.x | Medium | ActiveJob, Web Console | 1.9.3+ |
| 4.2.x | 5.0.x | Hard | ActionCable, API mode, ApplicationRecord | 2.2.2+ |
| 起始版本 | 目标版本 | 难度 | 核心变更 | 所需Ruby版本 |
|---|---|---|---|---|
| 2.3.x | 3.0.x | 非常难 | XSS防护、路由语法 | 1.8.7 - 1.9.3 |
| 3.0.x | 3.1.x | 中等 | 资源管道、jQuery | 1.8.7 - 1.9.3 |
| 3.1.x | 3.2.x | 简单 | 支持Ruby 1.9.3 | 1.8.7 - 2.0 |
| 3.2.x | 4.0.x | 难 | 强参数、Turbolinks | 1.9.3+ |
| 4.0.x | 4.1.x | 中等 | Spring、secrets.yml | 1.9.3+ |
| 4.1.x | 4.2.x | 中等 | ActiveJob、Web控制台 | 1.9.3+ |
| 4.2.x | 5.0.x | 难 | ActionCable、API模式、ApplicationRecord | 2.2.2+ |
Modern Rails (5.0 - 8.1)
新版本Rails(5.0 - 8.1)
| From | To | Difficulty | Key Changes | Ruby Required |
|---|---|---|---|---|
| 5.0.x | 5.1.x | Easy | Encrypted secrets, yarn default | 2.2.2+ |
| 5.1.x | 5.2.x | Medium | Active Storage, credentials | 2.2.2+ |
| 5.2.x | 6.0.x | Hard | Zeitwerk, Action Mailbox/Text | 2.5.0+ |
| 6.0.x | 6.1.x | Medium | Horizontal sharding, strict loading | 2.5.0+ |
| 6.1.x | 7.0.x | Hard | Hotwire/Turbo, Import Maps | 2.7.0+ |
| 7.0.x | 7.1.x | Medium | Composite keys, async queries | 2.7.0+ |
| 7.1.x | 7.2.x | Medium | Transaction-aware jobs, DevContainers | 3.1.0+ |
| 7.2.x | 8.0.x | Very Hard | Propshaft, Solid gems, Kamal | 3.2.0+ |
| 8.0.x | 8.1.x | Easy | Bundler-audit, max_connections | 3.2.0+ |
| 起始版本 | 目标版本 | 难度 | 核心变更 | 所需Ruby版本 |
|---|---|---|---|---|
| 5.0.x | 5.1.x | 简单 | 加密密钥、默认集成yarn | 2.2.2+ |
| 5.1.x | 5.2.x | 中等 | Active Storage、凭证管理 | 2.2.2+ |
| 5.2.x | 6.0.x | 难 | Zeitwerk自动加载、Action Mailbox/Text | 2.5.0+ |
| 6.0.x | 6.1.x | 中等 | 水平分库、严格加载 | 2.5.0+ |
| 6.1.x | 7.0.x | 难 | Hotwire/Turbo、Import Maps | 2.7.0+ |
| 7.0.x | 7.1.x | 中等 | 复合主键、异步查询 | 2.7.0+ |
| 7.1.x | 7.2.x | 中等 | 事务感知任务、DevContainers | 3.1.0+ |
| 7.2.x | 8.0.x | 非常难 | Propshaft、Solid全家桶gem、Kamal | 3.2.0+ |
| 8.0.x | 8.1.x | 简单 | Bundler-audit、max_connections配置 | 3.2.0+ |
Available Resources
可用资源
Core Documentation
核心文档
- - This file (entry point)
SKILL.md
- - 本文件(入口点)
SKILL.md
Version-Specific Guides (Load as needed)
特定版本指南(按需加载)
Legacy Rails:
- - Rails 3.2 → 4.0 (Strong Parameters)
version-guides/upgrade-3.2-to-4.0.md - - Rails 4.2 → 5.0 (ApplicationRecord)
version-guides/upgrade-4.2-to-5.0.md
Modern Rails:
- - Rails 5.0 → 5.1 (Encrypted secrets)
version-guides/upgrade-5.0-to-5.1.md - - Rails 5.1 → 5.2 (Active Storage, Credentials)
version-guides/upgrade-5.1-to-5.2.md - - Rails 5.2 → 6.0 (Zeitwerk)
version-guides/upgrade-5.2-to-6.0.md - - Rails 6.0 → 6.1 (Horizontal sharding)
version-guides/upgrade-6.0-to-6.1.md - - Rails 6.1 → 7.0 (Hotwire/Turbo)
version-guides/upgrade-6.1-to-7.0.md - - Rails 7.0 → 7.1 (Composite keys)
version-guides/upgrade-7.0-to-7.1.md - - Rails 7.1 → 7.2 (Transaction jobs)
version-guides/upgrade-7.1-to-7.2.md - - Rails 7.2 → 8.0 (Propshaft)
version-guides/upgrade-7.2-to-8.0.md - - Rails 8.0 → 8.1 (bundler-audit)
version-guides/upgrade-8.0-to-8.1.md
旧版本Rails:
- - Rails 3.2 → 4.0(强参数)
version-guides/upgrade-3.2-to-4.0.md - - Rails 4.2 → 5.0(ApplicationRecord)
version-guides/upgrade-4.2-to-5.0.md
新版本Rails:
- - Rails 5.0 → 5.1(加密密钥)
version-guides/upgrade-5.0-to-5.1.md - - Rails 5.1 → 5.2(Active Storage、凭证管理)
version-guides/upgrade-5.1-to-5.2.md - - Rails 5.2 → 6.0(Zeitwerk自动加载)
version-guides/upgrade-5.2-to-6.0.md - - Rails 6.0 → 6.1(水平分库)
version-guides/upgrade-6.0-to-6.1.md - - Rails 6.1 → 7.0(Hotwire/Turbo)
version-guides/upgrade-6.1-to-7.0.md - - Rails 7.0 → 7.1(复合主键)
version-guides/upgrade-7.0-to-7.1.md - - Rails 7.1 → 7.2(事务感知任务)
version-guides/upgrade-7.1-to-7.2.md - - Rails 7.2 → 8.0(Propshaft)
version-guides/upgrade-7.2-to-8.0.md - - Rails 8.0 → 8.1(bundler-audit)
version-guides/upgrade-8.0-to-8.1.md
Workflow Guides (Load when generating deliverables)
工作流指南(生成交付物时加载)
- - MANDATORY FIRST STEP - How to run and verify test suite
workflows/test-suite-verification-workflow.md - EXTERNAL DEPENDENCY: skill - MANDATORY SECOND STEP - Verify and update load_defaults to match Rails version (https://github.com/ombulabs/claude-code_rails-load-defaults-skill)
rails-load-defaults - - How to run breaking change detection directly
workflows/direct-detection-workflow.md - - How to generate upgrade reports
workflows/upgrade-report-workflow.md - - How to generate app:update previews
workflows/app-update-preview-workflow.md
- - 强制第一步 - 如何运行和验证测试套件
workflows/test-suite-verification-workflow.md - 外部依赖: 技能 - 强制第二步 - 验证和更新load_defaults匹配Rails版本 (https://github.com/ombulabs/claude-code_rails-load-defaults-skill)
rails-load-defaults - - 如何直接运行破坏性变更检测
workflows/direct-detection-workflow.md - - 如何生成升级报告
workflows/upgrade-report-workflow.md - - 如何生成app:update预览
workflows/app-update-preview-workflow.md
Examples (Load when user needs clarification)
示例(用户需要澄清时加载)
- - Single-hop upgrade example
examples/simple-upgrade.md - - Multi-hop upgrade example
examples/multi-hop-upgrade.md
- - 单跳升级示例
examples/simple-upgrade.md - - 多跳升级示例
examples/multi-hop-upgrade.md
Reference Materials
参考资料
- EXTERNAL DEPENDENCY: skill - Dual-boot setup and management with next_rails (https://github.com/ombulabs/claude-code_dual-boot-skill)
dual-boot - - Finding and fixing deprecations
reference/deprecation-warnings.md - - Keeping up with Rails releases
reference/staying-current.md - - Quick lookup
reference/breaking-changes-by-version.md - - Multi-version planning
reference/multi-hop-strategy.md - - Comprehensive testing
reference/testing-checklist.md - - Common gem version requirements
reference/gem-compatibility.md
- 外部依赖: 技能 - 使用next_rails搭建和管理双启动环境 (https://github.com/ombulabs/claude-code_dual-boot-skill)
dual-boot - - 查找和修复弃用项
reference/deprecation-warnings.md - - 跟进Rails版本发布
reference/staying-current.md - - 快速查询
reference/breaking-changes-by-version.md - - 多版本升级规划
reference/multi-hop-strategy.md - - 全面测试清单
reference/testing-checklist.md - - 常用gem版本要求
reference/gem-compatibility.md
Detection Pattern Resources
检测模式资源
- - Version-specific patterns for direct detection
detection-scripts/patterns/rails-*.yml
- - 直接检测用的特定版本匹配模式
detection-scripts/patterns/rails-*.yml
Report Templates
报告模板
- - Main upgrade report structure
templates/upgrade-report-template.md - - Configuration preview
templates/app-update-preview-template.md
- - 主升级报告结构
templates/upgrade-report-template.md - - 配置变更预览
templates/app-update-preview-template.md
High-Level Workflow
高层工作流
When user requests an upgrade, follow this workflow:
当用户请求升级时,遵循以下工作流:
Step 0: Verify Latest Patch Version (MANDATORY PRE-STEP)
第0步:确认最新补丁版本(强制前置步骤)
⚠️ THIS STEP IS REQUIRED BEFORE ANY OTHER WORK
1. Read Gemfile.lock to find exact current Rails version (e.g., 3.2.19)
2. Compare against latest patch for that series:
- EOL series (≤ 6.1): use static table in reference/multi-hop-strategy.md
- Active series (≥ 7.0): query RubyGems API (see reference/multi-hop-strategy.md for commands)
3. If current version < latest patch:
- INFORM user: "Your app is on Rails X.Y.Z but the latest patch is X.Y.W"
- Guide through Gemfile update and bundle update rails
- Run test suite after patch upgrade
- Deploy patch upgrade before proceeding
- Do NOT proceed to next minor/major until on latest patch
4. If current version == latest patch:
- Proceed to Step 1⚠️ 本步骤是所有其他工作的前置必要步骤
1. 读取Gemfile.lock获取当前准确的Rails版本(例如3.2.19)
2. 与当前系列的最新补丁版本对比:
- 已停止维护的系列(≤ 6.1):使用reference/multi-hop-strategy.md中的静态对照表
- 仍在维护的系列(≥ 7.0):查询RubyGems API(命令参考reference/multi-hop-strategy.md)
3. 如果当前版本 < 最新补丁版本:
- 告知用户:「您的应用当前运行在Rails X.Y.Z版本,最新补丁版本为X.Y.W」
- 引导用户更新Gemfile并运行bundle update rails
- 补丁升级后运行测试套件
- 补丁版本部署后再继续升级流程
- 未升级到最新补丁版本前不要进行次版本/主版本升级
4. 如果当前版本 == 最新补丁版本:
- 进入第1步Step 1: Run Test Suite (MANDATORY FIRST STEP)
第1步:运行测试套件(强制第一步)
⚠️ THIS STEP IS REQUIRED BEFORE ANY OTHER WORK
1. Read: workflows/test-suite-verification-workflow.md
2. Detect test framework (RSpec, Minitest, or both)
3. Run test suite with: bundle exec rspec OR bundle exec rails test
4. Capture results: total tests, passing, failing, pending
5. If ANY tests fail:
- STOP the upgrade process
- Report failing tests to user
- Offer to help fix failing tests
- Do NOT proceed until all tests pass
6. If all tests pass:
- Record baseline metrics (test count, coverage if available)
- Proceed to Step 2⚠️ 本步骤是所有其他工作的前置必要步骤
1. 读取:workflows/test-suite-verification-workflow.md
2. 检测测试框架(RSpec、Minitest或两者都有)
3. 运行测试套件:bundle exec rspec 或者 bundle exec rails test
4. 捕获结果:总测试数、通过数、失败数、 pending数
5. 如果有任何测试失败:
- 暂停升级流程
- 向用户报告失败的测试
- 主动提供协助修复测试的支持
- 所有测试通过前不要继续升级流程
6. 如果所有测试通过:
- 记录基准指标(测试数、覆盖率(如果有))
- 进入第2步Step 2: Detect Current Version & Verify load_defaults (BLOCKING STEP)
第2步:检测当前版本并验证load_defaults(阻塞步骤)
⚠️ THIS STEP MAY BLOCK THE UPGRADE
1. Read Gemfile to find current Rails gem version
2. Read config/application.rb for load_defaults version
3. Compare rails_gem_version with load_defaults_version
4. If load_defaults_version < rails_gem_version:
- DELEGATE to the rails-load-defaults skill for incremental update
- That skill walks through each config change one at a time, grouped by risk tier
- Tests are re-run between each change
- Do NOT proceed until load_defaults matches the current Rails version
5. If load_defaults_version == rails_gem_version:
- Proceed to Step 3⚠️ 本步骤可能会阻塞升级流程
1. 读取Gemfile获取当前Rails gem版本
2. 读取config/application.rb获取load_defaults版本
3. 对比rails_gem_version和load_defaults_version
4. 如果load_defaults_version < rails_gem_version:
- 委托给rails-load-defaults技能进行增量更新
- 该技能会按风险等级分组,逐个处理配置变更
- 每次变更后都会重新运行测试
- load_defaults匹配当前Rails版本前不要继续升级流程
5. 如果load_defaults_version == rails_gem_version:
- 进入第3步Step 3: Set Up Dual-Boot with next_rails (IF NOT ALREADY SET UP)
第3步:使用next_rails搭建双启动环境(如果还未搭建)
DELEGATE to the dual-boot skill for setup and initialization.
That skill handles:
- Checking if Gemfile.next already exists (to avoid duplicate next? method)
- Adding next_rails gem and running next_rails --init
- Installing dependencies for both Rails versions
- Configuring the Gemfile with if next? conditionals委托给dual-boot技能进行配置和初始化。
该技能会处理:
- 检查Gemfile.next是否已经存在(避免重复的next?方法)
- 添加next_rails gem并运行next_rails --init
- 安装两个Rails版本的依赖
- 使用if next?条件配置GemfileStep 4: Validate Upgrade Path
第4步:验证升级路径
1. Check if upgrade is single-hop or multi-hop
2. If multi-hop, explain sequential requirement
3. Plan individual hops1. 检查是单跳升级还是多跳升级
2. 如果是多跳升级,告知用户必须顺序升级的要求
3. 规划单独的升级步骤Step 5: Run Breaking Changes Detection (DIRECT)
第5步:运行破坏性变更检测(直接执行)
Claude runs detection directly using tools - NO script generation needed
1. Read: workflows/direct-detection-workflow.md
2. Read: detection-scripts/patterns/rails-{VERSION}-patterns.yml
3. For each pattern in the patterns file:
- Use Grep tool to search for the pattern
- Collect file paths and line numbers
- Store findings with context
4. Read: version-guides/upgrade-{FROM}-to-{TO}.md for context
5. Compile all findings into structured dataClaude直接使用工具运行检测 - 无需生成脚本
1. 读取:workflows/direct-detection-workflow.md
2. 读取:detection-scripts/patterns/rails-{VERSION}-patterns.yml
3. 遍历模式文件中的每个模式:
- 使用Grep工具搜索匹配模式
- 收集文件路径和行号
- 存储检测结果和上下文
4. 读取:version-guides/upgrade-{FROM}-to-{TO}.md获取上下文
5. 将所有检测结果整理为结构化数据Step 6: Load Report Resources & Generate Reports
第6步:加载报告资源并生成报告
1. Read: templates/upgrade-report-template.md
2. Read: templates/app-update-preview-template.md
3. Read: workflows/upgrade-report-workflow.md
4. Read: workflows/app-update-preview-workflow.mdDeliverable #1: Comprehensive Upgrade Report
- Input: Direct detection findings + version guide data
- Output: Report with real code examples from user's project
Deliverable #2: app:update Preview
- Input: Actual config files + findings
- Output: Preview with real file paths and changes
1. 读取:templates/upgrade-report-template.md
2. 读取:templates/app-update-preview-template.md
3. 读取:workflows/upgrade-report-workflow.md
4. 读取:workflows/app-update-preview-workflow.md交付物1:全面升级报告
- 输入: 直接检测结果 + 版本指南数据
- 输出: 包含用户项目真实代码示例的报告
交付物2:app:update预览
- 输入: 实际配置文件 + 检测结果
- 输出: 包含真实文件路径和变更的预览
Step 7: Present Reports & Offer Help
第7步:展示报告并提供支持
1. Present Comprehensive Upgrade Report first
2. Present app:update Preview Report second
3. Explain next steps
4. Offer to help implement changes1. 先展示全面升级报告
2. 再展示app:update预览报告
3. 说明后续步骤
4. 主动提供协助实现变更的支持Pre-Upgrade Checklist (FastRuby.io Best Practices)
前置检查清单(FastRuby.io最佳实践)
Before starting ANY upgrade:
开始任何升级前:
1. Test Coverage Assessment (AUTOMATED - Step 1 of Workflow)
1. 测试覆盖率评估(自动执行 - 工作流第1步)
- Run test suite - all tests passing? ← Claude runs this automatically
- Check test coverage (aim for >70%) ← Claude captures this if SimpleCov is configured
- Review critical paths have coverage
Note: This step is now automated. Claude will run the test suite and BLOCK the upgrade if any tests fail.
- 运行测试套件 - 所有测试是否通过? ← Claude自动运行
- 检查测试覆盖率(目标>70%) ← 如果配置了SimpleCov,Claude会自动捕获
- 确认核心路径有测试覆盖
注意: 本步骤已自动化。Claude会运行测试套件,如果有测试失败会阻塞升级流程。
2. Dependency Audit
2. 依赖审计
- Run
bundle outdated - Check gem compatibility with target Rails version
- Identify gems that need upgrading first
- 运行
bundle outdated - 检查gem与目标Rails版本的兼容性
- 识别需要优先升级的gem
3. Database Backup
3. 数据库备份
- Backup production database
- Backup development/staging databases
- Verify backup restore process works
- 备份生产数据库
- 备份开发/测试环境数据库
- 验证备份恢复流程可用
4. Git Branch Strategy
4. Git分支策略
- Create upgrade branch from main/master
- Set up CI for upgrade branch
- Plan merge strategy
- 从main/master分支创建升级分支
- 为升级分支配置CI
- 规划合并策略
5. Deprecation Warnings
5. 弃用警告处理
- Run app with
RAILS_DEPRECATION_WARNINGS=1 - Address existing deprecation warnings
- Enable verbose deprecations in test environment
- 使用运行应用
RAILS_DEPRECATION_WARNINGS=1 - 处理现有弃用警告
- 在测试环境开启详细弃用提醒
Common Request Patterns
常见请求模式
Pattern 1: Full Upgrade Request
模式1:全量升级请求
User says: "Upgrade my Rails app to 8.1"
Action - Step 0 (MANDATORY: Verify Latest Patch):
- Read for exact Rails version
Gemfile.lock - Compare against latest patch for that series (see )
reference/multi-hop-strategy.md - If not on latest patch → Guide user through patch upgrade first
- If on latest patch → Proceed to Step 1
Action - Step 1 (MANDATORY: Verify Tests Pass):
- Load:
workflows/test-suite-verification-workflow.md - Detect test framework (RSpec or Minitest)
- Run test suite: or
bundle exec rspecbundle exec rails test - If tests FAIL → STOP and help fix tests first
- If tests PASS → Record baseline and proceed
Action - Step 2 (MANDATORY: Verify load_defaults):
- Read Gemfile.lock for current Rails gem version
- Read config/application.rb for load_defaults version
- If load_defaults < Rails gem version:
- INFORM user: "Your app uses Rails X.Y but load_defaults is set to X.Z"
- DELEGATE to the skill for incremental, tiered update
rails-load-defaults - That skill handles per-config analysis, test runs, and risk assessment
- If load_defaults matches → Proceed to Step 3
Action - Step 3 (Run Detection Directly):
- Validate upgrade path
- Load:
workflows/direct-detection-workflow.md - Load:
detection-scripts/patterns/rails-{VERSION}-patterns.yml - Use Grep/Glob/Read tools to search for each pattern
- Collect findings with file:line references
Action - Step 4 (Generate Reports):
- Load:
workflows/upgrade-report-workflow.md - Load:
workflows/app-update-preview-workflow.md - Generate Comprehensive Upgrade Report (using direct findings)
- Generate app:update Preview (using actual config files)
- Present both reports to user
- Offer to help implement changes
用户说: "Upgrade my Rails app to 8.1" / 「将我的Rails应用升级到8.1」
操作 - 第0步(强制:验证最新补丁版本):
- 读取获取准确的Rails版本
Gemfile.lock - 与当前系列的最新补丁版本对比(见)
reference/multi-hop-strategy.md - 如果未运行最新补丁版本 → 先引导用户完成补丁版本升级
- 如果已经运行最新补丁版本 → 进入第1步
操作 - 第1步(强制:验证测试通过):
- 加载:
workflows/test-suite-verification-workflow.md - 检测测试框架(RSpec或Minitest)
- 运行测试套件:或
bundle exec rspecbundle exec rails test - 如果测试失败 → 暂停升级,先协助修复测试
- 如果测试通过 → 记录基准数据,继续下一步
操作 - 第2步(强制:验证load_defaults):
- 读取获取当前Rails gem版本
Gemfile.lock - 读取config/application.rb获取load_defaults版本
- 如果load_defaults < Rails gem版本:
- 告知用户:「您的应用使用Rails X.Y版本,但load_defaults配置为X.Z」
- 委托给技能进行增量分级更新
rails-load-defaults - 该技能会处理逐配置分析、测试运行和风险评估
- 如果load_defaults匹配 → 进入第3步
操作 - 第3步(直接运行检测):
- 验证升级路径
- 加载:
workflows/direct-detection-workflow.md - 加载:
detection-scripts/patterns/rails-{VERSION}-patterns.yml - 使用Grep/Glob/读取工具搜索每个匹配模式
- 收集检测结果和「文件:行号」引用
操作 - 第4步(生成报告):
- 加载:
workflows/upgrade-report-workflow.md - 加载:
workflows/app-update-preview-workflow.md - 生成全面升级报告(使用直接检测结果)
- 生成app:update预览(使用实际配置文件)
- 向用户展示两份报告
- 主动提供协助实现变更的支持
Pattern 2: Multi-Hop Request
模式2:多跳升级请求
User says: "Help me upgrade from Rails 5.2 to 8.1"
Action - Step 0 (MANDATORY: Verify Latest Patch):
- Check exact current version from
Gemfile.lock - If not on latest patch of current series → Upgrade to latest patch first
- For multi-hop: This check applies at the START and again after each hop
Action - Step 1 (MANDATORY: Verify Tests Pass):
- Run test suite BEFORE planning any upgrade work
- If tests fail → STOP and fix first
- If tests pass → Proceed with planning
Action - Step 2 (MANDATORY: Verify load_defaults):
- Check if load_defaults matches current Rails version
- If mismatched → Recommend updating load_defaults FIRST
- For multi-hop: Ensure load_defaults is current before starting
Action - Step 3 (Plan & Execute):
- Explain sequential requirement
- Calculate hops: 5.2 → 6.0 → 6.1 → 7.0 → 7.1 → 7.2 → 8.0 → 8.1
- Reference:
reference/multi-hop-strategy.md - Follow Pattern 1 for FIRST hop (5.2 → 6.0)
- After first hop complete, repeat for next hops
- IMPORTANT: After each hop, ensure load_defaults is updated before next hop
用户说: "Help me upgrade from Rails 5.2 to 8.1" / 「帮我把Rails从5.2升级到8.1」
操作 - 第0步(强制:验证最新补丁版本):
- 从获取当前准确版本
Gemfile.lock - 如果未运行当前系列的最新补丁版本 → 先升级到最新补丁版本
- 多跳升级场景:本检查在升级开始时和每个升级步骤完成后都需要执行
操作 - 第1步(强制:验证测试通过):
- 规划任何升级工作前先运行测试套件
- 如果测试失败 → 暂停升级,先修复测试
- 如果测试通过 → 进入规划阶段
操作 - 第2步(强制:验证load_defaults):
- 检查load_defaults是否与当前Rails版本匹配
- 如果不匹配 → 建议优先更新load_defaults
- 多跳升级场景:开始升级前确保load_defaults是当前版本
操作 - 第3步(规划与执行):
- 告知用户必须顺序升级的要求
- 计算升级步骤:5.2 → 6.0 → 6.1 → 7.0 → 7.1 → 7.2 → 8.0 → 8.1
- 参考:
reference/multi-hop-strategy.md - 按照模式1处理第一步升级(5.2 → 6.0)
- 第一步升级完成后,重复流程处理后续步骤
- 重要提醒: 每个步骤完成后,进入下一个步骤前必须更新load_defaults
Pattern 3: Breaking Changes Analysis Only
模式3:仅破坏性变更分析
User says: "What breaking changes affect my app for Rails 8.0?"
Action - Step 0 (MANDATORY: Verify Latest Patch):
- Check if on latest patch — warn if not, recommend patching first
Action - Step 1 (MANDATORY: Verify Tests Pass):
- Run test suite first
- If tests fail → Warn user and recommend fixing first
- If tests pass → Proceed with analysis
Action - Step 2 (MANDATORY: Verify load_defaults):
- Check load_defaults alignment
- If mismatched → Recommend updating first
Action - Step 3 (Run Detection):
- Load:
workflows/direct-detection-workflow.md - Run detection directly using tools
- Present findings summary
- Offer to generate full upgrade report
用户说: "What breaking changes affect my app for Rails 8.0?" / 「Rails 8.0有哪些会影响我的应用的破坏性变更?」
操作 - 第0步(强制:验证最新补丁版本):
- 检查是否运行最新补丁版本 — 如果没有发出警告,建议先升级补丁版本
操作 - 第1步(强制:验证测试通过):
- 先运行测试套件
- 如果测试失败 → 向用户发出警告,建议先修复测试
- 如果测试通过 → 进入分析阶段
操作 - 第2步(强制:验证load_defaults):
- 检查load_defaults是否匹配
- 如果不匹配 → 建议优先更新
操作 - 第3步(运行检测):
- 加载:
workflows/direct-detection-workflow.md - 使用工具直接运行检测
- 展示检测结果摘要
- 主动提供生成完整升级报告的支持
Quality Checklist
质量检查清单
Before delivering, verify:
For Direct Detection:
- All patterns from version-specific YAML file checked
- Grep/Glob tools used correctly for each pattern
- File:line references collected for all findings
- Context captured for each finding
For Comprehensive Upgrade Report:
- All {PLACEHOLDERS} replaced with actual values
- Used ACTUAL findings from direct detection (not generic examples)
- Breaking changes section includes real file:line references
- Custom code warnings based on actual detected issues
- Code examples use user's actual code from affected files
- Next steps clearly outlined
For app:update Preview:
- All {PLACEHOLDERS} replaced with actual values
- File list matches user's actual config files
- Diffs based on real current config vs target version
- Next steps clearly outlined
交付前验证:
直接检测相关:
- 版本专属YAML文件中的所有模式都已检查
- 每个模式都正确使用了Grep/Glob工具
- 所有检测结果都收集了「文件:行号」引用
- 每个检测结果都捕获了上下文
全面升级报告相关:
- 所有{占位符}都已替换为实际值
- 使用了直接检测的真实结果(不是通用示例)
- 破坏性变更部分包含真实的「文件:行号」引用
- 自定义代码警告基于实际检测到的问题
- 代码示例使用了用户受影响文件中的真实代码
- 后续步骤清晰明确
app:update预览相关:
- 所有{占位符}都已替换为实际值
- 文件列表与用户的实际配置文件匹配
- 差异基于真实的当前配置与目标版本对比
- 后续步骤清晰明确
Key Principles
核心原则
- ALWAYS Verify Latest Patch First (MANDATORY - ensure app is on latest patch of current series before any version hop)
- ALWAYS Run Test Suite (MANDATORY - no exceptions, no upgrade work until tests pass)
- Block on Failing Tests (if tests fail, STOP and help fix them before any upgrade work)
- ALWAYS Verify load_defaults (MANDATORY - check if load_defaults matches current Rails version)
- Recommend Updating load_defaults First (if behind current Rails, update load_defaults BEFORE upgrading to next version)
- Run Detection Directly (use Grep/Glob/Read tools - no script generation needed)
- Always Use Actual Findings (no generic examples in reports)
- Always Flag Custom Code (with ⚠️ warnings based on detected issues)
- Always Use Templates (for consistency)
- Always Check Quality (before delivery)
- Load Workflows as Needed (don't hold everything in memory)
- Sequential Process is Critical (patch check → tests → load_defaults check → detection → reports)
- Follow FastRuby.io Methodology (incremental upgrades, assessment first)
- Always Use for Dual-Boot Code (NEVER use
NextRails.next?for version branching. DELEGATE to therespond_to?skill for patterns and setup.)dual-boot
- 始终优先验证最新补丁版本(强制要求 - 任何版本升级前确保应用运行在当前系列的最新补丁版本)
- 始终运行测试套件(强制要求 - 无例外,测试通过前不进行任何升级工作)
- 测试失败时阻塞流程(如果测试失败,暂停升级先协助修复问题)
- 始终验证load_defaults(强制要求 - 检查load_defaults是否与当前Rails版本匹配)
- 建议优先更新load_defaults(如果落后于当前Rails版本,升级到下一个版本前先更新load_defaults)
- 直接运行检测(使用Grep/Glob/读取工具 - 无需生成脚本)
- 始终使用真实检测结果(报告中不使用通用示例)
- 始终标记自定义代码(基于检测到的问题添加⚠️警告)
- 始终使用模板(保证一致性)
- 交付前始终检查质量
- 按需加载工作流(不需要将所有内容都保存在内存中)
- 顺序流程至关重要(补丁检查 → 测试 → load_defaults检查 → 检测 → 报告)
- 遵循FastRuby.io方法论(增量升级、评估优先)
- 双启动代码始终使用(禁止使用
NextRails.next?做版本分支。模式和配置请委托给respond_to?技能处理。)dual-boot
Success Criteria
成功标准
A successful upgrade assistance session:
✅ Verified latest patch version (Step 0 - MANDATORY)
✅ Upgraded to latest patch if needed (before any minor/major hop)
✅ Ran test suite (Step 1 - MANDATORY)
✅ Verified all tests pass (blocked if tests failed)
✅ Recorded baseline metrics (test count, coverage)
✅ Checked load_defaults alignment (Step 2 - MANDATORY)
✅ Recommended load_defaults update if behind (asked user before proceeding)
✅ Updated load_defaults if user agreed (re-ran tests after update)
✅ Ran detection directly (using Grep/Glob/Read tools - no script)
✅ Generated Comprehensive Upgrade Report using actual findings
✅ Generated app:update Preview using actual config files
✅ Used user's actual code from findings (not generic examples)
✅ Flagged all custom code with ⚠️ warnings based on detected issues
✅ Provided clear next steps
✅ Offered to help implement changes
See CHANGELOG.md for version history and current version.
成功的升级协助会话需要满足:
✅ 验证了最新补丁版本(第0步 - 强制要求)
✅ 如果需要已升级到最新补丁版本(任何次版本/主版本升级前)
✅ 运行了测试套件(第1步 - 强制要求)
✅ 验证所有测试通过(测试失败时阻塞流程)
✅ 记录了基准指标(测试数、覆盖率)
✅ 检查了load_defaults匹配情况(第2步 - 强制要求)
✅ 如果load_defaults落后已建议更新(继续流程前征求用户同意)
✅ 如果用户同意已更新load_defaults(更新后重新运行测试)
✅ 直接运行了检测(使用Grep/Glob/读取工具 - 无脚本)
✅ 使用真实检测结果生成了全面升级报告
✅ 使用真实配置文件生成了app:update预览
✅ 使用了检测到的用户真实代码(不是通用示例)
✅ 基于检测到的问题为所有自定义代码添加了⚠️警告
✅ 提供了清晰的后续步骤
✅ 主动提供了协助实现变更的支持
版本历史和当前版本请查看CHANGELOG.md。