
Fastapi Development
Scaffold and extend production-style FastAPI services with async routes, Pydantic validation, CORS, logging, and OpenAPI docs for a solo-builder API or microservice.
Overview
FastAPI Development is an agent skill for the Build phase that guides creation of high-performance async Python REST APIs with validation, middleware, logging, and automatic OpenAPI documentation.
Install
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill fastapi-developmentWhat is this skill?
- Async FastAPI app bootstrap with title, version, and configurable docs_url
- HTTPException and status codes for consistent error handling
- CORSMiddleware pattern for browser clients hitting your API
- Structured logging setup via logging.basicConfig and module loggers
- Oriented toward OpenAPI/Swagger, Pydantic validation, JWT, and SQLAlchemy per skill overview
Adoption & trust: 502 installs on skills.sh; 251 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need a FastAPI service skeleton with async routes, validation, and docs but keep patching together incomplete snippets that miss CORS, logging, or error conventions.
Who is it for?
Solo builders creating Python microservices, SaaS APIs, or agent backends where async performance and Swagger docs matter from day one.
Skip if: Pure serverless one-function deployments with no FastAPI layer, or teams standardized on Django-only monoliths without HTTP API needs.
When should I use this skill?
Developing modern Python APIs with async support, automatic OpenAPI documentation, and high performance requirements.
What do I get? / Deliverables
You get a coherent FastAPI application structure ready to extend with routes, Pydantic models, auth, and ORM layers following the skill's reference guides.
- FastAPI application entrypoint with middleware and logging
- Route modules and patterns aligned with skill reference guides
Recommended Skills
Journey fit
FastAPI application structure is created during the Build phase when you turn a validated product idea into a shippable HTTP API. Backend is the primary shelf because the skill centers on REST/async endpoints, middleware, and service bootstrap—not frontend UI or launch SEO.
How it compares
Opinionated FastAPI build playbook for agents—not a generic Python tutorial or an OpenAPI code generator MCP.
Common Questions / FAQ
Who is fastapi-development for?
Indie developers and small teams building Python HTTP APIs who want FastAPI async patterns, Pydantic validation, and OpenAPI docs wired consistently by their coding agent.
When should I use fastapi-development?
During Build backend work when creating REST APIs, async endpoints, microservices, or services that need automatic Swagger/OpenAPI documentation and type-driven validation.
Is fastapi-development safe to install?
Treat it like any third-party agent skill: check the Security Audits panel on this page and review generated code for secrets, overly broad CORS, and dependency versions.
SKILL.md
READMESKILL.md - Fastapi Development
# FastAPI Development ## Table of Contents - [Overview](#overview) - [When to Use](#when-to-use) - [Quick Start](#quick-start) - [Reference Guides](#reference-guides) - [Best Practices](#best-practices) ## Overview Create fast, modern Python APIs using FastAPI with async/await support, automatic API documentation, type validation using Pydantic, dependency injection, JWT authentication, and SQLAlchemy ORM integration. ## When to Use - Building high-performance Python REST APIs - Creating async API endpoints - Implementing automatic OpenAPI/Swagger documentation - Leveraging Python type hints for validation - Building microservices with async support - Integrating Pydantic for data validation ## Quick Start Minimal working example: ```python # main.py from fastapi import FastAPI, HTTPException, status from fastapi.middleware.cors import CORSMiddleware from contextlib import asynccontextmanager import logging # Setup logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) # Create FastAPI instance app = FastAPI( title="API Service", description="A modern FastAPI application", version="1.0.0", docs_url="/api/docs", openapi_url="/api/openapi.json" ) # Add CORS middleware app.add_middleware( CORSMiddleware, allow_origins=["http://localhost:3000"], allow_credentials=True, allow_methods=["*"], // ... (see reference guides for full implementation) ``` ## Reference Guides Detailed implementations in the `references/` directory: | Guide | Contents | |---|---| | [FastAPI Application Setup](references/fastapi-application-setup.md) | FastAPI Application Setup | | [Pydantic Models for Validation](references/pydantic-models-for-validation.md) | Pydantic Models for Validation | | [Async Database Models and Queries](references/async-database-models-and-queries.md) | Async Database Models and Queries | | [Security and JWT Authentication](references/security-and-jwt-authentication.md) | Security and JWT Authentication | | [Service Layer for Business Logic](references/service-layer-for-business-logic.md) | Service Layer for Business Logic | | [API Routes with Async Endpoints](references/api-routes-with-async-endpoints.md) | API Routes with Async Endpoints | ## Best Practices ### ✅ DO - Use async/await for I/O operations - Leverage Pydantic for validation - Use dependency injection for services - Implement proper error handling with HTTPException - Use type hints for automatic OpenAPI documentation - Create service layers for business logic - Implement authentication on protected routes - Use environment variables for configuration - Return appropriate HTTP status codes - Document endpoints with docstrings and tags ### ❌ DON'T - Use synchronous database operations - Trust user input without validation - Store secrets in code - Ignore type hints - Return database models in responses - Implement authentication in route handlers - Use mutable default arguments - Forget to validate query parameters - Expose stack traces in production # API Routes with Async Endpoints ## API Routes with Async Endpoints ```python # routes.py from fastapi import APIRouter, Depends, HTTPException, status from fastapi.responses import JSONResponse from sqlalchemy.ext.asyncio import AsyncSession from database import get_db from models import UserCreate, UserUpdate, UserResponse, PostCreate, PostResponse from security import get_current_user, create_access_token from services import UserService, PostService router = APIRouter(prefix="/api", tags=["users"]) @router.post("/auth/register", response_model=UserResponse, status_code=status.HTTP_201_CREATED) async def regis