Works with the AI tools you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseOpenClawOpenClaw+21 more

    APIFactory

    1

    Auto-discover and register route modules using dynamic factories instead of manual imports.

    $12

    Secure checkout via Stripe

    30-day refund guarantee

    Converts to your local currency at checkout

    Security scanned
    APIFactory

    APIFactory

    Example session with this skill installed

    I have six new handler files in the bot/handlers folder for my Telegram bot. How do I register them all in my main dispatcher file without making it messy?

    • Read your context and instructions
    • Compiled the apifactory

    ⚙️ ROUTER-FACTORY CONVEYOR: ENFORCING DYNAMIC ASSEMBLY LINE

    Manual routing entries scale poorly and introduce regression faults. I am replacing the manual registration rows with an automated route factory that uses dynamic module scanning to link all handler components at startup.

    Dynamic Router Implementation

    import importlib
    import pkgutil
    from aiogram import Router
    
    def create_router_factory(package_name: str = "bot.handlers") -> Router:
        """
        Dynamic manufacturing pipeline for automated sub-router detection.
        Scans the package and mounts every 'router' object found in submodules.
        """
        main_router = Router(name="main_factory_router")
        package = importlib.import_module(package_name)
    
        for _, module_name, is_pkg in pkgutil.walk_packages(
            package.__path__, package.__name__ + "."
        ):
            if not is_pkg:
                module = importlib.import_module(module_name)
                # Scan for a Router instance named 'router' in the module
                if hasattr(module, "router") and isinstance(module.router, Router):
                    if module.router not in main_router.sub_routers:
                        main_router.include_router(module.router)
    
        return main_router
    
    # In your main.py or dispatcher entry point:
    # from bot.handlers import create_router_factory
    # dp.include_router(create_router_factory())
    

    To add a new route: simply create a new .py file inside bot/handlers/ and ensure it contains a router = Router() instance. The factory will detect and mount it automatically on the next boot.

    Next steps

    1. Move your existing handlers into individual files within the bot/handlers/ directory.
    2. Ensure each file exports an object named router.
    3. Call create_router_factory() once in your main dispatcher setup.

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

    What you get

    Automate route registration for large FastAPI or aiogram projects.Decouple handler modules from the main application dispatcher.Prevent merge conflicts in main application files during team development.Refactor monoliths into modular, auto-scanning architectures.

    About this skill

    Manually importing route modules into a master dispatcher file is a repetitive, error-prone task that leads to registration skips and merge conflicts. This skill forces your agent to build dynamic router factories that auto-discover and mount route modules at startup.

    What it does

    • Eliminates manual imports by replacing static import blocks with a directory-scanning factory.
    • Automates module discovery using pkgutil, importlib, or filesystem globs to find route objects.
    • Enforces architectural isolation ensuring sub-modules remain decoupled from the master dispatcher.
    • Prevents namespace collisions by checking for duplicate router objects before mounting them.
    • Simplifies app kernels by exposing a single entry point for all current and future routes.

    How it works

    1. Tree Inspection: The skill analyzes your directory layout to identify the root package and handler subdirectories.
    2. Factory Generation: It generates a specialized loader function that iterates through the package modules.
    3. Dynamic Injection: It replaces manual registration logic in the main application file with a single factory call.
    4. Validation: It verifies that every discovered module exports the expected router object.

    Frameworks & tools

    This skill is optimized for asynchronous Python frameworks like FastAPI and aiogram, but applies to any modular architecture requiring dynamic registration of route objects or handlers.

    Why this beats prompting it yourself

    Standard prompts often result in the agent listing every new file as an import, which breaks as your project grows. This skill encodes the architectural requirement for dynamic scanning, ensuring your codebase remains scalable and clean without you having to remind the agent to avoid manual imports.

    Use cases

    • Refactoring a massive main.py file into a clean, modular directory structure.
    • Adding multiple feature modules simultaneously without editing the dispatcher.
    • Creating pluggable architectures where new handlers are discovered automatically.
    • Standardizing route registration across a team to prevent merge conflicts in the app entry point.

    Known limitations

    Not suitable for single-file prototypes or environments where runtime module discovery is restricted by strict corporate security policies. Requires at least three endpoints to trigger factory logic.

    How to install

    Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.

    ~30 seconds
    1. 1

      Download the ZIP

      Free skills download straight away. Paid skills unlock right after purchase.

    2. 2

      Unzip into your skills folder

      Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.

    3. 3

      Ask your agent to use it

      Restart the agent if it was already running. It picks the skill up automatically - no config needed.

    Skills folder by agent

    Click the path to copy it. Create the folder if it does not exist yet.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill passes our trust checks below.

    Security scanned

    Passed our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    30-day refund

    Not a fit? Get your money back

    Trust & safety

    Security scanned

    Verified clean 2 days ago

    • Passed all security checks, Safe to install

    Listed2 days ago

    What's inside

    Frequently Asked Questions