Rule

0 installs · 0 said it worked

PatrickJS@patrickjs·
CodingRule· for Cursor

Cursor rules enforcing FastAPI and Python 3.12 best practices

A Cursor rules file that tells the assistant to write Python 3.12 FastAPI code using pydantic, sqlalchemy, alembic, and related libraries, and to follow general Python style, typing, docstring, and testing practices.

People use this for

  • fastapi cursor rules
  • python fastapi coding standards
  • write fastapi code with pydantic
  • cursor rules for python web api
  • make ai assistant follow fastapi best practices
Name
cursor-rules-enforcing-fastapi-and-python-312-best-practices
Works with
Cursor
License
CC0(as observed at the source)
Version
v1 · updated Nov 29, 2026
Imported · UnclaimedCC0

Imported on Nov 29, 2026 from github.com . License observed at the source on Nov 29, 2026: CC0.

Are you the author?Claim this profileRequest removal

Use this rule

$ curl -fsSL "https://promptcommunity.dev/api/v1/posts/cursor-rules-enforcing-fastapi-and-python-312-best-practices-ysne/export/mdc" -o .cursor/rules/cursor-rules-enforcing-fastapi-and-python-312-best-practices.mdc

Then open a new session; Cursor picks it up from .cursor/rules/.

Download cursor-rules-enforcing-fastapi-and-python-312-best-practices.mdc
Manual install

Save cursor-rules-enforcing-fastapi-and-python-312-best-practices.mdc as .cursor/rules/cursor-rules-enforcing-fastapi-and-python-312-best-practices.mdc for this project or ~/.cursor/rules/cursor-rules-enforcing-fastapi-and-python-312-best-practices.mdc for every project, then start a new session.

Rule


description: "Cursor rules for Python FastAPI development with best practices." globs: */ alwaysApply: false

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.

No result recorded yet. Added it? File a Tried-it report so the next person knows how it went in your editor.

Tried it

Reports from people who added this rule to their editor. They roll up into the badges above.

No one has filed a report yet. Try the prompt and be the first.

License: CC0v1 · published Nov 29, 2026

Comments

No comments yet. If you tried this prompt, say how it went.