mcpbeat Sign in

Framework Migration Assistant Agent Skill

Automatically migrate Python web applications between frameworks (Flask → FastAPI, Django → FastAPI). Use when you need to migrate an existing web application to a modern framework while preserving functionality. The skill analyzes the codebase, updates routes, handlers, configuration, dependency injection patterns, and tests. Creates git commits for each migration phase and generates a comprehensive summary of all changes. Supports automatic dependency updates, code transformations, and test adaptations.

19k tokens
context cost
the whole folder, loaded on every use
11
files
ships runnable scripts
0
copies elsewhere
how many repositories repackaged it
141
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/ArabelaTso/Skills-4-SE --skill framework-migration-assistant

The instruction itself

24 sections, as written by the author

Framework Migration Assistant

Overview

This skill automatically migrates Python web applications between frameworks, transforming code, configuration, and tests while preserving existing functionality. It handles route migration, request/response patterns, dependency injection, configuration updates, and test adaptations, committing changes incrementally with detailed summaries.

Quick Start

Basic Usage

# Navigate to your repository
cd /path/to/your/repo

# Run migration
python scripts/migrate.py . --from flask --to fastapi

The migration process will:

  • Create a migration branch
  • Analyze your codebase
  • Update dependencies
  • Migrate routes and handlers
  • Update configuration
  • Adapt tests
  • Generate a summary report

Example: Flask to FastAPI

# Migrate Flask app to FastAPI
python scripts/migrate.py /path/to/flask-app --from flask --to fastapi

# Output:
# ✓ Created migration branch: migrate-flask-to-fastapi
# ✓ Analyzing codebase...
# ✓ Found 15 route files
# ✓ Found 23 test files
# ✓ Migrating dependencies...
# ✓ Migrating routes...
# ✓ Migrating configuration...
# ✓ Migrating tests...
# ✓ Migration completed successfully!

Supported Migration Paths

Flask → FastAPI

What gets migrated:

  • Route decorators: @app.route() → @app.get(), @app.post(), etc.
  • Request handling: request.args → query parameters, request.json → Pydantic models
  • Response handling: jsonify() → direct return
  • Configuration: Flask config → Pydantic Settings
  • Tests: Flask test client → FastAPI TestClient
  • Dependencies: Flask packages → FastAPI equivalents

Example transformation:

Before (Flask):

@app.route('/users/<int:user_id>', methods=['GET'])
def get_user(user_id):
    user = db.get_user(user_id)
    return jsonify(user)

After (FastAPI):

@app.get('/users/{user_id}')
async def get_user(user_id: int) -> UserSchema:
    user = await db.get_user(user_id)
    return user

Django → FastAPI

What gets migrated:

  • URL patterns → FastAPI routes
  • Django views → FastAPI path operations
  • Django ORM references → SQLAlchemy patterns
  • Settings module → Pydantic Settings
  • Django test cases → FastAPI tests

Migration Process

Phase 1: Preparation

The migration tool automatically:

  • Validates the repository is a git repo
  • Detects the source framework (if not specified)
  • Creates a migration branch
  • Analyzes the codebase structure

Phase 2: Dependency Migration

Updates package dependencies:

  • requirements.txt
  • pyproject.toml
  • Replaces framework-specific packages
  • Adds required FastAPI dependencies

Example changes:

flask>=2.0.0          → fastapi>=0.104.0
werkzeug>=2.0.0       → uvicorn[standard]>=0.24.0
flask-cors>=3.0.0     → fastapi-cors>=0.0.6

Phase 3: Route Migration

Transforms route definitions and handlers:

  • Updates route decorators
  • Converts HTTP method specifications
  • Transforms path parameters
  • Updates request/response handling
  • Adds async/await where needed
  • Adds type hints for validation

Phase 4: Configuration Migration

Updates configuration files:

  • Migrates Flask config to Pydantic Settings
  • Updates environment variable handling
  • Converts middleware setup
  • Updates CORS configuration
  • Creates new config files if needed

Phase 5: Test Migration

Adapts test files:

  • Updates test client initialization
  • Converts test assertions
  • Updates request methods
  • Adapts fixtures and mocks
  • Adds async test support

Phase 6: Summary Generation

