Use uv exclusively for all Python package management, environment setup, and script execution. Trigger whenever the user installs/removes Python packages, runs Python scripts, manages dependencies, creates Python projects, or mentions python/python3/pip/pip3/poetry/conda/pip-tools/virtualenv. Also trigger when running any temporary/inline/quick-check/throwaway Python snippets (e.g. `python -c`).
Use uv exclusively. Never use pip, pip3, pip-tools, poetry, virtualenv or conda for dependency management. Never invoke python or python3 directly, including python -c.
| Scenario | Approach |
|---|---|
Working in a directory with pyproject.toml | Project — use uv add, uv run |
| Reusable script that needs specific packages | Standalone Script — use PEP 723 inline metadata |
| Quick throwaway code, no file needed | One-Off Code — pipe to uv run - |
pyproject.toml)uv inituv add <package>uv add "package[extra]"uv add --dev <package>uv remove <package>uv syncuv run <script>.pyuv run -m <module>Use PEP 723 inline metadata to declare dependencies inside the script:
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "requests",
# ]
# ///
uv add <package> --script <script>.pyuv remove <package> --script <script>.pyuv run <script>.pyUse instead of python -c "code":
echo 'print("hello")' | uv run -
For multi-line code, use a heredoc:
uv run - <<'EOF'
<script>
EOF
uv run --with <package> <script>.pyuvx <tool>uv tool install <tool>uv run --python 3.10 <script>.pyuv python install 3.12uv venvuv pip install -r requirements.txt