$npx -y skills add ombulabs/claude-code_rails-load-defaults-skill --skill rails-load-defaultsIncrementally upgrade Rails config.load_defaults by walking through each new_framework_defaults config one at a time. Use this skill whenever the user mentions load_defaults upgrade, new_framework_defaults, framework defaults, or wants to bring their Rails app's default configu
| 1 | # Rails load_defaults Upgrade Skill |
| 2 | |
| 3 | This skill guides the incremental upgrade of `config.load_defaults` in a Rails |
| 4 | application. The process walks through each config introduced in a new Rails |
| 5 | version, one at a time, so the user can test each change in isolation. |
| 6 | |
| 7 | ## Overview |
| 8 | |
| 9 | When a Rails app has a `load_defaults` version lower than its Rails version, |
| 10 | there are framework default configs that need to be adopted. This skill: |
| 11 | |
| 12 | 1. Detects the current `load_defaults` version |
| 13 | 2. Determines the next target version |
| 14 | 3. Generates the `new_framework_defaults_X_Y.rb` initializer with all configs commented |
| 15 | 4. Walks through each config one by one, analyzing the codebase to recommend values |
| 16 | 5. Waits for the user to test/commit each change before moving to the next |
| 17 | 6. Consolidates into `config/application.rb` when all configs are done |
| 18 | |
| 19 | ## Step 1: Detect Current State |
| 20 | |
| 21 | Read `config/application.rb` and look for: |
| 22 | ```ruby |
| 23 | config.load_defaults X.Y |
| 24 | ``` |
| 25 | |
| 26 | Also check if a `config/initializers/new_framework_defaults_*.rb` file already |
| 27 | exists (the user may be mid-upgrade). |
| 28 | |
| 29 | Report to the user: |
| 30 | - Current `load_defaults` version |
| 31 | - Current Rails version (from Gemfile.lock) |
| 32 | - Which version transitions are needed (e.g., 6.1 → 7.0 → 7.1 → 7.2) |
| 33 | |
| 34 | ## Step 2: Load Version Config Reference |
| 35 | |
| 36 | Read the appropriate config reference file for the target version: |
| 37 | |
| 38 | - **5.0**: `configs/5_0.yml` |
| 39 | - **5.1**: `configs/5_1.yml` |
| 40 | - **5.2**: `configs/5_2.yml` |
| 41 | - **6.0**: `configs/6_0.yml` |
| 42 | - **6.1**: `configs/6_1.yml` |
| 43 | - **7.0**: `configs/7_0.yml` |
| 44 | - **7.1**: `configs/7_1.yml` |
| 45 | - **7.2**: `configs/7_2.yml` |
| 46 | |
| 47 | Each config file contains entries organized into tiers with lookup patterns |
| 48 | and decision trees for each config. |
| 49 | |
| 50 | ## Step 3: Create the Initializer File |
| 51 | |
| 52 | If no `new_framework_defaults_X_Y.rb` exists yet, copy the template from |
| 53 | the `templates/` directory into the app's `config/initializers/`: |
| 54 | |
| 55 | - **5.0**: Copy `templates/new_framework_defaults_5_0.rb` → `config/initializers/new_framework_defaults_5_0.rb` |
| 56 | - **5.1**: Copy `templates/new_framework_defaults_5_1.rb` → `config/initializers/new_framework_defaults_5_1.rb` |
| 57 | - **5.2**: Copy `templates/new_framework_defaults_5_2.rb` → `config/initializers/new_framework_defaults_5_2.rb` |
| 58 | - **6.0**: Copy `templates/new_framework_defaults_6_0.rb` → `config/initializers/new_framework_defaults_6_0.rb` |
| 59 | - **6.1**: Copy `templates/new_framework_defaults_6_1.rb` → `config/initializers/new_framework_defaults_6_1.rb` |
| 60 | - **7.0**: Copy `templates/new_framework_defaults_7_0.rb` → `config/initializers/new_framework_defaults_7_0.rb` |
| 61 | - **7.1**: Copy `templates/new_framework_defaults_7_1.rb` → `config/initializers/new_framework_defaults_7_1.rb` |
| 62 | - **7.2**: Copy `templates/new_framework_defaults_7_2.rb` → `config/initializers/new_framework_defaults_7_2.rb` |
| 63 | |
| 64 | These templates contain the exact canonical Rails initializer with all configs |
| 65 | commented out, matching what `rails app:update` would generate. Always use |
| 66 | the template rather than generating from scratch — this ensures the comments, |
| 67 | formatting, and config ordering match the Rails source. |
| 68 | |
| 69 | ## Step 4: Iterative Config Walkthrough |
| 70 | |
| 71 | Process configs in order from safest (Tier 1) to those needing analysis (Tier 2). |
| 72 | |
| 73 | For each config: |
| 74 | |
| 75 | ### 4a. Analyze the Codebase |
| 76 | |
| 77 | Run the lookup patterns defined in the config reference: |
| 78 | - Use `grep -r` or `find` to search for the patterns listed |
| 79 | - Check the specific files/directories indicated |
| 80 | - Apply the decision tree to determine the recommended value |
| 81 | |
| 82 | ### 4b. Present Recommendation |
| 83 | |
| 84 | Tell the user: |
| 85 | - What the config does (old behavior → new behavior) |
| 86 | - What you found in their codebase |
| 87 | - Your recommended value and why |
| 88 | - Risk level (low/medium/high) |
| 89 | |
| 90 | ### 4c. Apply the Change |
| 91 | |
| 92 | Once the user agrees: |
| 93 | - Uncomment the config line in the initializer file |
| 94 | - Set the value (either the new default or the override value) |
| 95 | |
| 96 | ### 4d. Wait for User |
| 97 | |
| 98 | Stop and wait. The user will: |
| 99 | - Commit and push the change |
| 100 | - Run CI or manually test |
| 101 | - Come back to confirm success or report failure |
| 102 | |
| 103 | If the change broke something: |
| 104 | - Re-comment the config line or set it to the old value |
| 105 | - Note it as needing investigation |
| 106 | - Move to the next config |
| 107 | |
| 108 | ### 4e. Handle application_rb_only Configs |
| 109 | |
| 110 | Some configs are marked `application_rb_only` in the version reference YAML. |
| 111 | These cannot go in the initializer file and must be tested directly in |
| 112 | `config/applicatio |