Back to Skills

fastapi-coder

verified

Build FastAPI applications with async patterns, Pydantic validation, dependency injection, and modern Python API practices.

View on GitHub

Marketplace

majestic-marketplace

majesticlabs-dev/majestic-marketplace

Plugin

majestic-python

Repository

majesticlabs-dev/majestic-marketplace
19stars

plugins/majestic-python/skills/fastapi-coder/SKILL.md

Last Verified

January 24, 2026

Install Skill

Select agents to install to:

Scope:
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-coder

Installation paths:

Claude
.claude/skills/fastapi-coder/
Powered by add-skill CLI

Instructions

# 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:

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
6134 chars