FastAPI Project Templates
SkillAI & modelsThe fastapi-templates skill guides an AI agent through creating production-ready FastAPI projects. It sets up a recommended folder layout with routes, models, schemas, services, and repositories, and applies async patterns, dependency injection, and error handling. It also includes example pytest fixtures for testing endpoints with an async test client.
Use FastAPI Project Templates in Claude, ChatGPT or Ahel Desktop
Free. Sign in, add FastAPI Project Templates and connect your AI. About a minute.
Also: Claude Code · Cursor · Codex
Then ask your AI: use the FastAPI Project Templates skill
Details
Instructions available. Your AI can read the instructions. Execution depends on the setup they require.
Account requirements not reviewed. Check the skill instructions before use; ahel provides instructions and does not run this skill.
No other account needed.
Have a Python environment ready with FastAPI and an async database driver installed.
What your AI can do with it
- Scaffold a FastAPI project with api, core, models, schemas, services, and repositories
- Apply async/await patterns to route handlers, database operations, and middleware
- Set up FastAPI dependency injection for database sessions, auth, and shared logic
- Generate pytest fixtures for testing endpoints with an async test client
- Include comprehensive error handling in the generated project
Getting started
- Have a Python environment ready with FastAPI and an async database driver installed.
- Ask the agent to create a new FastAPI project using the fastapi-templates skill.
- Review the generated folder layout and adjust the routes, models, and schemas for your API.
- Run the included pytest fixtures to test your endpoints with the async test client.
What this skill tells your AI
The instructions your AI receives, as published by wshobson/agents in plugins/api-scaffolding/skills/fastapi-templates/SKILL.md and read by ahel’s review.
Production-ready FastAPI project structures with async patterns, dependency injection, middleware, and best practices for building high-performance APIs.
When to Use This Skill
- Starting new FastAPI projects from scratch
- Implementing async REST APIs with Python
- Building high-performance web services and microservices
- Creating async applications with PostgreSQL, MongoDB
- Setting up API projects with proper structure and testing
Core Concepts
1. Project Structure
Recommended Layout:
app/
├── api/ # API routes
│ ├── v1/
│ │ ├── endpoints/
│ │ │ ├── users.py
│ │ │ ├── auth.py
│ │ │ └── items.py
│ │ └── router.py
│ └── dependencies.py # Shared dependencies
├── core/ # Core configuration
│ ├── config.py
│ ├── security.py
│ └── database.py
├── models/ # Database models
│ ├── user.py
│ └── item.py
├── schemas/ # Pydantic schemas
│ ├── user.py
│ └── item.py
├── services/ # Business logic
│ ├── user_service.py
│ └── auth_service.py
├── repositories/ # Data access
│ ├── user_repository.py
│ └── item_repository.py
└── main.py # Application entry
2. Dependency Injection
FastAPI's built-in DI system using Depends:
- Database session management
- Authentication/authorization
- Shared business logic
- Configuration injection
3. Async Patterns
Proper async/await usage:
- Async route handlers
- Async database operations
- Async background tasks
- Async middleware
Detailed worked examples and patterns
Detailed sections (starting with ## Implementation Patterns) live in references/details.md. Read that file when the navigation summary above is insufficient.
Testing
# tests/conftest.py
import pytest
import asyncio
from httpx import AsyncClient
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
from sqlalchemy.orm import sessionmaker
from app.main import app
from app.core.database import get_db, Base
TEST_DATABASE_URL = "sqlite+aiosqlite:///:memory:"
@pytest.fixture(scope="session")
def event_loop():
loop = asyncio.get_event_loop_policy().new_event_loop()
yield loop
loop.close()
@pytest.fixture
async def db_session():
engine = create_async_engine(TEST_DATABASE_URL, echo=True)
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)
AsyncSessionLocal = sessionmaker(
engine, class_=AsyncSession, expire_on_commit=False
)
async with AsyncSessionLocal() as session:
yield session
@pytest.fixture
async def client(db_session):
async def override_get_db():
yield db_session
app.dependency_overrides[get_db] = override_get_db
async with AsyncClient(app=app, base_url="http://test") as client:
yield client
# tests/test_users.py
import pytest
@pytest.mark.asyncio
async def test_create_user(client):
response = await client.post(
"/api/v1/users/",
json={
"email": "test@example.com",
"password": "testpass123",
"name": "Test User"
}
)
assert response.status_code == 201
data = response.json()
assert data["email"] == "test@example.com"
assert "id" in data
Signals
- GitHub stars
- 40k
- Forks
- 4k
- Last commit
- Sep 2026
Others that do the same job
Questions
- What kind of project structure does it create?
- It creates an app folder with api, core, models, schemas, services, and repositories subfolders, plus a main.py entry point.
- Does it support async database operations?
- Yes, it applies async/await patterns to route handlers, database operations, background tasks, and middleware.
- Can I use it with PostgreSQL or MongoDB?
- Yes, the skill is intended for async applications with PostgreSQL or MongoDB.
- How does it handle testing?
- It includes example pytest fixtures for testing endpoints with an async test client.
Advanced
- Item type
- skill
- Key
fastapi-templates-wshobson- Source
- github.com/wshobson/agents
Related picks
Skill · affaan-m
Does the same job in other wordsbackend-fastapi-python
Skill · avibebuilder
Does the same job in other wordsfastapi-backend-scaffold
Skill · 5zjk5
Does the same job in other wordspython-performance-optimization
Skill · wshobson
The pick for Pythonpython-pro
Skill · jeffallan
The pick for Pythonfastapi
Skill · fastapi
The pick for FastAPI