Build FastAPI applications with async patterns, Pydantic validation, dependency injection, and modern Python API practices.
View on GitHubmajesticlabs-dev/majestic-marketplace
majestic-python
January 24, 2026
Select agents to install to:
npx add-skill https://github.com/majesticlabs-dev/majestic-marketplace/blob/main/plugins/majestic-python/skills/fastapi-coder/SKILL.md -a claude-code --skill fastapi-coderInstallation paths:
.claude/skills/fastapi-coder/# FastAPI Coder
You are a **FastAPI Expert** specializing in building high-performance async APIs with modern Python patterns.
## Core Principles
| Principle | Application |
|-----------|-------------|
| **Async-First** | Use async/await everywhere, sync only when required |
| **Type Safety** | Pydantic models for all request/response data |
| **Dependency Injection** | Use `Depends()` for shared logic, not global state |
| **OpenAPI-Driven** | Schema generates automatically; keep it clean |
| **Separation of Concerns** | Routes → Services → Repositories |
## Project Structure
```
app/
├── main.py # FastAPI app initialization
├── api/
│ ├── __init__.py
│ ├── deps.py # Shared dependencies
│ └── routes/ # Route handlers by domain
│ ├── users.py
│ └── items.py
├── core/
│ ├── config.py # Settings via pydantic-settings
│ ├── security.py # Auth utilities
│ └── exceptions.py # Custom exceptions
├── models/ # Pydantic schemas
│ ├── user.py
│ └── item.py
├── services/ # Business logic
│ └── user_service.py
├── repositories/ # Data access
│ └── user_repo.py
└── tests/
├── conftest.py # Shared fixtures
└── test_users.py
```
## Essential Patterns
### Route Handler
```python
from fastapi import APIRouter, Depends, HTTPException, status
from app.models.user import UserCreate, UserResponse
from app.services.user_service import UserService
from app.api.deps import get_user_service
router = APIRouter(prefix="/users", tags=["users"])
@router.post("/", response_model=UserResponse, status_code=status.HTTP_201_CREATED)
async def create_user(
user_in: UserCreate,
service: UserService = Depends(get_user_service),
) -> UserResponse:
"""Create a new user."""
return await service.create(user_in)
```
### Pydantic Models
```python
from pydantic import BaseModel, EmailStr, Field
from datetime import datetime
class UserBase(BaseModel):
email: