last update
May 23, 2026
license
MITv1.0.0
format
SKILL.md
- Install
// Downloads SKILL.md into ~/.claude/skills/fastapi-python-pro/
$ curl -fsSL --create-dirs -o ~/.claude/skills/fastapi-python-pro/SKILL.md https://claudeskil.com/skills/fastapi-python-pro/SKILL.md - Invoke
// Inside Claude Code, type the skill name as a slash command
> /fastapi-python-pro scaffold a typed REST endpoint - Or just ask
// Claude loads the skill by itself when a request matches its description
> scaffold a typed REST endpoint
- name:
- FastAPI Python Pro
- slug:
- fastapi-python-pro
- version:
- v1.0.0
- license:
- MIT
- author:
- @chiragthummar16
- categories:
- tags:
- #fastapi#python#pydantic#sqlalchemy#async
- description:
FastAPI + Pydantic v2 + SQLAlchemy 2: async Python APIs with auto-generated OpenAPI docs.
// What you can do with it
- Generates Pydantic v2 schemas using modelconfig = ConfigDict(fromattributes=True), Field constraints, and fieldvalidator / modelvalidator — not the deprecated v1 Config class or @validator.
- Sets up async SQLAlchemy with createasyncengine, DeclarativeBase, and Mapped[...] / mapped_column() typed models.
- Provides a get_db() dependency yielding an AsyncSession, injected via Depends(), and an OAuth2PasswordBearer flow issuing JWTs (python-jose + passlib/bcrypt).
- Initializes Alembic (alembic init, env.py pointed at your async engine) and writes the first autogenerated revision.
- OpenAPI docs come free at /docs and /redoc from your typed signatures.
README.md
FastAPI Python Pro
A scaffolding and code-assist skill for building production async APIs with FastAPI, Pydantic v2, and SQLAlchemy 2.0. It wires up the parts that are fiddly to assemble by hand — async session management, typed request/response models, JWT auth, and Alembic migrations — so you start from a working, idiomatic project instead of a blank main.py. Aimed at backend and full-stack developers who want correct async patterns rather than copy-pasted snippets that block the event loop.
When to use it
- Starting a new service and you want a sane layout (
routers/,models/,schemas/,deps.py) from the first commit. - Adding async database access with SQLAlchemy 2.0's
async_sessionmakerandAsyncSessionwithout leaking sessions across requests. - Bolting JWT login onto an existing app, or migrating Pydantic v1 models to v2.
- You keep getting
greenlet_spawnerrors or "this session is already flushing" and need the dependency lifecycle done right.
What it does
- Generates Pydantic v2 schemas using
model_config = ConfigDict(from_attributes=True),Fieldconstraints, andfield_validator/model_validator— not the deprecated v1Configclass or@validator. - Sets up async SQLAlchemy with
create_async_engine,DeclarativeBase, andMapped[...]/mapped_column()typed models. - Provides a
get_db()dependency yielding anAsyncSession, injected viaDepends(), and anOAuth2PasswordBearerflow issuing JWTs (python-jose + passlib/bcrypt). - Initializes Alembic (
alembic init,env.pypointed at your async engine) and writes the first autogenerated revision. - OpenAPI docs come free at
/docsand/redocfrom your typed signatures.
Example
curl -fsSL --create-dirs -o ~/.claude/skills/fastapi-python-pro/SKILL.md https://claudeskil.com/skills/fastapi-python-pro/SKILL.md
# then, in your project:
"Scaffold a FastAPI app with a User model, async Postgres,
JWT auth, and an Alembic baseline migration."
Generated route:
@router.get("/users/{user_id}", response_model=UserRead)
async def read_user(user_id: int, db: AsyncSession = Depends(get_db)):
user = await db.get(User, user_id)
if user is None:
raise HTTPException(404, "User not found")
return user
Tips & gotchas
- Define
get_dbwithasync with async_sessionmaker() as session: yield session— never share one session across requests. - Set
expire_on_commit=Falseon the sessionmaker, or attributes become un-awaited and detached after commit. - Alembic autogenerate needs your models imported into
env.py'starget_metadata, and the async engine wrapped withrun_syncinrun_migrations_online. - Use
await db.execute(select(...))then.scalars(); the olddb.query()API is removed in 2.0 style.
FAQ
Does it require Postgres? No — defaults to asyncpg/Postgres but works with aiosqlite for local dev; swap the DATABASE_URL.
Pydantic v1 or v2? Strictly v2 (ConfigDict, model_dump(), Annotated fields). It can help port v1 code.
Can I run sync DB drivers? Possible, but the scaffold assumes async; mixing sync drivers under async routes will block the loop.
$ cat reviews/