description:Use before running any Python, uv, pytest, mypy, ruff, pre-commit or make command. Keeps the agent's virtual environment out of the workspace .venv.
---
# Python Environment
## Why
The workspace may be shared with the developer's machine (e.g. a mounted
directory or a container). The workspace `.venv` then belongs to the developer
and is bound to an interpreter on their machine, which does not exist for the
agent. `uv` treats such a `.venv` as broken: it deletes and recreates it for
the agent's interpreter, which breaks the developer's environment, and the
developer's next `uv` call breaks the agent's in turn (e.g. dev tools such as
pytest or mypy go missing).
## Rules
- **Never use, create, modify or delete the workspace `.venv`.**
- Use a virtual environment outside the workspace, selected by
`UV_PROJECT_ENVIRONMENT`. In the AI development sandbox (`ai/`) it is
already set for every shell and tool call; check with
`echo "$UV_PROJECT_ENVIRONMENT"`.
- If it is not set, set it in **every** shell command that runs `uv` or