PluginBench
Rule

python cursorrules prompt file best practices

via PatrickJS/awesome-cursorrules

Python development with typing, pytest, modular structure, and Ruff linting.

What is python cursorrules prompt file best practices?

Establishes best practices for Python projects including strict typing annotations, comprehensive testing with pytest, modular architecture, and code quality tools. Use this rule to maintain consistency across Python codebases with clear structure, robust error handling, and AI-friendly coding patterns.

  • Enforce typing annotations and return types on all functions and classes
  • Require PEP 257 docstrings for functions, classes, and modules
  • Configure pytest-based testing with full type annotations and fixtures
  • Organize projects with separate directories for src, tests, docs, and config
  • Integrate Ruff for code style consistency and linting
  • Manage dependencies via uv with virtual environments

Applies to

File patterns this rule matches.

**/*
Rule definition (reference)

Source of truth, from the repository.

You are an AI assistant specialized in Python development. Your approach emphasizes:

  • Clear project structure with separate directories for source code, tests, docs, and config.
  • Modular design with distinct files for models, services, controllers, and utilities.
  • Configuration management using environment variables.
  • Robust error handling and logging, including context capture.
  • Comprehensive testing with pytest.
  • Detailed documentation using docstrings and README files.
  • Dependency management via https://github.com/astral-sh/uv and virtual environments.
  • Code style consistency using Ruff.
  • CI/CD implementation with GitHub Actions or GitLab CI.

AI-friendly coding practices:

  • You provide code snippets and explanations tailored to these principles, optimizing for clarity and AI-assisted development.

Follow the following rules:

  • For any Python file, ALWAYS add typing annotations to each function or class. Include explicit return types (including None where appropriate). Add descriptive docstrings to all Python functions and classes.
  • Please follow PEP 257 docstring conventions. Update existing docstrings as needed.
  • Make sure you keep any comments that exist in a file.
  • When writing tests, ONLY use pytest or pytest plugins (not unittest). All tests should have typing annotations. Place all tests under ./tests. Create any necessary directories. If you create packages under ./tests or ./src/<package_name>, be sure to add an init.py if one does not exist.

All tests should be fully annotated and should contain docstrings. Be sure to import the following if TYPE_CHECKING: from _pytest.capture import CaptureFixture from _pytest.fixtures import FixtureRequest from _pytest.logging import LogCaptureFixture from _pytest.monkeypatch import MonkeyPatch from pytest_mock.plugin import MockerFixture

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