AgentLint Verified 100/100929 Python repos analyzed
Python CLAUDE.md & AGENTS.md Template
pytest, ruff, uv/venv isolation, and strict typing rules distilled from 929 Python repos.
# Python Project — Python Harness Python 3.12 service managed with `uv`, tested with `pytest`, formatted with `ruff`, and typechecked with `pyright`. ## Commands - Sync deps: `uv sync --dev` - Fast unit test: `uv run pytest tests/unit/test_module.py -x -q -m "not slow and not network"` - Full suite: `uv run pytest -q` - Lint & format: `uv run ruff check . && uv run ruff format --check .` - Typecheck: `uv run pyright` ## Rules - Don't invoke global `python` or `pip`. Instead prefix commands with `uv run` (or `.venv/bin/python`). Because system Python mismatches project dependencies. - Don't swallow exceptions with bare `except Exception: pass`. Instead catch specific errors and log structured context. Because silent fallbacks mask production data corruption. - Don't add tests that hit live network endpoints without `@pytest.mark.network`. Instead mock HTTP boundaries in `tests/unit/`. Because unmocked calls make CI flaky. - When modifying database models, read `docs/migrations.md` before generating Alembic scripts. ## Continuity & Safety - Keep `.env`, `.venv/`, and `CLAUDE.local.md` out of git. - Record architecture decisions and passing test evidence in `HANDOFF.md`.
Most Adopted Python Rules Across Real Open-Source Repos
Measured across 929 public Python repositories in the 4,533-repo harness study:
pytesttesting
Use pytest as the testing framework
45.9%426 repos
unit-teststesting
Write unit tests for all changes
40.9%380 repos
error-handlingpatterns
Proper error handling with context
30.4%282 repos
type-hintspatterns
Type hints on all function signatures
29.8%277 repos
rufftooling
Use ruff for linting and formatting
29.1%270 repos
dockertooling
Docker for containerization
28.6%266 repos
conventional-commitsworkflow
Use conventional commit messages
27.2%253 repos
uvtooling
Use uv for package management
24.5%228 repos
Essential Commands (Checks W1 & W7)
- install
- uv sync --dev
- fastTest
- uv run pytest tests/unit/test_target.py -x -q
- fullTest
- uv run pytest -q
- lint
- uv run ruff check . && uv run ruff format --check . && uv run pyright
- build
- uv build
Common Python Agent Pitfalls
- 01Agents invoke system
pythoninstead of.venv/bin/pythonoruv run, triggering false missing-module errors. - 02Broad
except Exception: passblocks swallow real bugs during agent self-repair loops. - 03Slow network or LLM integration tests lack pytest markers, causing agents to stall on every run.