Fastapi development

From aj-geddes/useful-ai-prompts · View interactive version

Fastapi development is an AI agent skill from the GitHub repository aj-geddes/useful-ai-prompts. Build high-performance FastAPI applications with async routes, validation, dependency injection, security, and automatic API documentation. Use when developing modern Python APIs with async support, automatic OpenAPI documentation, and high performance requirements.

How to use this skill

Skill file

FastAPI Development

Table of Contents

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

Quick Start

Minimal working example:

# 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 | FastAPI Application Setup |

| Pydantic Models for Validation | Pydantic Models for Validation |

| Async Database Models and Queries | Async Database Models and Queries |

| Security and JWT Authentication | Security and JWT Authentication |

| Service Layer for Business Logic | Service Layer for Business Logic |

| API Routes with Async Endpoints | API Routes with Async Endpoints |

Best Practices

✅ DO

❌ DON'T

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.