Codebase Migration Agent (Python 2 to 3, JavaScript to TypeScript)
This agent orchestrates the complete migration of a codebase between technologies: Python 2 to Python 3 or JavaScript to TypeScript. It analyzes the existing source code, identifies incompatibilities and obsolete patterns, generates a prioritized migration plan, then produces the migrated code file by file with corresponding unit tests.
For who
Developers and tech leads needing to migrate a legacy codebase to a modern language version, seeking to automate and make the process more reliable.
Input
Code source à migrer (fichiers Python 2 ou JavaScript), avec indication du type de migration souhaité (Python 2→3 ou JS→TS)
steps (5)
Source Code Audit and Mapping
promptAnalyzes existing code to identify all incompatibilities and dependencies to migrate.
Prioritized Migration Plan
promptGenerates an ordered migration plan with file dependencies and optimal processing order.
File-by-File Code Migration
promptApplies migration transformations on each file following the established plan.
Non-Regression Test Generation
promptCreates a test suite verifying that migrated code behavior is identical to the original.
Final Report and Deployment Guide
promptSynthesizes the migration with a complete report and deployment instructions.
Output
Code migré complet, suite de tests de non-régression, changelog détaillé des transformations, et rapport de migration avec guide de déploiement
Example
Input
Python 2 to 3 migration of a data processing module:
```python
# utils.py
import urllib2
import ConfigParser
from StringIO import StringIO
def fetch_data(url):
response = urllib2.urlopen(url)
return response.read()
def parse_config(path):
config = ConfigParser.SafeConfigParser()
config.read(path)
return dict(config.items('main'))
def process_items(items):
results = filter(lambda x: x > 0, items)
for key, value in {}.iteritems():
print key, value
return map(str, results)
```Output
**Migrated code (utils.py)**:
```python
import urllib.request
import configparser
from io import StringIO
def fetch_data(url: str) -> bytes:
response = urllib.request.urlopen(url)
return response.read()
def parse_config(path: str) -> dict[str, str]:
config = configparser.ConfigParser()
config.read(path)
return dict(config.items('main'))
def process_items(items: list[int]) -> list[str]:
results = [x for x in items if x > 0]
for key, value in {}.items():
print(key, value)
return [str(x) for x in results]
```
**Changelog**: 6 transformations applied (3 renamed imports, 1 print to print(), 1 iteritems to items, 1 filter/map to list comprehension). **Tests**: 4 functional parity tests generated. **Confidence**: 95%.Customization
| Parameter | Description | Default |
|---|---|---|
| migration_type | Type de migration Ă effectuer : Python 2 vers Python 3, ou JavaScript vers TypeScript | python2-to-python3 |
| strategie | Stratégie de migration : 'conservative' (comportement identique garanti) ou 'modern' (adoption des patterns modernes idiomatiques) | modern |
| strictness_level | Niveau de strictness pour le typage en cible : 'loose' (any autorisé), 'moderate' (any limité), 'strict' (zéro any, types exhaustifs) | moderate |
Technical Notes
This agent works optimally on moderately sized modules (< 500 lines per file). For large codebases, proceed in batches by submitting files module by module following the dependency order.
For Python 2 to 3 migrations, the agent handles major incompatibilities: print, unicode/bytes, renamed imports, iterators, integer division, and syntax changes. Advanced metaprogramming cases (metaclasses, custom descriptors) require human review.
For JS to TS migrations, the agent infers types from context and usage. Provide existing type files (@types/) and API interfaces for more precise typing. Enable strict mode for critical projects.
Related Prompts
Write a Clear and Impactful Internal Memo
This prompt generates a structured, professional internal memo adapted to your company context, with the right level of formality and all essential elements.
Prepare for Due Diligence
To prepare for a serious fundraising round
Online Community of Practice
Community of Practice
Mistral Prompt for Creating a Knowledge Base
Mistral, the leading French language model, excels at structuring and organizing complex knowledge. Creating an effective knowledge base requires more than just copying and pasting information: it involves categorizing, prioritizing, linking, and formatting data so that it can be used by a team or system. Thanks to its contextual understanding and structured generation capabilities, Mistral can transform raw documents, scattered notes, or business expertise into a coherent and navigable knowledge base. Whether you are a startup looking to capitalize on its know-how, a support team wanting to centralize its answers, or a consultant aiming to organize their expertise, Mistral supports you at every step: defining a taxonomy, extracting key information, writing articles, and creating links between topics. This guide provides optimized prompts to fully leverage Mistral in building a professional, structured, and scalable knowledge base.