FastAPI Cursor Rules

April 15, 2026

FastAPI Cursor Rules

Project Structure

  • /main.py - app entry point
  • /routers - route modules
  • /schemas - Pydantic models
  • /services - business logic

Best Practices

  • Use HTTP methods correctly
  • Return appropriate status codes
  • Use Pydantic models for request/response
  • Use Field() for validation
  • Use async def for I/O operations
  • Use BackgroundTasks for long operations

AI Instructions

  • Use dependency injection
  • Add OpenAPI annotations
  • Include error responses in docs
  • Use Enum for fixed values