PluginBench
Rule

python 312 fastapi best practices cursorrules prom

via PatrickJS/awesome-cursorrules

Python 3.12 FastAPI development with Pydantic, SQLAlchemy, and authentication best practices.

What is python 312 fastapi best practices cursorrules prom?

Cursor rules for building FastAPI applications with Python 3.12 using industry-standard libraries for ORM, user management, authentication, and caching. Use this rule when starting FastAPI projects to enforce consistent code quality, type safety, and architectural patterns.

  • Enforces Python 3.12 with FastAPI, Pydantic, and SQLAlchemy stack
  • Requires Poetry for dependency management and Alembic for database migrations
  • Integrates fastapi-users for user management and fastapi-jwt-auth for authentication
  • Includes caching, rate limiting, pagination, and email sending via FastAPI extensions
  • Mandates PEP 8 compliance, type hints, docstrings, and exception handling
  • Promotes clean code practices: meaningful names, list comprehensions, virtual environments, and unit tests

Applies to

File patterns this rule matches.

**/*
Rule definition (reference)

Source of truth, from the repository.

Here are some best practices and rules you must follow:

  • You use Python 3.12
  • Frameworks:
    • pydantic
    • fastapi
    • sqlalchemy
  • You use poetry for dependency management
  • You use alembic for database migrations
  • You use fastapi-users for user management
  • You use fastapi-jwt-auth for authentication
  • You use fastapi-mail for email sending
  • You use fastapi-cache for caching
  • You use fastapi-limiter for rate limiting
  • You use fastapi-pagination for pagination
  1. Use Meaningful Names: Choose descriptive variable, function, and class names.
  2. Follow PEP 8: Adhere to the Python Enhancement Proposal 8 style guide for formatting.
  3. Use Docstrings: Document functions and classes with docstrings to explain their purpose.
  4. Keep It Simple: Write simple and clear code; avoid unnecessary complexity.
  5. Use List Comprehensions: Prefer list comprehensions for creating lists over traditional loops when appropriate.
  6. Handle Exceptions: Use try-except blocks to handle exceptions gracefully.
  7. Use Virtual Environments: Isolate project dependencies using virtual environments (e.g., venv).
  8. Write Tests: Implement unit tests to ensure code reliability.
  9. Use Type Hints: Utilize type hints for better code clarity and type checking.
  10. Avoid Global Variables: Limit the use of global variables to reduce side effects.

These rules will help you write clean, efficient, and maintainable Python code.

Related rules

Python development with containerization best practices and integration.

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

Python development best practices with typing, testing, and modern tooling standards.

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

Python development guidance with CLI and file system expertise

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

Django development best practices guide for scalable, maintainable web applications.

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

FastAPI development with async-first patterns, Pydantic validation, and scalable architecture.

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

FastAPI best practices, project structure, and development patterns for Python async web APIs.

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