/fastapi-backend:fastapi-project-structurefrom fastapi-backend
Scaffolds production-ready FastAPI projects with templates for minimal, standard, MCP-server, full-stack, and microservice setups. Handles directory structure, settings management, Docker, and configuration files.
Ships in fastapi-backend. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Production-ready FastAPI project scaffolding templates and best practices for building scalable, maintainable backend applications with MCP integration support.
Select the appropriate project template based on your use case:
Use the setup script to scaffold a new FastAPI project:
cd /home/gotime2022/.claude/plugins/marketplaces/ai-dev-marketplace/plugins/fastapi-backend/skills/fastapi-project-structure
./scripts/setup-project.sh <project-name> <template-type>
Template types: minimal, standard, mcp-server, full-stack, microservice
Example:
./scripts/setup-project.sh my-api-service standard
What This Creates:
The skill uses Pydantic Settings for configuration management:
Settings Structure:
# app/core/config.py
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
# App Configuration
PROJECT_NAME: str = "FastAPI App"
VERSION: str = "1.0.0"
DEBUG: bool = False
# Server Configuration
HOST: str = "0.0.0.0"
PORT: int = 8000
# Database Configuration (if needed)
DATABASE_URL: str
# Security
SECRET_KEY: str
ALLOWED_ORIGINS: list[str] = ["*"]
class Config:
env_file = ".env"
case_sensitive = True
Environment Variables:
Copy .env.example to .env and customize:
cp .env.example .env
# Edit .env with your configuration
my-api-service/
├── app/
│ ├── __init__.py
│ ├── main.py # Application entry point
│ ├── core/
│ │ ├── __init__.py
│ │ ├── config.py # Settings management
│ │ └── dependencies.py # Dependency injection
│ ├── api/
│ │ ├── __init__.py
│ │ ├── routes/ # API route handlers
│ │ │ ├── __init__.py
│ │ │ ├── health.py
│ │ │ └── users.py
│ │ └── deps.py # Route dependencies
│ ├── models/ # Pydantic models
│ │ ├── __init__.py
│ │ └── user.py
│ ├── schemas/ # Request/Response schemas
│ │ ├── __init__.py
│ │ └── user.py
│ └── services/ # Business logic
│ ├── __init__.py
│ └── user_service.py
├── tests/
│ ├── __init__.py
│ ├── conftest.py
│ └── test_api/
├── .env.example
├── .gitignore
├── pyproject.toml
├── README.md
└── Dockerfile (optional)
my-mcp-api/
├── app/
│ ├── main.py # FastAPI + MCP server
│ ├── core/
│ │ ├── config.py
│ │ └── mcp_config.py # MCP-specific settings
│ ├── api/
│ │ └── routes/
│ ├── mcp/
│ │ ├── __init__.py
│ │ ├── server.py # MCP server instance
│ │ ├── tools/ # MCP tools
│ │ ├── resources/ # MCP resources
│ │ └── prompts/ # MCP prompts
│ └── services/
├── .mcp.json # MCP configuration
├── pyproject.toml
└── README.md
Run validation to ensure proper structure and dependencies:
./scripts/validate-structure.sh <project-directory>
Validation Checks:
Initialize the development environment:
# Navigate to project
cd <project-name>
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -e ".[dev]"
# Run development server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
For projects with MCP server support:
# Configure MCP settings
cp templates/mcp-config-template.json .mcp.json
# Edit MCP configuration
# Add tools, resources, and prompts
# Run as MCP server (STDIO mode)
python -m app.main --mcp
# Run as HTTP server
uvicorn app.main:app --host 0.0.0.0 --port 8000
See the examples directory for:
minimal-api/: Simple FastAPI applicationcrud-api/: Complete CRUD API with databasemcp-integrated-api/: FastAPI + MCP servermicroservice-template/: Production microserviceauth-api/: API with JWT authentication[project]
name = "my-api-service"
version = "1.0.0"
description = "FastAPI application"
requires-python = ">=3.11"
dependencies = [
"fastapi>=0.115.0",
"uvicorn[standard]>=0.32.0",
"pydantic>=2.0.0",
"pydantic-settings>=2.0.0",
]
[project.optional-dependencies]
dev = [
"pytest>=8.0.0",
"pytest-asyncio>=0.24.0",
"httpx>=0.27.0",
"ruff>=0.6.0",
"mypy>=1.11.0",
]
mcp = [
"mcp>=1.0.0",
]
[tool.ruff]
line-length = 100
target-version = "py311"
[tool.mypy]
python_version = "3.11"
strict = true
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.core.config import settings
from app.api.routes import health, users
app = FastAPI(
title=settings.PROJECT_NAME,
version=settings.VERSION,
debug=settings.DEBUG,
)
# CORS
app.add_middleware(
CORSMiddleware,
allow_origins=settings.ALLOWED_ORIGINS,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include routers
app.include_router(health.router, prefix="/health", tags=["health"])
app.include_router(users.router, prefix="/api/v1/users", tags=["users"])
@app.get("/")
async def root():
return {"message": f"Welcome to {settings.PROJECT_NAME}"}
FROM python:3.11-slim as builder
WORKDIR /app
COPY pyproject.toml .
RUN pip install --no-cache-dir build && \
python -m build --wheel
FROM python:3.11-slim
WORKDIR /app
COPY --from=builder /app/dist/*.whl .
RUN pip install --no-cache-dir *.whl && rm *.whl
COPY app/ ./app/
EXPOSE 8000
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
Project Structure:
Configuration:
Code Organization:
Testing:
Security:
Performance:
# 1. Generate project structure
./scripts/setup-project.sh my-api standard
# 2. Add new route file
# Create app/api/routes/items.py
# 3. Add schemas
# Create app/schemas/item.py
# 4. Add service logic
# Create app/services/item_service.py
# 5. Register router in main.py
# app.include_router(items.router, prefix="/api/v1/items")
# 1. Generate MCP-enabled project
./scripts/setup-project.sh my-mcp-api mcp-server
# 2. Configure .mcp.json
cp templates/mcp-config-template.json my-mcp-api/.mcp.json
# 3. Add MCP tools
# Copy from templates/mcp-tool-template.py to app/mcp/tools/
# 4. Run in MCP mode
cd my-mcp-api
python -m app.main --mcp
# 1. Build Docker image
docker build -t my-api:latest .
# 2. Run container
docker run -d -p 8000:8000 \
--env-file .env.prod \
--name my-api \
my-api:latest
# 3. Health check
curl http://localhost:8000/health
Import errors: Ensure virtual environment is activated and dependencies installed
Port already in use: Change PORT in .env or use different port with --port flag
Environment variables not loading: Check .env file location and syntax, ensure pydantic-settings installed
MCP server not starting: Verify .mcp.json configuration and mcp package installed
Type checking errors: Run mypy app/ to see detailed type errors, ensure all dependencies have type stubs
Plugin: fastapi-backend Version: 1.0.0 Category: Project Structure & Scaffolding Skill Type: Templates & Automation
README.md (opens in a new tab)examples/mcp-integrated-example.md (opens in a new tab)examples/minimal-api-example.md (opens in a new tab)examples/production-best-practices.md (opens in a new tab)scripts/setup-project.sh (opens in a new tab)scripts/validate-structure.sh (opens in a new tab)templates/config-template.py (opens in a new tab)templates/dockerfile-template (opens in a new tab)templates/health-route-template.py (opens in a new tab)templates/main-template.py (opens in a new tab)templates/mcp-config-template.json (opens in a new tab)templates/pyproject-template.toml (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
fastapi-scaffold, project-template, mcp-server, backend-setup
npx claudepluginhub vanman2024/ai-dev-marketplace --plugin fastapi-backend6 skills in this plugin
/async-sqlalchemy-patternsAsync SQLAlchemy 2.0+ database patterns for FastAPI including session management, connection pooling, Alembic migrations, relationship loading strategies, and query optimization. Use when implementing database models, configuring async sessions, setting up migrations, optimizing queries, managing relationships, or when user mentions SQLAlchemy, async database, ORM, Alembic, database performance, or connection pooling./fastapi-api-patternsREST API design and implementation patterns for FastAPI endpoints including CRUD operations, pagination, filtering, error handling, and request/response models. Use when building FastAPI endpoints, creating REST APIs, implementing CRUD operations, adding pagination, designing API routes, handling API errors, or when user mentions FastAPI patterns, REST API design, endpoint structure, API best practices, or HTTP endpoints./fastapi-auth-patternsImplement and validate FastAPI authentication strategies including JWT tokens, OAuth2 password flows, OAuth2 scopes for permissions, and Supabase integration. Use when implementing authentication, securing endpoints, handling user login/signup, managing permissions, integrating OAuth providers, or when user mentions JWT, OAuth2, Supabase auth, protected routes, access control, role-based permissions, or authentication errors./fastapi-deployment-configConfigure multi-platform deployment for FastAPI applications including Docker containerization, Railway, DigitalOcean App Platform, and AWS deployment. Use when deploying FastAPI apps, setting up production environments, containerizing applications, configuring cloud platforms, implementing health checks, managing environment variables, setting up reverse proxies, or when user mentions Docker, Railway, DigitalOcean, AWS, deployment configuration, production setup, or container orchestration./mem0-fastapi-integrationMemory layer integration patterns for FastAPI with Mem0 including client setup, memory service patterns, user tracking, conversation persistence, and background task integration. Use when implementing AI memory, adding Mem0 to FastAPI, building chat with memory, or when user mentions Mem0, conversation history, user context, or memory layer.Other plugins' skills for the same job