This skill helps you manage Python projects with the uv package manager, handling dependencies, virtual environments, and scripts for reliable, repeatable
npx playbooks add skill untitled-data-company/data-skills --skill uv
Prefer uv over pip/poetry for Python dependency and project management. Use the workflow below and choose the right mode (project, script, or tool).
User needs to...
│
├─ Repo uses poetry / pipenv / conda (poetry.lock, Pipfile, environment.yml)
│ → Ask: "This repo uses [poetry/pipenv/conda]. Do you want to switch to uv?"
│ → If yes: prefer the migrate-to-uv tool (uvx migrate-to-uv in project root) to convert metadata and lockfile; then uv sync. Remove legacy files only after user confirms.
│ → If no: do not use uv for project management; use the existing tool or uv pip only if appropriate.
│
├─ Repo has requirements.txt (no pyproject.toml)
│ → Ask: "This repo uses requirements.txt. Do you want to convert to uv (pyproject.toml + uv.lock)?"
│ → If yes: guide conversion (uv init, uv add from requirements, then uv sync)
│ → If no: use Pip-Compatible workflow (uv pip)
│
├─ Manage a project (pyproject.toml, lockfile, team repo)
│ → Use PROJECT workflow (uv init, uv add, uv sync, uv run)
│
├─ Run a single script with dependencies
│ → Use SCRIPT workflow (uv add --script, uv run <script>)
│
├─ Run a one-off CLI tool (no project)
│ → Use uvx: uvx <package> [args] or uv tool install <package>
│
└─ User declined conversion; existing pip/requirements workflow
→ Use uv pip (uv venv, uv pip sync, uv pip compile)
Use for apps, libraries, or any repo with pyproject.toml.
uv init [project-name]
cd [project-name]
uv add <package> [package2...]
uv sync
uv run python main.py
# or: uv run <any command>
uv sync # install from lockfile (or resolve and lock)
uv add <package> # add dependency, update lockfile and env
uv remove <package> # remove dependency
uv run <command> # run in project venv (creates .venv if needed)
uv lock # refresh lockfile only
uv python pin 3.11 # writes .python-version
uv python install 3.11 # ensure that version is available
Rules:
uv add for project dependencies; avoid editing pyproject.toml by hand for deps when uv can do it.uv sync (or rely on uv add/uv remove which update the env).uv run so the correct venv and env are used; do not assume pip install or manual activate..venv is in .gitignore (uv init usually adds it; add it if missing).uv.lock as a mandatory source-controlled artifact: commit it so all environments and CI use the same dependency versions; the lockfile is universal (one file for Windows, macOS, Linux).For a single Python file that needs packages (no full project).
uv add --script to add deps to the file):# /// script
# requires-python = ">=3.10"
# dependencies = ["requests"]
# ///
import requests
print(requests.get("https://example.com"))
uv add --script example.py requests
uv run example.py
For executable scripts that run without typing uv run, use a shebang (PEP 723):
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.10"
# dependencies = ["requests"]
# ///
Rules:
uv add --script <file> to declare dependencies for that script.uv run <script>.py to run it; do not tell the user to pip install first.#!/usr/bin/env -S uv run --script.Run without installing globally:
uvx <package> [args]
# e.g. uvx ruff check .
# e.g. uvx pycowsay "hello"
Install the tool for repeated use:
uv tool install <package>
# e.g. uv tool install ruff
Rules:
uvx for one-off runs; use uv tool install when the user will call the tool often.When the repo has requirements.txt (and no pyproject.toml):
uv init, then uv add -r requirements.txt (or, if you have requirements.in and locked requirements.txt, uv add -r requirements.in -c requirements.txt to preserve versions), then uv sync. Optionally remove or keep requirements.txt per user preference.Do not convert to uv without asking when the repo currently uses only requirements.txt.
For repos that still use requirements.txt or pip (and user did not want conversion):
uv venv # create .venv
uv pip sync requirements.txt # install from locked requirements
uv pip compile requirements.in -o requirements.txt # compile/lock
Use uv pip instead of pip for the same commands when you want speed and better resolution.
When the user asks about uv in CI (e.g. GitHub Actions) or uv in Docker, advise using the patterns below and point to [references/docker-and-ci.md](references/docker-and-ci.md) for full detail.
CI (e.g. GitHub Actions):
astral-sh/setup-uv action; use cache keyed by uv.lock and pyproject.toml.uv sync --locked so the job fails if the lockfile is out of sync (no silent deploy of untested deps).uv cache prune --ci at end of job to keep cache lean.Docker:
ghcr.io/astral-sh/uv, copy only uv.lock and pyproject.toml first, run uv sync (or equivalent), then copy .venv and app code into a slim runtime image (no uv/Rust in final image).UV_COMPILE_BYTECODE=1 and UV_LINK_MODE=copy in the build stage; use --no-editable when syncing so the final image doesn’t depend on source.For step-by-step Dockerfiles and CI workflow examples, see [references/docker-and-ci.md](references/docker-and-ci.md).
After uv creates or uses a project .venv, automatically try to configure the IDE to use that interpreter so run/debug and IntelliSense use the same environment.
.vscode/settings.jsonpython.defaultInterpreterPath pointing at the project’s .venv:"${workspaceFolder}/.venv/bin/python""${workspaceFolder}/.venv/Scripts/python.exe".vscode/settings.json exists, read it, add or update only python.defaultInterpreterPath, then write back. If it doesn’t exist, create .vscode/ and the file with this setting. Preserve all other keys.uv init, uv sync, or conversion from requirements.txt that creates/updates .venv.Rules:
.vscode/settings.json), not user settings, so the choice is per-project and can be committed..venv is the default.uv init (or uv init <name>), then uv add for initial deps, then uv sync. Suggest uv run for run/test commands.uv add <package>. For dev/optional: uv add --dev <package>.uv run <command> in a project; uv run script.py for scripts; uvx <tool> for one-off tools.uv run so the agent and user don’t depend on source .venv/bin/activate.uv.lock; treat it as mandatory for parity. After pull or after editing deps, run uv sync. In CI, use uv sync --locked so the job fails if the lockfile is out of sync with pyproject.toml.pyproject.toml exists and there is no poetry/pipenv/conda (no poetry.lock, Pipfile, environment.yml), assume uv is allowed and suggest uv commands. If the user said "use uv", always prefer uv over pip/poetry. If poetry/pipenv/conda is present, ask before switching to uv (see Mode Decision)..venv, try to set the workspace Python interpreter by adding or updating python.defaultInterpreterPath in .vscode/settings.json (see IDE Setup above).| Task | Command |
|-------------------|----------------------------|
| New project | uv init [name] |
| Add dependency | uv add <pkg> |
| Add dev dependency| uv add --dev <pkg> |
| Remove dependency | uv remove <pkg> |
| Install from lock | uv sync |
| Update lockfile | uv lock |
| Run in project | uv run <cmd> |
| Run script | uv run script.py |
| Run CLI tool once | uvx <pkg> [args] |
| Install tool | uv tool install <pkg> |
| Create venv | uv venv |
| Pin Python | uv python pin 3.11 |
| Install Python | uv python install 3.11 |
Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.