Creates a comprehensive report:

  • Total changes made
  • Files modified by category
  • Migration plan executed
  • Next steps for manual review
  • Saved as MIGRATION_SUMMARY.json

Using the Migration Scripts

Main Migration Script

python scripts/migrate.py <repo_path> --from <source> --to <target>

# Options:
#   repo_path: Path to the repository
#   --from: Source framework (flask, django, or auto)
#   --to: Target framework (fastapi)

Individual Migration Modules

You can also run individual migration steps:

from migrate_dependencies import DependencyMigrator
from migrate_routes import RouteMigrator
from migrate_config import ConfigMigrator
from migrate_tests import TestMigrator

# Run specific migration
migrator = RouteMigrator(repo_path, 'flask', 'fastapi')
migrator.migrate()

Post-Migration Steps

After migration completes:

  • Review the changes
   git log --oneline
   git diff main..migrate-flask-to-fastapi
  • Install new dependencies
   pip install -r requirements.txt
  • Run tests
   pytest
  • Manual review needed for:
  • Complex authentication logic
  • Custom middleware
  • Database connection strings
  • Third-party integrations
  • Advanced error handling
  • Test the application
   uvicorn main:app --reload
  • Merge when ready
   git checkout main
   git merge migrate-flask-to-fastapi

Reference Documentation

  • references/framework_comparison.md - Detailed comparison of Flask, Django, and FastAPI including architecture, routing, request handling, and performance
  • references/migration_guide.md - Comprehensive migration guide with step-by-step instructions, common patterns, troubleshooting, and post-migration checklist
  • references/migration_patterns.md - Common migration patterns for routes, requests, responses, authentication, database operations, and testing

Example Applications

Example applications are provided in assets/:

  • example_flask_app.py - Flask application before migration
  • example_fastapi_app.py - Same application after migration to FastAPI

Compare these files to understand the transformations applied.

Migration Summary

After migration, review MIGRATION_SUMMARY.json:

{
  "source_framework": "flask",
  "target_framework": "fastapi",
  "total_changes": 47,
  "changes_by_type": {
    "dependency": 5,
    "route": 15,
    "config": 4,
    "test": 23
  },
  "files_modified": [...],
  "next_steps": [...]
}

Tips

  • Always commit or backup your code before migration
  • Review each migration commit individually
  • Test thoroughly after migration
  • Update documentation to reflect framework changes
  • Consider performance improvements with async/await
  • Use the generated API documentation (FastAPI auto-generates OpenAPI docs)
  • Consult reference documentation for complex patterns
  • Run tests frequently during manual adjustments

Troubleshooting

Issue: Import errors after migration

  • Solution: Run pip install -r requirements.txt

Issue: Tests fail with async errors

  • Solution: Add @pytest.mark.asyncio and install pytest-asyncio

Issue: Database connections fail

  • Solution: Update connection strings for async SQLAlchemy

Issue: CORS errors

  • Solution: Configure CORS middleware in FastAPI

See references/migration_guide.md for detailed troubleshooting.

Other skills for the same job

different authors, same section of the catalogue
MCP Builder
by anthropics
vendor ×13

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

30k tokens scripts
Changelog Generator
by frostant
×9

Automatically creates user-facing changelogs from git commits by analyzing commit history, categorizing changes, and transforming technical commits into clear, customer-friendly release notes. Turns hours of manual changelog writing into minutes of automated generation.

774 tokens
Finishing A Development Branch
by ZhanlinCui
×7

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup

1k tokens
MCP Builder
by JayZeeDesign
×7

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

37k tokens scripts
Vercel React Native Skills
by vercel-labs
vendor ×6

React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.

39k tokens
Vercel React Best Practices
by ratacat
×5

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

34k tokens
Next Best Practices
by vercel-labs
vendor ×4

Next.js best practices - file conventions, RSC boundaries, data patterns, async APIs, metadata, error handling, route handlers, image/font optimization, bundling

20k tokens
Using Git Worktrees
by ZhanlinCui
×4

Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification

1k tokens

How to use it

Copy the folder

Take arabelatso/framework-migration-assistant from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.

Install what it needs

The instructions reference pip. Without those the skill loads but fails at the first command.