fastapi-development — Claude Code skill: FastAPI with async
A skill that steers your AI agent toward idiomatic FastAPI code: async routes, Pydantic validation, JWT auth and automatic OpenAPI docs.
npx skills add aj-geddes/useful-ai-prompts --skill fastapi-development -a claude-codeWhat fastapi-development does
The skill hands the agent a set of rules and worked examples for building FastAPI services. It opens with a minimal app: creating the FastAPI instance, wiring CORS middleware and logging. From there it points to six reference files under references/ covering application setup, Pydantic models, async database queries with SQLAlchemy, security and JWT, a service layer, and async API routes.
A DO and DON'T list is the part that actually changes output. The agent is told not to run synchronous database calls, not to return database models in responses, not to keep secrets in code, and not to put authentication inside route handlers. Install it before the first route exists, otherwise you will be unwinding those patterns later.
The skill is MIT-licensed and ships for Claude, Codex, Cursor, GitHub Copilot, Gemini CLI and OpenCode. Installation needs npx or gh, depending on the platform.
What it helps with
- scaffold a FastAPI app with CORS and logging
- define Pydantic request and response schemas
- write async SQLAlchemy queries
- protect routes with JWT authentication
- move business logic into a service layer
Example prompts for the agent
- create a FastAPI app with async routes and CORS enabled
- write Pydantic models for a user creation endpoint
- add JWT authentication to the protected routes
How to install fastapi-development
1Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill fastapi-development -a claude-code2Manually: put the files in place
~/.claude/skills/fastapi-development/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/fastapi-development/
1Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill fastapi-development -a codex2Manually: put the files in place
.agents/skills/fastapi-development/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill fastapi-development -a cursor2Manually: put the files in place
.cursor/skills/fastapi-development/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install aj-geddes/useful-ai-prompts fastapi-development2Manually: put the files in place
.github/skills/fastapi-development/SKILL.md1Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill fastapi-development -a gemini-cli2Platform CLI
gemini skills install https://github.com/aj-geddes/useful-ai-prompts --path skills/fastapi-developmentManually: put the files in place
.devin/skills/fastapi-development/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill fastapi-development -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
From the same set118
Similar
Nearby in Backend and APIs
Everything for Backend and APIs →Questions about fastapi-development
How do I install fastapi-development in Claude?
Run npx skills add aj-geddes/useful-ai-prompts --skill fastapi-development -a claude-code. The skill lands in ~/.claude/skills/fastapi-development/SKILL.md.
What does fastapi-development do?
It gives the agent instructions and examples for FastAPI work: async routes, Pydantic validation, dependency injection, JWT auth and automatic OpenAPI documentation.
Which platforms support the skill?
Claude, Codex, Cursor, GitHub Copilot, Gemini CLI and OpenCode. Each platform has its own install command and its own directory for the skill file.
Source text
SKILL.md · MIT
---
name: fastapi-development
description: >
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.
---
# 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
© aj-geddes · MIT · aj-geddes/useful-ai-prompts