CLAUDE.md for Python
A complete, production-ready CLAUDE.md example for Python projects — token-optimized to 130 tokens, ready to drop into your repo. Plus a free generator that tailors it to your exact stack in 3 questions.
What is CLAUDE.md?
CLAUDE.md is Claude Code's persistent memory file — loaded at the start of every session. It captures what Claude would get wrong by reading the code alone: the non-obvious gotchas, the current focus, and the hard constraints not documented anywhere else. Every line must pass the test: "would removing this cause a mistake?" If not, it shouldn't be there.
CLAUDE.md example for Python
Here is a complete CLAUDE.md for a Python project, optimized to 130tokens using MDPilot's 5-pass optimizer:
# Project
Python package for data analysis
# Current focus
Implementing new feature for data visualization
# Gotchas
* Use `python -m venv .venv` for virtual environment setup
* Requirements are specified in `pyproject.toml` and `requirements.txt`
* Type hints are used with mypy for static type checking
* Use `pip install -e .` for editable install
* Formatting is done with black and ruff, following PEP 8 conventions
* Testing is done with pytest
# Hard constraints
* Python version: 3.9+
* Package manager: pipWhy Python projects need CLAUDE.md
Python projects often involve managing various dependencies, formatting, and testing tools, which can be error-prone if not properly documented. The CLAUDE.md file helps mitigate this by providing a centralized source of information for developers. For instance, specifying the use of `python -m venv .venv` for virtual environment setup and `pip install -e .` for editable install ensures that developers use the correct commands. Additionally, noting the use of type hints with mypy and formatting with black and ruff helps maintain consistency in the codebase.
Generate your own CLAUDE.md for Python
Answer 3 questions about your project and MDPilot generates a CLAUDE.md grounded in your exact stack — real commands, real paths, no hallucinated scripts.
Generate CLAUDE.md free →Frequently asked questions
What is CLAUDE.md?
A documentation file that provides essential information about a project, including setup, dependencies, and testing.
How does CLAUDE.md interact with Python tooling?
CLAUDE.md provides information on the use of various Python tools, such as pip, pytest, mypy, black, and ruff, to ensure consistency and accuracy in the project.
What naming conventions should I follow in my Python project?
Follow PEP 8 conventions, which are also enforced by tools like black and ruff, to maintain consistency in the codebase.
Where should I place the CLAUDE.md file in my Python project?
The CLAUDE.md file should be placed in the root directory of the project, allowing it to be easily accessible and readable.