Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+22 more

    APIFactory — Auto-Register Routes Without Import Hell

    1

    Kill manual import hell and merge conflicts forever. Forces your AI agent to implement dynamic route auto-registration factories that scan package directories at runtime.

    $9.99

    Secure checkout via Stripe

    30-day refund guarantee

    Converts to your local currency at checkout

    Security scanned
    APIFactory — Auto-Register Routes Without Import Hell

    APIFactory — Auto-Register Routes Without Import Hell

    Example session with this skill installed

    I have 8 new handler files in my bot/handlers folder. How do I register them in the main dispatcher without writing 8 import lines?

    • Read your context and instructions
    • Compiled the apifactory

    ⚙️ ROUTER-FACTORY CONVEYOR: ENFORCING DYNAMIC ASSEMBLY LINE

    Manual routing entries scale poorly and introduce regression faults.
    Not generating manual registration rows. Injecting an automated route factory
    that uses dynamic module scanning to link all checkout components at startup.

    Generated a dynamic router factory for your aiogram bot. This replaces manual registration with automated package scanning.

    Dynamic Router Factory Implementation

    
    # bot/handlers/__init__.py
    import importlib
    import pkgutil
    from aiogram import Router
    
    def create_router_factory(package_name: str = __name__) -> Router:
        """
        Scans the package for modules containing a 'router' object 
        and mounts them to a single master router.
        """
        main_router = Router(name="auto_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)
                if hasattr(module, "router") and isinstance(module.router, Router):
                    # Ensure we don't double-register
                    if module.router not in main_router.sub_routers:
                        main_router.include_router(module.router)
    
        return main_router
    
    # Singleton instance for the dispatcher
    main_router = create_router_factory()
    
    
    # bot/main.py
    from aiogram import Dispatcher, Bot
    from bot.handlers import main_router
    
    async def main():
        dp = Dispatcher()
        dp.include_router(main_router)
        # ... rest of startup logic
    

    Next steps

    1. Ensure each of your 8 files in bot/handlers/ defines a variable named router = Router().
    2. Delete any existing manual handler imports from your main.py to prevent duplicate execution.
    3. Restart the bot; the factory will now pick up any new .py files added to that folder automatically.

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

    About this skill

    Manual route registration is a critical maintenance bottleneck that consistently introduces annoying merge conflicts, messy git histories, and forgotten endpoints. As your system expands, forcing developers or AI to constantly touch a central dispatcher file for every new feature creates an unnecessary regression risk. APIFactory completely overrides this brittle workflow, mandating your AI coding agent to construct bulletproof, dynamic router factories that scan your package directories natively at runtime. Core Benefits & Capabilities

    • Automated Package Discovery: Leverages runtime package scanning to immediately locate, map, and mount new route modules as soon as the files are created.
    • Complete Boilerplate Elimination: Replaces fragile, endlessly growing lists of manual imports in your core layout configuration file with a single, elegant factory call.
    • Strict Architectural Isolation: Guarantees that route modules remain cleanly decoupled from the main app dispatcher and entirely independent of each other.
    • Collision & Namespace Prevention: Automatically validates directory structures and monitors for namespace conflicts before dynamically mounting discovered routers into the master application tree.
    • Seamless Scalability: Provides a highly pluggable pattern where simply dropping a new handler file into a directory is the only step required for full deployment.

    Technical Execution Workflow

    1. Package Tree Mapping: The AI agent analyzes your project directory architecture to isolate the subpackages where endpoints, handlers, or routes reside.
    2. Factory Generation: The agent structures a central init.py or factory utility leveraging standard Python architecture (pkgutil or importlib) to programmatically walk the target package.
    3. Dynamic Module Mounting: The factory dynamically imports each module on app initialization, validates the presence of the router instance, and cleanly registers it with the master dispatcher.

    Supported Frameworks & Standard Library Stack Optimized out-of-the-box for high-performance Python-based web and bot ecosystems, including FastAPI and aiogram, as well as modular Express layouts. Built entirely on top of robust standard library components (pkgutil and importlib) for native, dependency-free module discovery. Why This Beats Manual Prompting Standard AI prompts usually settle for manual imports because hardcoding lines is the "path of least resistance" for an LLM. APIFactory strictly blocks this behavior, enforcing a professional-grade decoupled architecture that completely protects your main configuration file from turning into an unmaintainable, conflict-prone monolith.

    How to use

    Skills on Agensi run inside your AI agent. Copy the prompt, paste it into your agent, and it connects to Agensi and installs this skill for you. If a payment is needed, your agent shows it to you first.

    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 13 days ago

    • Passed all security checks, Safe to install

    Listed13 days ago

    What's inside

    Frequently Asked Questions