1---
2name: python-conventions
3description: Apply Python project conventions — uv for deps and builds, Ruff strict (E, F, I, UP, B, SIM, PTH, PIE, RUF, T201, PLC0415), mypy strict, pytest with pytest-cov and pytest-asyncio, vulture for dead code, pip-audit for dependency security, and a gitignored test.py for scratch experiments. Use when starting a Python project, writing or reviewing Python code, configuring Python tooling, or evaluating compliance with these defaults. Co-activates with running-tdd-cycles, reviewing-changes, and engineering-philosophy.
4allowed-tools: Read, Edit, Write, Grep, Glob, Bash(uv *), Bash(uv run ruff *), Bash(uv run mypy *), Bash(uv run pytest *), Bash(uv run pip-audit *), Bash(uv run vulture *), Bash(uv run python *)
5globs: "**/*.py"
6paths: "**/*.py"
7metadata:
8 source: https://skillmd.com/skills/aibot88/python-conventions
9---
10
11## Default Stack
12
13If the repo doesn't define its own tooling, use:
14
15- **UV** — dependency management, builds, running scripts
16- **GitHub Actions** — CI/CD
17- **Ruff** — linting and formatting, with these rule sets:
18 - `E` (pycodestyle errors), `F` (pyflakes), `I` (isort), `UP` (pyupgrade)
19 - `B` (flake8-bugbear), `SIM` (flake8-simplify), `PTH` (pathlib)
20 - `PIE` (flake8-pie), `RUF` (ruff-specific), `T201` (no print)
21 - `PLC0415` (import-outside-toplevel)
22- **mypy** — strict mode (`strict = true`, `warn_return_any = true`, `warn_unused_configs = true`)
23- **pytest** — testing (`pytest-cov`, `pytest-asyncio`)
24- **vulture** — dead code detection
25- **pip-audit** — dependency security audit
26
27## Scratch Testing
28
29**ALWAYS use `test.py`** in project root for:
30- Ad-hoc testing, API calls, data exploration
31- Any Python code that isn't a formal test or production code
32- **NEVER use inline Python heredocs via Bash** (`uv run python3 << 'EOF'`)
33
34Write code to `test.py`, then run with `uv run python test.py`. Comment out previous code — keeps history. Gitignored — never commit.