Skip to content
Development
Command

/code-migrate

Generate comprehensive migration plans and scripts for transitioning codebases between frameworks, languages, versions, or platforms with minimal disruption.

From plugin
wshobson-agents
39k95 skills139 agents95 commands
Install
$ npx -y skills add wshobson/agents --agent claude-code

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/code-migrate

Context preview

What this command does when you run it.

Generate comprehensive migration plans and scripts for transitioning codebases between frameworks, languages, versions, or platforms with minimal disruption.

Command definition

code-migrate.md
description: Generate comprehensive migration plans and scripts for transitioning codebases between frameworks, languages, versions, or platforms with minimal disruption.

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**

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**

class MigrationPlanner:
    def create_migration_plan(self, analysis):
        """
        Create comprehensive migration plan
        """
        plan = {
            'phases': self._define_phases(analysis),
            'timeline': self._estimate_timeline(analysis),
            'resources': self._calculate_resources(analysis),
            'milestones': self._define_milestones(analysis),
            'success_criteria': self._define_success_criteria()
        }

        return self._format_plan(plan)

    def _define_phases(self, analysis):
        """Define migration phases"""
        complexity = analysis['complexity']['overall']

        if complexity < 3:
            # Simple migration
            return [
                {
                    'name': 'Preparation',
                    'duration': '1 week',
                    'tasks': [
                        'Setup new project structure',
                        'Install dependencies',
                        'Configure build tools',
                        'Setup testing framework'
Read more
Ships withwshobson-agents

Production-ready agentic workflow building blocks: 94 plugins, 203 agents, 175 skills, 109 commands — built for Claude Code and consumed natively by OpenAI Codex CLI, Cursor, OpenCode, Gemini CLI, and GitHub Copilot from a single Markdown source.

Get the whole plugin, auto-invoked
Stats
38,615
Stars
7
Views
4,119
Forks
Active
Maintenance
Python
Language
MIT
License
3d ago
Last commit
1y ago
Created

Repo: wshobson/agents