skill-rails-upgrade by sickn33/antigravity-awesome-skills
npx skills add https://github.com/sickn33/antigravity-awesome-skills --skill skill-rails-upgrade分析 Rails 应用并提供升级评估
在处理分析 Rails 应用并提供升级评估时使用此技能。
分析当前的 Rails 应用程序,并提供包含选择性文件合并的全面升级评估。
通过查找以下文件来检查我们是否在 Rails 应用程序中:
Gemfile(必须存在且包含 'rails')config/application.rb(Rails 应用程序配置)config/environment.rb(Rails 环境)如果缺少其中任何一个文件或文件内容未表明是 Rails 应用,请停止并告知用户这似乎不是一个 Rails 应用程序。
从以下位置提取当前 Rails 版本:
Gemfile.lock 以获取确切的已安装版本(查找 rails (x.y.z))Gemfile 中的版本约束广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
报告确切的当前版本(例如,7.1.3)。
使用 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'
比较当前版本和最新版本以对升级进行分类:
使用 WebFetch 获取官方的 Rails 升级指南:
URL: https://guides.rubyonrails.org/upgrading_ruby_on_rails.html
查找与版本跨越相关的部分。该指南按目标版本组织,包含以下部分:
提取并总结与用户特定升级路径相关的部分。
使用 WebFetch 从 railsdiff.org 获取版本间的差异:
URL: https://railsdiff.org/{current_version}/{target_version}
例如:https://railsdiff.org/7.1.3/8.0.0
这显示了:
bin/ 脚本的变更总结关键的文件变更。
Rails 应用程序通常包含应随 Rails 一起更新的 JavaScript 包。检查并报告这些依赖项。
检查应用程序使用哪个包管理器:
# 检查是否存在 package.json (npm/yarn)
ls package.json 2>/dev/null
# 检查是否存在 importmap (Rails 7+)
ls config/importmap.rb 2>/dev/null
如果存在 package.json,检查以下与 Rails 相关的包:
# 提取与 Rails 相关的包的当前版本
cat package.json | grep -E '"@hotwired/|"@rails/|"stimulus"|"turbo-rails"' || echo "未找到 Rails JS 包"
需要检查的关键包:
| 包 | 用途 | 版本对齐 |
|---|---|---|
@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 版本时代匹配 |
对于 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
如果应用程序使用 importmap-rails,检查 config/importmap.rb 中的固定版本:
cat config/importmap.rb | grep -E 'pin.*turbo|pin.*stimulus|pin.*@rails' || echo "未找到 importmap 固定版本"
更新 importmap 固定版本:
bin/importmap pin @hotwired/turbo-rails
bin/importmap pin @hotwired/stimulus
在升级摘要中包含:
### JavaScript 依赖项
**包管理器**: [npm/yarn/importmap/无]
| 包 | 当前版本 | 最新版本 | 操作 |
|---------|---------|--------|--------|
| @hotwired/turbo-rails | 8.0.4 | 8.0.12 | 建议更新 |
| @rails/actioncable | 7.1.0 | 8.0.0 | 随 Rails 更新 |
| ... | ... | ... | ... |
**推荐的 JS 更新:**
- 运行 `npm update @hotwired/turbo-rails`(或 yarn 等效命令)
- 运行 `npm update @rails/actioncable @rails/activestorage` 以匹配 Rails 版本
提供包含步骤 1-7 所有发现的全面摘要:
根据以下因素将升级评级为 小、中 或 大:
| 因素 | 小 | 中 | 大 |
|---|---|---|---|
| 版本跨越 | 仅补丁 | 次版本 | 主版本 |
| 破坏性变更 | 无 | 少量,文档完善 | 许多,重大 |
| 配置变更 | 最少 | 中等 | 广泛 |
| 弃用项 | 无活跃项 | 一些需要处理 | 许多需要重构 |
| 依赖项 | 兼容 | 需要一些更新 | 主要依赖项更新 |
列出用户需要处理的最重要变更:
bundle update railsrails app:update - 使用下面的选择性合并流程分析 Rails 应用并提供升级评估
在处理分析 Rails 应用并提供升级评估时使用此技能。
rails app:update)重要提示: 不要运行 rails app:update,因为它会在不考虑本地自定义的情况下覆盖文件。相反,请遵循此选择性合并流程:
在进行任何升级之前,识别具有本地自定义的文件:
# 检查未提交的更改
git status
# 列出与全新 Rails 应用不同的配置文件
# 这些是我们需要谨慎处理的文件
git diff HEAD --name-only -- config/ bin/ public/
创建这些类别文件的心理清单:
根据步骤 6 中的 railsdiff 输出,对每个更改的文件进行分类:
| 类别 | 操作 | 示例 |
|---|---|---|
| 新文件 | 直接创建 | config/initializers/new_framework_defaults_X_Y.rb |
| 本地未更改 | 安全覆盖 | public/404.html(如果未自定义) |
| 本地已自定义 | 需要手动合并 | config/application.rb、bin/dev |
| 仅注释变更 | 通常跳过 | 配置文件中的次要注释更新 |
向用户呈现清晰的升级计划:
## 升级计划:Rails X.Y.Z → A.B.C
### 新文件(将被创建):
- config/initializers/new_framework_defaults_A_B.rb
- bin/ci(新的 CI 脚本)
### 安全更新(无本地自定义):
- public/400.html
- public/404.html
- public/500.html
### 需要手动合并(检测到本地自定义):
- config/application.rb
└─ 本地:i18n 配置
└─ Rails:[如有,描述新的 Rails 变更]
- config/environments/development.rb
└─ 本地:letter_opener 邮件程序配置
└─ Rails:[描述新的 Rails 变更]
- bin/dev
└─ 本地:foreman + Procfile.dev 设置
└─ Rails:更改为简单的 ruby 脚本
### 跳过(仅注释变更或不相关变更):
- config/puma.rb(仅注释变更)
用户确认计划后:
直接使用 railsdiff 中的内容或通过从全新的 Rails 应用中提取来创建它们:
# 生成一个临时的全新 Rails 应用以提取新文件
cd /tmp && rails new rails_template --skip-git --skip-bundle
# 然后复制所需的文件
或使用 Rails 生成器生成特定文件:
bin/rails app:update:configs # 仅更新配置文件,仍然是交互式的
覆盖这些文件,因为它们没有本地自定义。
对于每个需要合并的文件,向用户展示:
config/application.rb 的合并示例:
# 保留本地自定义:
config.i18n.available_locales = [:de, :en]
config.i18n.default_locale = :de
config.i18n.fallbacks = [:en]
# 添加新的 Rails 8.1 设置(如果需要):
# (通常不需要 - 新的默认值通过 new_framework_defaults 文件引入)
文件更新后,运行任何新的迁移:
bin/rails db:migrate
检查已添加的新迁移:
ls -la db/migrate/ | tail -10
完成合并后:
启动 Rails 服务器并检查错误:
bin/dev # 或 bin/rails server
检查 Rails 控制台:
bin/rails console
运行测试套件:
bin/rails test
查看日志中的弃用警告
验证应用程序正常工作后:
审查 config/initializers/new_framework_defaults_X_Y.rb
逐个启用每个新默认值,每次启用后进行测试
所有默认值都启用并测试后,更新 config/application.rb:
config.load_defaults X.Y # 更新到新版本
删除 new_framework_defaults_X_Y.rb 文件
分析 Rails 应用并提供升级评估
在处理分析 Rails 应用并提供升级评估时使用此技能。
gh CLI 未认证,请指导用户运行 gh auth logingit checkout 恢复原状每周安装数
92
仓库
GitHub 星标数
27.1K
首次出现
2026年2月2日
安全审计
安装于
opencode90
github-copilot89
codex89
kimi-cli87
gemini-cli87
amp87
Analyze Rails apps and provide upgrade assessments
Use this skill when working with analyze rails apps and provide upgrade assessments.
Analyze the current Rails application and provide a comprehensive upgrade assessment with selective file merging.
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.
Extract the current Rails version from:
Gemfile.lock for the exact installed version (look for rails (x.y.z))Gemfile for the version constraintReport the exact current version (e.g., 7.1.3).
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'
Compare current and latest versions to classify the upgrade:
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:
Extract and summarize the relevant sections for the user's specific upgrade path.
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:
Summarize the key file changes.
Rails applications often include JavaScript packages that should be updated alongside Rails. Check for and report on these dependencies.
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
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 |
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
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
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
Provide a comprehensive summary including all findings from Steps 1-7:
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 |
List the most important changes the user needs to handle:
bundle update railsrails app:update directly - use the selective merge process belowAnalyze Rails apps and provide upgrade assessments
Use this skill when working with analyze rails apps and provide upgrade assessments.
rails app:update)IMPORTANT: Do NOT run rails app:update as it overwrites files without considering local customizations. Instead, follow this selective merge process:
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:
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 |
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)
After user confirms the plan:
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
Overwrite these files as they have no local customizations.
For each file needing merge, show the user:
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)
After file updates, run any new migrations:
bin/rails db:migrate
Check for new migrations that were added:
ls -la db/migrate/ | tail -10
After completing the merge:
Start the Rails server and check for errors:
bin/dev # or bin/rails server
Check the Rails console:
bin/rails console
Run the test suite:
bin/rails test
Review deprecation warnings in logs
After verifying the app works:
Review config/initializers/new_framework_defaults_X_Y.rb
Enable each new default one by one, testing after each
Once all defaults are enabled and tested, update config/application.rb:
config.load_defaults X.Y # Update to new version
Delete the new_framework_defaults_X_Y.rb file
Analyze Rails apps and provide upgrade assessments
Use this skill when working with analyze rails apps and provide upgrade assessments.
gh CLI is not authenticated, instruct the user to run gh auth logingit checkout to restore if neededWeekly Installs
92
Repository
GitHub Stars
27.1K
First Seen
Feb 2, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode90
github-copilot89
codex89
kimi-cli87
gemini-cli87
amp87
| Rich text editing |
| Should match Rails version |
@rails/request.js | Rails UJS replacement | Should match Rails version era |