Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    Fastapi Projects Async Sql en

    1

    Scaffold production-ready async FastAPI projects with SQLAlchemy, SQLModel, Alembic migrations, and pytest.

    Free

    Security scanned
    fastapi-projects-async-sql-en

    fastapi-projects-async-sql-en

    Example session with this skill installed

    I want to start a new async FastAPI project called "inventory-service" using PostgreSQL and Python 3.12. Please include the test suite.

    • Read your context and instructions
    • Compiled the fastapi-projects-async-sql-en

    I have initialized the inventory-service project. I used uv for dependency management, configured SQLAlchemy with asyncpg for PostgreSQL, and scaffolded the repository pattern.

    Project Structure and Configuration

    
    # pyproject.toml
    [project]
    name = "inventory-service"
    version = "0.1.0"
    dependencies = [
        "fastapi[standard]",
        "sqlmodel",
        "sqlalchemy",
        "asyncpg",
        "alembic",
    ]
    
    [tool.pytest.ini_options]
    asyncio_mode = "auto"
    pythonpath = ["."]
    testpaths = ["app/tests"]
    
    
    # app/core/config.py
    from pydantic_settings import BaseSettings
    from pathlib import Path
    
    class Settings(BaseSettings):
        APP_ENV: str = "development"
        DATABASE_URL: str
        SECRET: str
        
        BASE_DIR: Path = Path(__file__).resolve().parents[2]
    
        class Config:
            env_file = ".env"
    
    settings = Settings()
    
    
    # app/db/base_repository.py
    from typing import Generic, TypeVar, Type, List, Optional
    from sqlalchemy.ext.asyncio import AsyncSession
    from sqlmodel import select
    
    T = TypeVar("T")
    
    class BaseRepository(Generic[T]):
        def __init__(self, model: Type[T], session: AsyncSession):
            self.model = model
            self.session = session
    
        async def get(self, id: int) -> Optional[T]:
            return await self.session.get(self.model, id)
    
        async def get_all(self) -> List[T]:
            statement = select(self.model)
            result = await self.session.execute(statement)
            return result.scalars().all()
    

    Next steps

    1. Update the DATABASE_URL in your .env file with your PostgreSQL credentials.
    2. Run uv run alembic upgrade head to apply the initial schema.
    3. Execute uv run pytest to verify the testing infrastructure is working.

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

    About this skill

    Starting a new FastAPI project often leads to hours of boilerplate setup for async database drivers, migration configs, and testing utilities. This skill automates the creation of a production-ready async FastAPI foundation using modern Python tooling.

    What it does

    • Bootstraps project structure following a modular architecture with clear separation of concerns.
    • Configures async SQL using SQLAlchemy or SQLModel with engines like PostgreSQL, MySQL, or SQLite.
    • Sets up migrations through Alembic with pre-configured async templates and auto-generation commands.
    • Implements generic CRUD via a base repository pattern to eliminate repetitive data access code.
    • Automates testing setup including pytest, pytest-asyncio, and a dedicated conftest.py for async endpoint testing.

    How it works

    1. Evaluation: Scans your directory for existing files to prevent accidental overwrites and identify conflicts.
    2. Configuration: Prompts for project name, database engine, Python version, and testing preferences.
    3. Scaffolding: Initializes the environment with uv, installs dependencies, and generates the core directory structure.
    4. Implementation: Writes config, database connection, main entry point, and repository files.
    5. Validation: Cross-references the generated codebase against architectural references to ensure consistency.

    Frameworks & tools

    Built for Python 3.12+ using FastAPI, SQLAlchemy, SQLModel, Alembic, and Pydantic. It relies on uv for lightning-fast package management and pytest for the testing suite.

    Why this beats prompting it yourself

    Prompting an LLM for a FastAPI setup usually results in a single-file "main.py" that doesn't scale. This skill enforces a professional multi-file architecture, correctly configures the tricky asyncio parts of Alembic, and ensures your repository pattern is typesafe from day one.

    Use cases

    • Scaffold a new microservice with PostgreSQL and async-driver support.
    • Add a standardized testing layer to an existing FastAPI codebase.
    • Migrate a synchronous SQLAlchemy setup to an asynchronous SQLModel architecture.
    • Benchmark your current project structure against FastAPI best practices.

    Known limitations

    Requires uv to be installed on the host machine. Database drivers like asyncpg or aiosqlite must be manually verified if using non-standard SQL engines.

    Requires 'uv' package manager. DB migrations via Alembic require manual environment variable updates to run against live instances. Driver support focused on asyncpg and aiosqlite.

    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

    Free forever

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 4 days ago

    • Free with an Agensi account

    Requires

    Python

    Permissions

    Terminal / Shell
    Read Files
    Network Access

    Allowed Hosts

    test
    Listed4 days ago

    What's inside

    Frequently Asked Questions

    This skill automates the complex setup of asynchronous database drivers and Alembic migrations, providing a production-grade multi-file directory structure that avoids the "single-file" limitations of typical LLM-generated code.

    The skill is optimized for Python 3.12+ and officially supports SQLAlchemy and SQLModel, with pre-configured engines for PostgreSQL, MySQL, and SQLite.

    Yes, the 'Evaluation' step scans your current directory to identify conflicts, allowing you to add standardized testing layers or repository patterns to your current codebase without overwriting existing logic.

    The skill generates a complete scaffold including modular directory structures, async database configurations, Alembic migration templates, a generic CRUD repository, and a fully functional pytest suite.

    You must have the `uv` package manager installed on your host machine, as the skill relies on it for fast dependency resolution and environment management.

    While the skill configures the core async boilerplate, you will still need to manually verify specific drivers like `asyncpg` or `aiosqlite` if you are using non-standard or highly customized SQL engines.

    New in APIs & Backend