Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    legacy code modernizer pro

    1

    Refactor legacy code into modern, clean, and type-safe syntax with robust error handling.

    $9

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    legacy code modernizer pro

    legacy code modernizer pro

    Example session with this skill installed

    Legacy Code: import urllib2 def fetch_data(url): try: response = urllib2.urlopen(url) print "Data fetched successfully!" return response.read() except urllib2.URLError, e: print "Error fetching data: " + str(e) Original Language/Version: Python 2.7 Target Language/Version: Python 3.11+

    • Read your context and instructions
    • Compiled the legacy code modernizer

    🛠️ Refactor Summary

    Migration: Python 2.7 ➡️ Python 3.11+

    Key Improvements

    Replaced urllib2 with the modern urllib.request (and added an option to use requests as a more ergonomic alternative)
    Converted print statements to function calls and modernized exception syntax (except X as e)
    Added timeout handling, input validation, HTTP status checking, and specific exception branches (network vs. HTTP errors) with proper logging instead of bare print
    💻 Modernized Code

    python
    """
    

    Module for fetching remote data over HTTP(S).

    Migrated from Python 2.7's urllib2 to Python 3.11+'s urllib.request.
    """

    import logging
    import urllib.request
    import urllib.error
    

    logger = logging.getLogger(name)

    DEFAULT_TIMEOUT = 10 # seconds

    def fetch_data(url: str, timeout: float = DEFAULT_TIMEOUT) -> bytes:
        """
    
    Fetch raw data from the given URL.
    

    Args
    url: The HTTP/HTTPS URL to fetch.
    timeout: Number of seconds to wait before giving up.

    Returns
    The response body as bytes.

    Raises
    ValueError: If the URL is empty or not a string.
    urllib.error.URLError: If the request fails at the network/connection level.
    urllib.error.HTTPError: If the server returns a non-2xx status code.
    """
    if not isinstance(url, str) or not url.strip():
    raise ValueError("url must be a non-empty string")

        try:
            with urllib.request.urlopen(url, timeout=timeout) as response:
                status = getattr(response, "status", 200)
                if status >= 400:
    
                # Defensive check; urlopen normally raises HTTPError itself,
                # but this guards against unexpected implementations.
                raise urllib.error.HTTPError(
                    url, status, "Non-success status code", response.headers, None
    
                    )
                data = response.read()
    
            logger.info("Data fetched successfully from %s (%d bytes)", url, len(data))
            return data
    
    except urllib.error.HTTPError as e:
        # Server responded, but with an error status (4xx/5xx)
        logger.error("HTTP error fetching %s: %s (status %s)", url, e.reason, e.code)
        raise
    
    except urllib.error.URLError as e:
        # Network-level failure (DNS, connection refused, timeout, etc.)
        logger.error("Error fetching data from %s: %s", url, e.reason)
        raise
    

    Notes on the refactor

    urllib2.urlopen(url) ➜ urllib.request.urlopen(url, timeout=...) — added a timeout so the call can't hang forever, which was a latent risk in the original.
    except urllib2.URLError, e: (Python 2 comma syntax) ➜ except urllib.error.URLError as e: (Python 3 syntax), split into HTTPError (subclass of URLError) and URLError branches so HTTP status errors and network errors are handled/logged distinctly.
    Swapped print for logging calls so output is leveled, timestamped, and redirectable — standard practice for production-quality code instead of legacy debug prints.
    Added a docstring and an input-validation guard (raise ValueError on bad input) that the original lacked entirely.

    If you'd like, I can also show a requests-based version, which is the more idiomatic third-party choice for HTTP calls in modern Python codebases these days.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Use this skill when a user provides outdated, monolithic, or poorly structured legacy code and requests refactoring into a modern, type-safe, and clean syntax. It triggers automatically whenever a user requests code upgrades, performance optimization, better error handling, or technical debt reduction.

    Pro Capabilities

    • Language Migration: Modernizes outdated syntax (e.g., upgrading legacy Python 2.x scripts to modern Python 3.11+ standards, adding strict TypeScript types to JavaScript).
    • Robust Error Handling: Implements comprehensive try/catch blocks, explicit input validation, and secure edge-case checking in legacy logic.
    • Modular Refactoring: Converts bloated, monolithic functions into highly reusable, clean, and well-documented utility modules.
    • Technical Debt Reduction: Eliminates anti-patterns, removes dead code, and optimizes runtime performance without changing core application behavior.

    Target Environment

    This skill is highly optimized for integration with AI agent platforms utilizing the standard SKILL.md specification. It executes entirely in text-based environments and requires no external local packages or specialized system network access.

    Best suited for functions, classes, or utility modules. Does not perform full architectural migrations or infrastructure-level changes.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 2 months ago

    Permissions

    No special permissions declared or detected

    Listed2 months ago

    What's inside

    Frequently Asked Questions

    Legacy Code Modernizer Pro specializes in transforming monolithic, outdated code into modular, type-safe, and clean syntax, specifically targeting technical debt and poor error handling. It solves the problem of maintaining "spaghetti code" by introducing modern patterns like strict typing in TypeScript or Python 3.11+ standards.

    This skill is designed for any AI agent platform following the standard SKILL.md specification. Because it is text-based and requires no local package installations, it integrates seamlessly with most LLM-driven development environments.

    The skill is primarily optimized for Python and JavaScript/TypeScript, but its logic-refactoring capabilities can be applied to most major programming languages to improve modularity and error handling. It is especially effective at migrating legacy JS to strict TypeScript.

    Connect your AI agent to Agensi through MCP, then ask it to use legacy code modernizer pro on your task. Your agent loads the latest approved version each time. Paid skills require a purchase or active subscription. Skill files are not available for download; your licence does not allow you to save, copy or export any part of a skill.

    No, this skill operates entirely within the text-based context of your AI agent platform. It does not require external network access or local binary executions, making it a secure choice for refactoring sensitive logic.

    The purchase includes the complete skill definition, including the logic for modular refactoring and error handling implementation. Buyers also receive documentation on how to maximize the skill's effectiveness for different technical debt scenarios.

    New in Code Quality & Review