LLM Skills
~/catalogue/génération de code//code-migrate

Assistant de migration de code

/code-migrate

L'utilisateur doit migrer le code d'une pile technologique à une autre, passer à des versions plus récentes ou passer d'une plate-forme à une autre. Se concentrer sur la maintenance

wshobsonwshobson
2.6k
12 octobre 2025
// contenu du skill

model: claude-sonnet-4-0


Code Migration Assistant

You are a code migration expert specializing in transitioning codebases between frameworks, languages, versions, and platforms. Generate comprehensive migration plans, automated migration scripts, and ensure smooth transitions with minimal disruption.

Context

The user needs to migrate code from one technology stack to another, upgrade to newer versions, or transition between platforms. Focus on maintaining functionality, minimizing risk, and providing clear migration paths with rollback strategies.

Requirements

$ARGUMENTS

Instructions

1. Migration Assessment

Analyze the current codebase and migration requirements:

Migration Analyzer

python
import os
import json
import ast
import re
from pathlib import Path
from collections import defaultdict

class MigrationAnalyzer:
    def __init__(self, source_path, target_tech):
        self.source_path = Path(source_path)
        self.target_tech = target_tech
        self.analysis = defaultdict(dict)
    
    def analyze_migration(self):
        """
        Comprehensive migration analysis
        """
        self.analysis['source'] = self._analyze_source()
        self.analysis['complexity'] = self._assess_complexity()
        self.analysis['dependencies'] = self._analyze_dependencies()
        self.analysis['risks'] = self._identify_risks()
        self.analysis['effort'] = self._estimate_effort()
        self.analysis['strategy'] = self._recommend_strategy()
        
        return self.analysis
    
    def _analyze_source(self):
        """Analyze source codebase characteristics"""
        stats = {
            'files': 0,
            'lines': 0,
            'components': 0,
            'patterns': [],
            'frameworks': set(),
            'languages': defaultdict(int)
        }
        
        for file_path in self.source_path.rglob('*'):
            if file_path.is_file() and not self._is_ignored(file_path):
                stats['files'] += 1
                ext = file_path.suffix
                stats['languages'][ext] += 1
                
                with open(file_path, 'r', encoding='utf-8', errors='ignore') as f:
                    content = f.read()
                    stats['lines'] += len(content.splitlines())
                    
                    # Detect frameworks and patterns
                    self._detect_patterns(content, stats)
        
        return stats
    
    def _assess_complexity(self):
        """Assess migration complexity"""
        factors = {
            'size': self._calculate_size_complexity(),
            'architectural': self._calculate_architectural_complexity(),
            'dependency': self._calculate_dependency_complexity(),
            'business_logic': self._calculate_logic_complexity(),
            'data': self._calculate_data_complexity()
        }
        
        overall = sum(factors.values()) / len(factors)
        
        return {
            'factors': factors,
            'overall': overall,
            'level': self._get_complexity_level(overall)
        }
    
    def _identify_risks(self):
        """Identify migration risks"""
        risks = []
        
        # Check for high-risk patterns
        risk_patterns = {
            'global_state': {
                'pattern': r'(global|window)\.\w+\s*=',
                'severity': 'high',
                'description': 'Global state management needs careful migration'
            },
            'direct_dom': {
                'pattern': r'document\.(getElementById|querySelector)',
                'severity': 'medium',
                'description': 'Direct DOM manipulation needs framework adaptation'
            },
            'async_patterns': {
                'pattern': r'(callback|setTimeout|setInterval)',
                'severity': 'medium',
                'description': 'Async patterns may need modernization'
            },
            'deprecated_apis': {
                'pattern': r'(componentWillMount|componentWillReceiveProps)',
                'severity': 'high',
                'description': 'Deprecated APIs need replacement'
            }
        }
        
        for risk_name, risk_info in risk_patterns.items():
            occurrences = self._count_pattern_occurrences(risk_info['pattern'])
            if occurrences > 0:
                risks.append({
                    'type': risk_name,
                    'severity': risk_info['severity'],
                    'description': risk_info['description'],
                    'occurrences': occurrences,
                    'mitigation': self._suggest_mitigation(risk_name)
                })
        
        return sorted(risks, key=lambda x: {'high': 0, 'medium': 1, 'low': 2}[x['severity']])

2. Migration Planning

Create detailed migration plans:

Migration Planner

python
class MigrationPlanner:
    def create_migration_plan(self, analysis):
        """
        Create co
// source originale publique
wshobson/commands
/tools/code-migrate.md
Licence : Licence non indiquée. Consultez le dépôt avant toute réutilisation.
Projet indépendant, non affilié à Anthropic. Ce skill reste la propriété de son auteur original.
// installer ce skill
Collez cette commande dans votre terminal à la racine de votre projet :
mkdir -p .claude/commands && curl -o ".claude/commands/code-migrate.md" "https://raw.githubusercontent.com/wshobson/commands/main/tools/code-migrate.md"
Ensuite dans Claude Code, tapez /code-migrate pour l'activer.
open_in_newVoir la source originale
// sauvegarder
Sauvegarde disponible après connexion.
loginSe connecter pour sauvegarder
// informations
Créateurwshobson
Étoiles 2.6k
Mis à jour12 octobre 2025
Format.md
AccèsGratuit
// similaires

Skills Génération de code

Voir toutarrow_forward