beta

Python FastAPI CLAUDE.md

Rules

Agent rules for FastAPI projects with SQLAlchemy, Alembic, and pytest.

2503/23/2026

Version 1

Published

Initial version

Created 3/23/2026

Initial version — no previous version to compare

CLAUDE.md
# CLAUDE.md

## Project
Python FastAPI application with SQLAlchemy ORM, Alembic migrations, and pytest.

## Commands
- `uv run fastapi dev` — start dev server
- `uv run pytest` — run tests
- `uv run alembic upgrade head` — run migrations
- `uv run ruff check .` — lint
- `uv run ruff format .` — format

## Code Style
- Use type hints everywhere
- Use Pydantic models for request/response schemas
- Use dependency injection for database sessions
- Follow Google Python style guide
- Keep functions under 30 lines

## Architecture
- app/api/ — route handlers
- app/models/ — SQLAlchemy models
- app/schemas/ — Pydantic schemas
- app/services/ — business logic
- app/core/ — config, security, deps

## Database
- Always create Alembic migrations for schema changes
- Use async SQLAlchemy sessions
- Never use raw SQL — use the ORM