Sign in
Explore
Prompts · RulesBackend & APIsDatabasesBackend frameworksReviewed

python

Python best practices and project structure, for Flask and SQLite projects.

Kind
Rules
Works with
Cursor
Languages
Python, SQL
Source
Awesome Cursor Rules @ b044f956f021
Path
rules/python.mdc
Jobs
Implementation
Topics
Databases, Backend frameworks

Credit

Made by
PatrickJS
Original
github.com/PatrickJS/awesome-cursorrules/blob/b044f956f021b6e…
License
CC0-1.0

Listed by Skill Manifest; not made by us.

InstallCopy it from the source repository, or sign in and let the assistant adapt it for your project.
Install factsScanned 3 Nov 2026
Adds
  • Text to merge into your CLAUDE.md or AGENTS.md (no new files)
Runs scripts
None found
Uses the network
None found
Needs secrets
None found
Source revision
b044f956f021
Licence
CC0-1.0
Last activity
30 May 2026
Review
Reviewed

Found by a static scan of the stored text; nothing is run. “None found” is not a guarantee, so read what you install before you run it.

# Python Best Practices

## Project Structure
- Use src-layout with `src/your_package_name/`
- Place tests in `tests/` directory parallel to `src/`
- Keep configuration in `config/` or as environment variables
- Store requirements in `requirements.txt` or `pyproject.toml`
- Place static files in `static/` directory
- Use `templates/` for Jinja2 templates

## Code Style
- Follow Black code formatting
- Use isort for import sorting
- Follow PEP 8 naming conventions:
  - snake_case for functions and variables
  - PascalCase for classes
  - UPPER_CASE for constants
- Maximum line length of 88 characters (Black default)
- Use absolute imports over relative imports

## Type Hints
- Use type hints for all function parameters and returns
- Import types from `typing` module
- Use `Optional[Type]` instead of `Type | None`
- Use `TypeVar` for generic types
- Define custom types in `types.py`
- Use `Protocol` for duck typing

## Flask Structure
- Use Flask factory pattern
- Organize routes using Blueprints
- Use Flask-SQLAlchemy for database
- Implement proper error handlers
- Use Flask-Login for authentication
- Structure views with proper separation of concerns

## Database
…