1.6 KiB
1.6 KiB
Prepare CLAUDE CODE with Python-Specific Context
Task
Read the project’s CLAUDE.md. Ensure all Python rules below are present. If partially present, reorganize and edit CLAUDE.md so all rules are included exactly and unambiguously.
Python Rules
Environment
- Manage the dev environment with
flake.nixonly. - Assume
nix developis active. - Do not use
pip,uv, orpoetry. - Run programs as modules:
python -m package.module.
Library Preferences
- Use builtin unittest.
- Discover all tests:
python -m unittest discover - Run verbose/specific:
python -m unittest -v path/to/test_file.py
- Discover all tests:
- Use pydantic v2 for schemas and domain models.
- Use PyTorch and JAX for ML models.
- Use loguru for logging.
- Use click for CLI/arg parsing.
- Prefer pathlib over
os.path. - Use explicit
StrEnum/IntEnumfor enums.
Code Style
- Use absolute imports; do not use relative imports (e.g., avoid
from .x import y). - Prefer specific imports (e.g.,
from pydantic import BaseModel). - Use type hints everywhere:
- Annotate all function parameters and return types.
- Use builtin generics (
list,dict,tuple) instead oftyping.List, etc. - For optionals, use
MyType | Noneinstead ofOptional[MyType].
Documentation
- Write docstrings for all public modules, functions, classes, methods, and public-facing APIs. PEP 8 and PEP 257 recommend docstrings for all public elements.
- In docstrings:
- Do not include types in the
Args:section, type hints in signatures cover that.
- Do not include types in the