cfircoo avatar

Sqlalchemy Postgres

This is a comprehensive setup guide for building database layers with SQLAlchemy 2.0, Pydantic, and PostgreSQL. It walks you through the modern async stack with proper type safety using Mapped[] annotations, separating ORM models from Pydantic schemas, and implementing the repository pattern. The workflows cover everything from initial setup to migrations with Alembic, and it pushes you toward production-ready patterns like connection pooling and async sessions with FastAPI. The auto-detection is smart enough to kick in when you mention database-related terms. Honestly, this is less of a quick reference and more of an opinionated project structure, which is exactly what you want when starting a new FastAPI project with a database.

skills.sh installs
507
GitHub stars
17
last updated
Aug 21, 2026

Install

$ npx -y skills add cfircoo/claude-code-toolkit --skill sqlalchemy-postgres --agent claude-code

Installs into .claude/skills of the current project.

Files

<essential_principles>

SQLAlchemy 2.0 + Pydantic + PostgreSQL Best Practices

This skill provides expert guidance for building production-ready database layers.

Stack

  • SQLAlchemy 2.0 with async support (asyncpg driver)
  • Pydantic v2 for validation and serialization
  • Alembic for migrations
  • PostgreSQL only

Core Principles

1. Separation of Concerns

models/       # SQLAlchemy ORM models (database layer)
schemas/      # Pydantic schemas (API layer)
repositories/ # Data access patterns
services/     # Business logic

2. Type Safety First Always use SQLAlchemy 2.0 style with Mapped[] type annotations:

from sqlalchemy.orm import Mapped, mapped_column

class User(Base):
    __tablename__ = "users"
    id: Mapped[int] = mapped_column(primary_key=True)
    name: Mapped[str] = mapped_column(String(100))

3. Async by Default Use async engine and sessions for FastAPI:

from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
engine = create_async_engine("postgresql+asyncpg://...")

Sponsors

Details

Repository
github.com/cfircoo/claude-code-toolkit
Categories
Backend & APIs, Python, Databases
First seen
Jun 3, 2026
1hkuds avatarcli-anything-adguardhomehkuds/cli-anythingCommand-line interface for AdGuard Home - Network-wide ad blocking and DNS management via AdGuard Home REST API. Designed for AI agents and power users who need507skills.sh installs
2kernel avatarkernel-clikernel/skillsUse the Kernel CLI to manage cloud browsers, apps, profiles, proxies, managed auth, API keys, projects, and organization limits. Use when installing or authenti507skills.sh installs
3mvanhorn avatarpp-weather-goatmvanhorn/printing-press-libraryUse this skill whenever the user asks about weather, forecasts, temperature, rain, storms, severe weather alerts, air quality, pollen, UV, or wants an activity 507skills.sh installs
4freestylefly avatarcanghe-danger-gemini-webfreestylefly/canghe-skillsGenerates images and text via reverse-engineered Gemini Web API. Supports text generation, image generation from prompts, reference images for vision input, and497skills.sh installs
5webmaxru avatarenonic-nextxp-integrationwebmaxru/enonic-agent-skillsGuides setup, development, and troubleshooting of the Next.js and Enonic XP headless integration (Next.XP framework). Covers Enonic adapter configuration, conte488skills.sh installs
6hummingbot avatarhummingbot-deployhummingbot/skillsDeploy Hummingbot trading infrastructure including API server, MCP server, and Condor Telegram bot. Use this skill when the user wants to install, deploy, set u486skills.sh installs