- Setup: Run
uv sync --devbefore major work sessions - Activate: Ensure
.venvis active; runuv venvif missing - Code: Use
python3oruv run python; always add type hints and tests
| Component | Tool |
|---|---|
| Environment & Deps | uv |
| Data Validation | Pydantic |
| CLI Framework | Typer |
| Testing | pytest |
| Linting & Formatting | ruff |
| Type Checking | mypy |
| Security Audit | pip-audit |
| Markdown Lint | pymarkdownlnt |
| Git Hooks | prek |
python_package_template/
config.py (Pydantic models)
hello.py (Business logic)
cli.py (Typer CLI)
tests/ (Pytest suite)
pyproject.toml (Dependencies & tool config)
- Type Hints: Required on ALL function signatures
and class members. Enforce strictly with mypy.
Avoid using
# type: ignorecomments to suppress mypy errors; fix the underlying type issues instead. - Docstrings: Google-style format for all public APIs.
- Logging: Use
loggingmodule only; neverprint(). - Relative Paths: Never use absolute paths in code.
- Adding/Removing Dependencies: Use
uv add/uv removecommands. - Editing pyproject.toml: Avoid manual edits during
development. Only update
pyproject.tomlas the final change after all work is tested. - Before Major Work: Always run
uv sync --devfirst.
- Test Coverage: Every code change requires
corresponding tests in
tests/. - Validation: You do NOT run validation tools.
Write code with quality standards in mind (type
hints, docstrings, tests). The user will run
pytest,ruff check,ruff format, andmypymanually for final validation.
- No Interactive Prompts: Mock or bypass any interactive commands.
- Staging & Commit Protocol: When you have completed
work and updated files, stage the changes with
git addand then display a suggested commit message for the user's review. DO NOT actually commit. - Code Review Mode: Analyze only; record findings
in
./REVIEW.mdwithout making modifications.
- Keep Instructions Current: Update "Tech Stack,"
"Project Structure," and "Workflow Commands" if
pyproject.toml, structure, or core logic changes. - YAML Files: Use
.yamlextension for all YAML files (e.g.,.github/workflows/ci.yamlinstead of.yml).
uv sync --dev # Install/sync all dependencies
uv run hello-world hello # Test CLI