explaingit

joshpxyne/gpt-migrate

6,978PythonAudience · developerComplexity · 4/5Setup · hard

TLDR

A command-line tool that uses GPT-4 to automatically rewrite your entire codebase from one programming language or framework into another, running auto-generated tests in Docker to verify the result.

Mindmap

mindmap
  root((gpt-migrate))
    What it does
      AI codebase migration
      Language translation
      Framework rewriting
    How it works
      Docker container setup
      GPT-4 file-by-file rewrite
      Auto-generated tests
    Configuration
      Source and target lang
      Entry point file
      OpenRouter support
    Caution
      High API costs possible
      Verify results manually
      Large codebases risky
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Automatically translate a Flask Python app to Node.js by pointing gpt-migrate at your source folder and specifying the target language

USE CASE 2

Rewrite a legacy codebase in a modern language with AI-generated tests to verify the translation compiles and runs correctly

USE CASE 3

Prototype a language migration to see what the AI produces before committing your team to a manual rewrite effort

Tech stack

PythonDockerGPT-4OpenRouter

Getting it running

Difficulty · hard Time to first run · 1h+

Requires a paid OpenAI API key and Docker installed, full migrations on large codebases can accumulate significant API costs.

In plain English

GPT-Migrate is a command-line tool that uses a large language model to automatically rewrite a codebase from one programming language or framework into another. You point it at a folder of source code and tell it the target language, and it does the translation work by repeatedly asking the AI to read and rewrite each file. The process has several stages. First the tool sets up a Docker container, which is an isolated software environment, configured for the target language. Then it reads your existing code to identify which third-party libraries you are using, finds equivalent libraries in the new language, and begins rewriting the code file by file starting from your application's main entry point. Once the new code is written, it starts the application in the container and runs automatically generated tests against it. If anything fails, the tool reads the error messages and attempts to fix the code on its own, repeating until the tests pass or the user intervenes. The tool is designed to work with GPT-4 and is configured by default to use GPT-4-32k, a version with a larger context window useful for reading longer files. It also supports connecting through OpenRouter, a service that routes requests to multiple AI providers. Running a full migration can accumulate significant API costs because the model may need to rewrite and debug large amounts of code. Configuration is done through command-line flags specifying the source directory, source language, target language, entry point file, and other options. A set of benchmark examples is included in the repository for testing, including a sample Flask-to-Node.js migration. The README notes that results should not be trusted blindly and that the tool should be used with care, particularly for large codebases where costs and errors can compound.

Copy-paste prompts

Prompt 1
I want to migrate my Flask Python app to Express Node.js using gpt-migrate. What exact command do I run, and what should I set as the source directory, source language, target language, and entry-point flags?
Prompt 2
gpt-migrate ran but the auto-generated tests are failing after the migration. Show me how to read the Docker container logs to understand what went wrong and how the tool attempts to self-correct.
Prompt 3
Estimate the OpenAI API cost for migrating a 10000-line Python codebase to Go using gpt-migrate with GPT-4-32k, given that the tool may rewrite and debug files multiple times.
Prompt 4
I want to use gpt-migrate with OpenRouter instead of directly with OpenAI. Show me the configuration changes needed to route requests through OpenRouter.
Open on GitHub → Explain another repo

← joshpxyne on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.