| name | uv-package-manager |
| description | Manage Python projects and dependencies using UV, the ultra-fast Rust-based package manager. Use when creating Python projects, managing dependencies, or running Python scripts. |
UV Package Manager Skill
When to Activate
Activate this skill when:
- Creating new Python projects
- Adding or removing dependencies
- Running Python scripts or tools
- Managing virtual environments
- Setting up Python version management
Why UV?
- 10-100x faster than pip (Rust implementation)
- Unified tool - replaces pip, pip-tools, poetry, pyenv, virtualenv
- Reliable - lock files for reproducible builds
- Modern - built for current Python workflows
Quick Commands
uv init
uv init --package my-lib
uv add requests
uv add --dev pytest
uv remove package-name
uv run script.py
uv run pytest
uv run python -m module
uv sync
uv sync --frozen
uv lock
uv python install 3.12
Creating Projects
uv init my-project
cd my-project
uv init --package my-library
uv init --python 3.11
Created Structure
my-project/
├── .python-version # Python version
├── pyproject.toml # Project config
├── .venv/ # Virtual environment (auto-created)
└── hello.py # Sample script
Adding Dependencies
uv add requests fastapi uvicorn
uv add "django>=4.2,<5.0"
uv add "requests==2.31.0"
uv add "fastapi[all]"
uv add --dev pytest black ruff mypy
uv add --git https://github.com/user/repo --branch develop
Running Scripts
uv run script.py
uv run script.py --input data.csv
uv run pytest tests/ -v
uv run black .
uv run ruff check .
uv run --with httpx fetch_data.py
uv run python
Virtual Environment
UV automatically manages virtual environments:
uv sync
uv add package
uv run script.py
uv venv
uv venv --python 3.11
source .venv/bin/activate
.venv\Scripts\activate
Lock Files
uv lock
uv sync
uv sync --frozen
uv lock --upgrade-package requests
Python Version Management
uv python list
uv python install 3.12
echo "3.12" > .python-version
Migration from pip
uv init my-project
cd my-project
uv add -r requirements.txt
uv add --dev -r requirements-dev.txt
Common pyproject.toml
[project]
name = "my-project"
version = "0.1.0"
requires-python = ">=3.11"
dependencies = [
"fastapi>=0.100.0",
"uvicorn>=0.20.0",
]
[project.optional-dependencies]
dev = [
"pytest>=7.0.0",
"black>=23.0.0",
"ruff>=0.1.0",
]
[tool.uv]
dev-dependencies = [
"pytest>=7.0.0",
]
Best Practices
DO ✅
- Commit
uv.lock and .python-version
- Use semantic versioning for dependencies
- Use
--dev for development tools
- Use
uv run instead of manual activation
- Use
--frozen in CI/CD
DON'T ❌
- Commit
.venv/ directory
- Use
* for version constraints
- Mix pip and uv in same project
- Skip lock file updates after changes
Troubleshooting
uv cache clean
uv --verbose add package
uv lock
uv sync
Related Resources
See AgentUsage/uv_usage.md for complete documentation including:
- Docker integration patterns
- Workspace support for monorepos
- CI/CD configuration
- Detailed migration guides