|
5 | 5 |
|
6 | 6 | - [Why migrate?](#why-migrate) |
7 | 7 | - [Steps to migrate](#steps-to-migrate) |
| 8 | +- [LLM-assisted migration prompt](#llm-assisted-migration-prompt) |
8 | 9 |
|
9 | 10 | <!-- END doctoc generated TOC please keep comment here to allow auto update --> |
10 | 11 |
|
@@ -61,3 +62,43 @@ In this guide, it is assumed that you have upgraded the `react-rails` project to |
61 | 62 |
|
62 | 63 | You can also check [react-rails-to-react-on-rails](https://github.com/shakacode/react-rails-example-app/tree/react-rails-to-react-on-rails) branch on [react-rails example app](https://github.com/shakacode/react-rails-example-app) for an example of migration from `react-rails` v3 to `react_on_rails` v13.4. |
63 | 64 |
|
| 65 | +## LLM-assisted migration prompt |
| 66 | + |
| 67 | +You can usually do a safe first-pass migration quickly with a coding assistant. Give it this prompt: |
| 68 | + |
| 69 | +If your assistant cannot browse URLs, paste this migration guide content directly into the prompt context before running the template. |
| 70 | + |
| 71 | +```text |
| 72 | +You are a senior Rails + React engineer. Migrate this app from react-rails to react_on_rails. |
| 73 | + |
| 74 | +Before starting, ask me for the relevant files (at minimum: Gemfile, package.json, JS entrypoints, config/initializers, and representative react_component usages). |
| 75 | + |
| 76 | +Use this guide as the source of truth: |
| 77 | +https://github.com/reactjs/react-rails/blob/main/docs/migrating-from-react-rails-to-react_on_rails.md |
| 78 | + |
| 79 | +Requirements: |
| 80 | +1. Keep changes minimal and production-safe. |
| 81 | +2. Work in clear phases: |
| 82 | + - dependencies |
| 83 | + - installer changes |
| 84 | + - bundle entry points |
| 85 | + - view helper updates |
| 86 | + - cleanup |
| 87 | +3. At each phase: |
| 88 | + - explain what changed and why |
| 89 | + - show commands run |
| 90 | + - show exact files changed |
| 91 | +4. Do not remove behavior unless you explain the replacement. |
| 92 | +5. After each phase, tell me the exact test/lint commands to run and wait for my output before continuing. |
| 93 | +6. End with: |
| 94 | + - a migration checklist |
| 95 | + - rollback steps |
| 96 | + - a PR summary with risk level |
| 97 | +7. Add safety checks: |
| 98 | + - if `rails g react_on_rails:install` fails to install JS deps, run the install commands shown by the generator |
| 99 | + - remove leftover `react_ujs` / `ReactRailsUJS` references |
| 100 | + - remove or replace stale `server_rendering.js` entries if present |
| 101 | + - if using Shakapacker, run `bundle exec rails shakapacker:compile` and fix compile errors before finalizing |
| 102 | +``` |
| 103 | + |
| 104 | +Review all generated diffs before merging. |
0 commit comments