Python dependencies
First identify the project's existing dependency workflow from its committed files and documented commands. Preserve that workflow for existing projects. Prefer uv for new projects, and use it for an existing project only when the user requests migration or the scoped task genuinely requires it.
New project
uv init
uv add <package>Commit pyproject.toml and uv.lock. Add .venv/ to .gitignore if missing.
Existing uv project
After editing pyproject.toml or changing dependencies:
uv lock
uv syncOn clone or a new machine, use the project's documented setup, normally:
uv syncExisting non-uv project
Keep its current requirements, lockfile, package manager, and setup commands. Do not add pyproject.toml, create uv.lock, or remove requirements.txt automatically. If the user requests migration, or the scoped task cannot be completed without it, agree the migration boundary first and preserve the existing dependency set while moving it to uv.
For a requested or necessary requirements.txt migration:
uv init
uv add -r requirements.txt
uv lock
uv syncRemove or archive requirements.txt only after the user-approved migration is committed and the new lockfile reproduces the required environment.
Rules
- Prefer
uv add <package>over manualpyproject.tomledits in uv-managed projects when possible. - Run the existing project's required lock and sync/install checks after dependency changes.
- Never commit
.venv/. - Do not replace a working existing dependency workflow with uv without an explicit request or a concrete scoped necessity.