Gemini Migration Prompt Template
You get a step-by-step migration plan with old-to-new code mappings, the breaking changes that will bite you, and a way to roll out safely. This version is set up for Gemini: attach files or images the prompt refers to, or paste the text below the instructions. Below you'll find the prompt, how to run it in Gemini, a worked example and answers to common questions.
Help me migrate code from one version, library or framework to another. ## Migration From: [e.g. moment.js 2.x] To: [e.g. date-fns 3.x] Why: [e.g. bundle size, end of support] ## Codebase Language and size: [e.g. TypeScript, about 40 files use moment] Typical usage: [paste 3 to 5 representative snippets] ## Constraints - Can we run old and new side by side during the move: [yes or no] - Deadline or freeze dates: [if any] ## Instructions - Map each old pattern I pasted to its new equivalent. - List breaking changes and behavior differences that are easy to miss (defaults, time zones, mutability, return types). - Suggest an order of work that keeps the app shippable at every step. - Flag anything that has no direct equivalent. ## Output format 1. Old to new mapping table 2. Gotchas 3. Step-by-step plan 4. How to verify each step Context - Reference material: [paste it below, or attach the file]
How to use this prompt
- 1
Open Gemini
Start a new chat in Gemini and paste the prompt.
- 2
Give it context
Attach files or images the prompt refers to, or paste the text below the instructions.
- 3
Review and iterate
Reply in the same chat to refine the result.
- 4
Save what you repeat
For a prompt you run often, save it as a Gem with custom instructions.
Working in Gemini
- •Gemini accepts images and files as well as text, so attach a screenshot when the task is visual.
- •Ask for the exact output format; otherwise answers tend to come with extra headings and summaries.
- •If you use Google Docs or Sheets, ask for output you can paste straight in, such as a table.
Worked example
What you give it
From: moment.js 2.x. To: date-fns 3.x. Why: moment is in maintenance mode and adds a lot to our bundle.
Codebase: React app in TypeScript, about 40 files import moment. Typical usage:
moment(date).format("YYYY-MM-DD")
moment().add(7, "days")
moment(a).isBefore(b)
Side by side: yes. No deadline, but we want it done this quarter.What a good answer looks like (shortened)
1. Mapping
- moment(date).format("YYYY-MM-DD") becomes format(date, "yyyy-MM-dd")
- moment().add(7, "days") becomes addDays(new Date(), 7)
- moment(a).isBefore(b) becomes isBefore(a, b)
2. Gotchas
- Format tokens differ. In date-fns, lowercase yyyy is the calendar year and dd is the day of month. Uppercase YYYY and DD mean different things and throw unless you opt in.
- date-fns works on native Date objects and never mutates them, while moment's add() mutates the moment instance. Check code that relied on mutation.
3. Plan
1. Add date-fns alongside moment.
2. Migrate one folder at a time, starting with formatting helpers.
3. Remove moment once a search for "moment(" returns nothing.
4. Verify: snapshot test formatted dates for a fixed set of inputs before and after each folder.Tips for better results
- •Pick the snippets for Typical usage from different parts of the codebase. The odd cases, not the common ones, are where migrations fail.
- •Read the Gotchas section before writing any code. Behavior changes like mutability or default time zones cause bugs that tests often miss.
- •Ask for the exact output format; otherwise answers tend to come with extra headings and summaries.
- •Avoid this: Asking the AI to migrate everything in one pass, which produces a huge diff nobody can review or roll back.
Get the free prompt pack
Our best coding prompts in one Markdown file, delivered by email. The templates here stay free either way — the pack just saves you the copying.
Variations
Framework upgrade
Replace Migration with: From [framework] [old version] to [new version]. List deprecated APIs we use and their replacements, in order of risk.
Database migration
Replace Codebase with: Current schema [paste] and target schema [paste]. Write reversible migrations and a backfill plan with no downtime.
Language port
Change Instructions to: Translate [file] from [language A] to [language B] idiomatically, not line by line, and note any library differences.
Save it as a Retext snippet
Retext is a free text expander for Mac. Save this prompt once, then type ;migrate in any app (ChatGPT, Claude, your editor, a browser tab) and the full prompt is pasted in.
- Click Add to Retext. The prompt installs as a snippet with the trigger ;migrate.
- Change the trigger in Retext if you prefer a different one.
- Type the trigger wherever you want the prompt, then fill in the brackets.
Frequently asked questions
Can AI migrate a whole codebase automatically?
It can convert common patterns quickly, but it misses project-specific behavior and edge cases. Use it to plan and to convert files in small batches that you test as you go.
Can I save this prompt in Gemini?
Yes, as a Gem with the prompt as its instructions. A Retext snippet also works if you switch between Gemini and other tools.
How do I check that a migration did not change behavior?
Write tests or snapshots of current outputs before you start, then run them after each step. Behavior differences are much easier to spot one folder at a time.
How do I reuse this prompt without copying it every time?
Click Add to Retext to save it as a snippet. Then type ;migrate in any Mac app, including your AI tool, and the full prompt is pasted in.
Related Templates
Get the free prompt pack
Our best coding prompts in one Markdown file, delivered by email. The templates here stay free either way — the pack just saves you the copying.