| name | uv |
| description | Use this skill when working with Python projects, packages, scripts, environments, or dependencies using uv. Activates on mentions of uv, uv add, uv sync, uv run, uv lock, uv init, uv build, uv publish, uv export, uv python, uvx, uv tool, uv pip, uv venv, uv workspace, uv audit, uv version, pyproject.toml dependencies, Python package management, Python project setup, dependency lockfile, or virtual environments. |
uv: Python Package & Project Manager
uv (v0.11.11, May 2026) replaces pip, pip-tools, pipx, pyenv, virtualenv, and poetry. Written in Rust, 10-100x faster than alternatives. It is stable production software; minor versions can contain breaking changes, while patch releases are intended to be non-breaking.
Workflow Decision Tree
What are you doing?
├─ Running a standalone script? ──────────────────── Scripts workflow
│ (single .py file, no project context needed)
├─ Working in a project with pyproject.toml? ─────── Projects workflow
│ (adding deps, running commands, building)
├─ Running a CLI tool (ruff, ty, pytest)? ────────── Tools workflow
│ (one-off execution, not project-scoped)
├─ Managing Python versions? ─────────────────────── Python workflow
│ (installing, pinning, upgrading interpreters)
├─ Legacy requirements.txt workflow? ─────────────── Pip interface
│ (no pyproject.toml, existing req files)
└─ Building/publishing a package? ────────────────── Build/Publish workflow
(sdist, wheel, PyPI upload)
Critical rule: If pyproject.toml exists, use project commands (uv add, uv sync, uv run). Never uv pip install in a project, it bypasses the lockfile.
Projects
Initialization
uv init
uv init --lib
uv init --package
uv init --build-backend uv_build
uv init --build-backend maturin
uv init --python 3.13
uv init --bare
Dependency Management
uv add httpx
uv add httpx --dev
uv add httpx --group lint
uv add httpx --optional network
uv add -r requirements.txt
uv remove httpx
uv add 'httpx>=0.27'
uv add 'httpx~=0.27.0'
Dependency Groups (PEP 735)
[dependency-groups]
dev = ["pytest>=8", "ruff"]
lint = ["ruff"]
test = ["pytest", {include-group = "lint"}]
[tool.uv]
default-groups = ["dev", "lint"]
Sync & Run
uv sync
uv sync --locked
uv sync --frozen
uv sync --no-dev
uv sync --all-extras
uv sync --all-groups
uv sync --group lint
uv sync --no-install-project
uv sync --inexact
uv run pytest
uv run --with hypothesis pytest
uv run -p 3.12 pytest
Locking
uv lock
uv lock --upgrade
uv lock --upgrade-package httpx
uv lock --check
uv lock --resolution lowest
Export
uv export --format requirements-txt
uv export --format pylock-toml
Scripts (PEP 723)
Single-file scripts with inline dependency metadata. Scripts with metadata run in complete isolation, project dependencies are ignored even inside a project directory.
import httpx
uv run script.py
uv add --script script.py 'click'
uv lock --script script.py
uv init --script example.py
echo 'print("hi")' | uv run -
Tools
uvx ruff check .
uvx ruff@0.15.12 check .
uvx --from 'httpie' http
uvx --python 3.12 ruff
uv tool install ruff
uv tool upgrade --all
uv tool list --outdated
Key distinction: uvx creates isolated environments, tools are CLI-only, not importable. For tools needing project context (pytest, mypy), use uv run inside a project.
Python Management
uv python install 3.13
uv python install 3.13t
uv python install pypy
uv python upgrade 3.13
uv python pin 3.13
uv python list --only-installed
| Preference Setting | Behavior |
|---|
managed (default) | Prefer uv-installed Python |
only-managed | Never use system Python |
system | Prefer system Python |
only-system | Never use managed Python |
Workspaces
[tool.uv.workspace]
members = ["packages/*"]
exclude = ["packages/experimental"]
[tool.uv.sources]
my-lib = { workspace = true }
Key behaviors:
- Single lockfile across all members
- Single
requires-python: intersection of all members
- Workspace members are always editable
- Root
tool.uv.sources apply to all members unless overridden
- Config in
uv.toml is read only from workspace root, member-level config is ignored
uv workspace dir
uv workspace list
uv run --package my-lib pytest
uv build --package my-lib
Virtual workspaces (no root package):
[tool.uv]
package = false
[tool.uv.workspace]
members = ["packages/*"]
Publishing
uv version
uv version --bump minor
uv version --bump patch --dry-run
uv build
uv build --list
uv publish
uv publish --token pypi-xxx
uv publish --index testpypi
uv publish --check-url https://pypi.org/simple/
Trusted publishing (GitHub Actions, no credentials):
permissions:
id-token: write
steps:
- run: uv build && uv publish
Preview Features (0.10+)
Enable with --preview or UV_PREVIEW=1, or selectively with --preview-features:
| Feature | Flag | Description |
|---|
uv audit | --preview | Security vulnerability scanning (OSV database) |
uv format | format | Code formatting via Ruff |
pylock | pylock | Install from pylock.toml (PEP 751) |
native-auth | native-auth | System keychain credentials |
uv audit --preview
Configuration Quick Reference
Precedence: CLI flags > env vars > project uv.toml > project pyproject.toml [tool.uv] > user ~/.config/uv/uv.toml > system /etc/uv/uv.toml
In a workspace, config search starts at workspace root. uv.toml takes precedence over pyproject.toml in the same directory.
| Setting | Default | Purpose |
|---|
required-version | — | Enforce uv version (PEP 440) |
add-bounds | "lower" | Default bounds for uv add |
compile-bytecode | false | Compile .pyc on install |
fork-strategy | "requires-python" | Resolution fork behavior |
exclude-newer | — | Date/duration cutoff for reproducibility |
environments | [] | Limit lockfile platforms |
torch-backend | — | PyTorch backend (cpu/cu126/auto) |
default-groups | ["dev"] | Groups installed by default |
.env file support: uv run automatically loads .env files. Control with --env-file or UV_NO_ENV_FILE=1.
For full configuration reference, see references/configuration.md.
For Docker and CI/CD patterns, see references/docker-ci.md.
For dependency resolution deep dive, see references/resolution.md.
Non-Obvious Gotchas
| Gotcha | Explanation |
|---|
uv pip install in a project | Bypasses lockfile and pyproject.toml. Use uv add instead |
| Scripts with metadata ignore project | Even inside a project dir, PEP 723 scripts run in isolation |
--locked vs --frozen | --locked errors on stale lockfile; --frozen silently uses whatever's there |
uv venv needs --clear (0.10+) | No longer auto-removes existing venvs |
tool.uv.sources stripped on publish | Sources are development-only; published packages use project.dependencies |
| Workspace config inheritance | Member-level uv.toml is ignored; only workspace root config applies |
link-mode in Docker | Must use copy with cache mounts (hardlinks fail across filesystem boundaries) |
exclude-newer accepts durations | "30 days", "1 week", "PT24H", not just RFC 3339 timestamps |
uv run uses inexact sync | Won't remove extraneous packages by default; use --exact to enforce |
Anti-Patterns
| Anti-Pattern | Fix |
|---|
pip install / python -m pip in uv project | uv add <package> for deps, uv run for commands |
python script.py | uv run script.py (ensures correct environment) |
python -m venv .venv && source .venv/bin/activate | uv run <command> (auto-manages venv) |
Manual requirements.txt for new projects | uv init + uv add + uv.lock |
uv pip compile for project deps | uv lock (universal resolution) |
uv tool install pytest | uv add --dev pytest + uv run pytest (project-scoped) |
uvx for project-scoped tools | uv run <tool> (picks up project context) |
What This Skill is NOT
- Not a replacement for reading
uv --help for flag discovery
- Not for Poetry/PDM projects (those have their own lock formats)
- Not for building C/Rust extensions (see uv-build skill for backend limitations)
- Not for ruff/ty configuration (see dedicated ruff and ty skills)