backend-fastapi-python

Implement FastAPI endpoints with AsyncSession, Pydantic schemas, and auth dependencies.

113|15|Updated Mar 3, 2026
One-click install
npx skills add https://github.com/avibebuilder/claude-prime --skill backend-fastapi-python
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: backend-fastapi-python
Source: https://github.com/avibebuilder/claude-prime/tree/main/.claude/starter-skills/backend-fastapi-python
Command: npx skills add https://github.com/avibebuilder/claude-prime --skill backend-fastapi-python

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill reduces inconsistent, ad-hoc backend patterns and repetitive prompt work by giving clear, project-specific conventions and troubleshooting guidance for building Python APIs with FastAPI, SQLModel, and async SQLAlchemy.

Core Features & Use Cases

  • Consistent service signatures: Enforce stateless service functions with AsyncSession as the first parameter to standardize database access.
  • API response and error conventions: Use ApiResponse[T] wrappers, AppException with machine-readable error_code, and centralized exception handlers for predictable frontend integration.
  • Auth, dependencies, and middleware patterns: Provide chainable auth dependencies (get_current_user → require_auth → require_admin), cookie or bearer strategies, request-id and logging middleware, and background task guidance.
  • Database and migration guidance: Async engine/session setup, expire_on_commit recommendations, query patterns, and Alembic autogenerate caveats for production-safe migrations.

Quick Start

Use the backend-fastapi-python skill to implement a new FastAPI endpoint with AsyncSession injection, a Pydantic response schema, and the appropriate authentication dependency.

Frequently Asked Questions about backend-fastapi-python

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure FastAPI service functions with async SQLAlchemy?

FastAPI service functions should be stateless with AsyncSession as the first parameter to standardize database access. This pattern ensures consistent query execution and transaction management across your API endpoints.

What's the best way to standardize API responses and error handling in FastAPI?

Standardize API responses in FastAPI using ApiResponse[T] wrappers and AppException with machine-readable error_code. Centralized exception handlers provide predictable frontend integration and consistent error formatting.

How do I chain authentication dependencies in FastAPI?

Chain FastAPI auth dependencies using get_current_user → require_auth → require_admin. This pattern supports cookie or bearer strategies and allows role-based access control across protected endpoints.

How do I handle Alembic migrations with async SQLAlchemy in FastAPI?

Alembic migrations with async SQLAlchemy require attention to autogenerate caveats for production safety. Configure async engine and session setup carefully, and follow expire_on_commit recommendations to avoid lazy loading issues.

Why does my FastAPI background task fail with async SQLAlchemy sessions?

FastAPI background tasks require proper async I/O handling and session management. Use async SQLAlchemy session patterns correctly, ensuring sessions are properly scoped and expired objects are handled before background execution.