fastapi-templates

Generates FastAPI project structures with async patterns, dependency injection, and repository layers.

Updated May 20, 2026
One-click install
npx skills add https://github.com/TechCorp25/kingdom --skill fastapi-templates-techcorp25
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: fastapi-templates
Source: https://github.com/TechCorp25/kingdom/tree/main/.claude/skills/api-scaffolding/skills/fastapi-templates
Command: npx skills add https://github.com/TechCorp25/kingdom --skill fastapi-templates-techcorp25

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Setting up a new FastAPI backend involves repetitive decisions about project layout, async database sessions, authentication, and error handling. This Skill provides complete, working code patterns so you can scaffold a well-structured API without assembling boilerplate from scratch. ## Core Features & Use Cases - Project Scaffolding: Provides a recommended directory layout separating API routes, core config, models, schemas, services, and repositories. - Async CRUD Patterns: Includes a generic base repository, service layer, and endpoint implementations using SQLAlchemy async sessions and dependency injection. - Authentication & Testing: Supplies JWT-based auth with password hashing, plus pytest fixtures using in-memory SQLite and httpx AsyncClient. - Use Case: When starting a new microservice, ask for a FastAPI project with user management and receive main.py, config, database session handling, user endpoints, and tests following these patterns. ## Quick Start Ask the assistant to scaffold a new FastAPI project with async SQLAlchemy, JWT authentication, and a users endpoint using these templates.

Frequently Asked Questions about fastapi-templates

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

FAQPage Schema
How do I structure a FastAPI project for production?▼

Organize code into separate directories for API routes, core configuration, database models, Pydantic schemas, services, and repositories. This separation keeps business logic in the service layer and data access in repositories, making the codebase testable and maintainable.

How to use async SQLAlchemy with FastAPI dependency injection?▼

Create an async engine and sessionmaker, then define a get_db dependency that yields an AsyncSession with commit, rollback, and close handling. Inject it into route handlers with Depends so each request gets its own session.

Does FastAPI support JWT authentication with password hashing?▼

Yes, combine python-jose for JWT token creation and verification with passlib's CryptContext using bcrypt for password hashing. Use OAuth2PasswordBearer as a dependency to extract and validate tokens per request.

How do I test FastAPI endpoints with an async database?▼

Use pytest fixtures with an in-memory SQLite database via aiosqlite, override the get_db dependency with app.dependency_overrides, and call endpoints through httpx AsyncClient. This isolates tests from your real database.

What is the repository pattern in FastAPI applications?▼

The repository pattern encapsulates database queries in a generic base class with get, create, update, and delete methods typed by model and schema. Services call repositories instead of writing raw queries, keeping endpoints thin and logic reusable.