Python Project Free Claude Code CLAUDE.md template, copy & paste
A CLAUDE.md for a Python service: uv or pip commands, pytest, typing and linting rules, and what not to touch.
WHEN TO USE IT
When Claude keeps reaching for the wrong tool — pip instead of uv, unittest instead of pytest — in a Python codebase.
Formats change. If a field stops working, check it against Anthropic's documentation.
The single most useful line is the test command. Claude will run whatever it guesses otherwise.
# [Project name]
[One sentence: what this service does.]
## Commands
- Install: `uv sync`
- Run: `uv run python -m [package]`
- Test: `uv run pytest -q` — run the relevant tests after every change
- Lint and format: `uv run ruff check --fix . && uv run ruff format .`
- Types: `uv run mypy src`
## Layout
- `src/[package]/` — application code
- `tests/` — pytest; fixtures in `tests/conftest.py`
## Conventions
- Python 3.12, type hints on every public function
- pytest style: plain `assert`, fixtures over setup methods
- Use `pathlib`, not `os.path`
- Log with the module logger (`logging.getLogger(__name__)`), never print
## Do not
- Use pip directly — dependencies go through `uv add`
- Commit `.env` or anything in `data/`
- Change a public function's signature without updating its callers
@path imports another file into the memory. Paths are relative to the importing file; inside backticks or code blocks they are NOT imported.
## More
- Architecture: @docs/architecture.md
- Release process: @docs/releasing.md
MORE CLAUDE.MD
The authority
Anthropic's documentation for CLAUDE.md
This template is a starting point. Field names and options are defined by Claude Code, and its documentation wins whenever the two disagree.
https://code.claude.com/docs/en/memory