PluginBench
Rule

python fastapi

via PatrickJS/awesome-cursorrules

FastAPI best practices, async patterns, and Pydantic validation for Python web APIs

What is python fastapi?

Provides guidance on building FastAPI applications with proper dependency injection, async/await patterns, and Pydantic schemas. Use this rule when developing REST APIs in FastAPI to ensure type safety, validation, and adherence to framework conventions.

  • Use Pydantic models for request and response schemas with automatic validation
  • Implement dependency injection for shared resources and cleaner code organization
  • Utilize async/await for non-blocking operations and better performance
  • Apply proper error handling with HTTPException and FastAPI's built-in error responses
  • Leverage FastAPI's automatic OpenAPI documentation and JSON Schema generation
  • Organize code with models, schemas, routers, dependencies, and services folders

Applies to

File patterns this rule matches.

**/*
Rule definition (reference)

Source of truth, from the repository.

Python FastAPI .cursorrules

FastAPI best practices

fastapi_best_practices = [ "Use Pydantic models for request and response schemas", "Implement dependency injection for shared resources", "Utilize async/await for non-blocking operations", "Use path operations decorators (@app.get, @app.post, etc.)", "Implement proper error handling with HTTPException", "Use FastAPI's built-in OpenAPI and JSON Schema support", ]

Folder structure

folder_structure = """ app/ main.py models/ schemas/ routers/ dependencies/ services/ tests/ """

Additional instructions

additional_instructions = """

  1. Use type hints for all function parameters and return values
  2. Implement proper input validation using Pydantic
  3. Use FastAPI's background tasks for long-running operations
  4. Implement proper CORS handling
  5. Use FastAPI's security utilities for authentication
  6. Follow PEP 8 style guide for Python code
  7. Implement comprehensive unit and integration tests """

Related rules

Senior full-stack TypeScript, React, Node.js guidance with clean architecture, testing, and WHY-oriented reasoning.

**/*
41k
via PatrickJS/awesome-cursorrules

Quantitative factor research skills for designing, evaluating, and mining alpha factors in equities markets.

**/*
41k
via PatrickJS/awesome-cursorrules

Android development with Jetpack Compose, clean architecture, and Material Design 3.

**/*
41k
via PatrickJS/awesome-cursorrules

Angular development with Novo Elements UI library using standalone components.

**/*
41k
via PatrickJS/awesome-cursorrules

Expert Angular 18 + TypeScript development with Jest, emphasizing clean code and performance.

**/*
41k
via PatrickJS/awesome-cursorrules

Manage Kubernetes clusters, add-ons, stacks, and credentials via the Ankra CLI platform.

**/*.sh +5
41k
via PatrickJS/awesome-cursorrules