agentleFS
garretoconnorgarretoconnor/agent-skills/skills/uv-python/SKILL.md

uv-python

Skill0 starsChanged 8 months agoMITView on GitHub

How to use uv for Python package management, virtual environments, running scripts, and managing project dependencies. Use this skill whenever working with Python in any capacity — installing packages, running .py files, creating virtual environments, managing project dependencies, or troubleshooting import errors and module-not-found issues. Trigger on ANY of: `pip install`, `python -m`, `python3`, `.py` files, `pyproject.toml`, `requirements.txt`, virtualenv/venv, ModuleNotFoundError, ImportError, or any mention of Python package management. If uv is available on the system, ALWAYS prefer it over pip, pip-tools, virtualenv, pyenv, or poetry. Even if the user doesn't mention uv, use it when doing Python work.

  • Pipes a download into a shell
  • Installs packages

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. Enjoyoer/loadout★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before using uv, verify it's installed:

    line 24
  2. Distinctive:

    If uv is not installed, you can install it with:

    line 30
  3. Very specific:

    When you request a Python version (via .python-version, requires-python in pyproject.toml, or --python flag), uv will automatically …

    line 166
  4. Very specific:

    If there's a pyproject.toml in the current or parent directory, uv run will try to install the project first.

    line 194
  5. Very specific:

    If a project has existing requirements.txt files:

    line 227

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

uv — Python Package & Project Manager

uv is an extremely fast Python package and project manager written in Rust. It replaces pip, pip-tools, pipx, poetry, pyenv, virtualenv, and more with a single tool. If uv is available, always prefer it over pip and other Python tooling.

How uv handles Python (the short version)

uv manages its own Python installations from prebuilt standalone distributions (from Astral's python-build-standalone project). It will automatically download and install the right Python version when needed — you don't need to worry about pyenv, system Python, which python3, or any of that. When you run uv run or uv sync, uv ensures the correct Python is available, the virtual environment exists, and dependencies are installed. Trust the tool.

Check if uv is available

Before using uv, verify it's installed:

which uv && uv --version

If uv is not installed, you can install it with:

curl -LsSf https://astral.sh/uv/install.sh | sh

Then ensure it's on PATH: source $HOME/.local/bin/env (or restart the shell).


Decision Tree: Which uv workflow do I need?

Pick the right approach based on context:

1. Quick one-off script (no project structure)

You have a single .py file and just need to run it, possibly with some dependencies.

Run with ad-hoc dependencies:

uv run --with requests --with pandas my_script.py

Better: use inline script metadata (PEP 723) so dependencies are self-documenting:

# /// script
# dependencies = [
#   "requests",
#   "pandas>=2.0",
# ]
# ///

import requests
import pandas as pd
# ...

Then just:

uv run my_script.py

uv creates an isolated temporary environment, installs dependencies, runs the script. No venv activation, no pip install, no cleanup.

Add dependencies to an existing script:

uv add --script my_script.py requests pandas

2. Project with pyproject.toml

You're in a directory with (or creating) a structured Python project.

Initialize a new project:

uv init my-project
cd my-project

This creates pyproject.toml, .python-version, main.py, and a .gitignore.

Add dependencies:

uv add requests pandas numpy
uv add --dev pytest ruff  # dev-only dependencies

This updates pyproject.toml, resolves versions, updates uv.lock, and installs into .venv.

Remove dependencies:

uv remove pandas

Run commands in the project environment:

uv run python main.py
uv run pytest
uv run python -c "import requests; print(requests.__version__)"

uv run automatically ensures the environment is synced before execution. You do NOT need to activate the venv.

Sync the environment (install everything from the lockfile):

uv sync

Update the lockfile (after manual edits to pyproject.toml):

uv lock

3. Low-level pip-style commands (legacy / escape hatch)

Sometimes you need direct control — e.g., installing into a specific venv without a pyproject.toml, or working with an existing requirements.txt. uv provides a pip-compatible interface for this.

Create a virtual environment:

uv venv                    # creates .venv with default Python
uv venv --python 3.11      # creates .venv with Python 3.11
uv venv my-env             # creates my-env/ instead of .venv/

Install packages:

uv pip install requests pandas
uv pip install -r requirements.txt
uv pip install -e .                  # editable install of current project

List / inspect:

uv pip list
uv pip show requests
uv pip freeze

Important: uv pip install installs into the active venv (or .venv if found). It will NOT install into the system Python by default. If you need system-level installs (e.g., in a container), pass --system.

4. Running CLI tools (replacing pipx)

Need to run a tool like ruff, black, pytest, or jupyterlab without polluting your project?

uvx ruff check .               # run in ephemeral environment
uvx black my_file.py
uv tool install ruff           # install persistently, adds to PATH

Managing Python Versions

uv python install 3.12          # install a specific version
uv python install 3.10 3.11     # install multiple
uv python list                   # see what's available/installed
uv python pin 3.11              # pin current directory to 3.11

When you request a Python version (via .python-version, requires-python in pyproject.toml, or --python flag), uv will automatically download it if not already present.


Common Pitfalls & Anti-Patterns

❌ Don't: pip install <package>

Do: uv pip install <package> or better, uv add <package> (in a project).

Raw pip install bypasses uv's resolver, may install into the wrong environment, and won't update your lockfile.

❌ Don't: python -m venv .venv && source .venv/bin/activate && pip install ...

Do: uv venv && uv pip install ... or just use uv init + uv add for projects.

uv handles venv creation, Python version selection, and package installation in one coherent flow.

❌ Don't: activate the venv to run things

Do: uv run <command>

uv run handles environment syncing and activation transparently. You rarely need source .venv/bin/activate.

❌ Don't: pip install --break-system-packages

Do: uv pip install --system if you truly need system-level installs (containers, CI).

❌ Don't: worry about which Python is on PATH

Do: Let uv manage it. Use --python 3.11 or .python-version files to request versions. uv resolves the right interpreter automatically.

⚠️ Watch out: uv run in a project directory

If there's a pyproject.toml in the current or parent directory, uv run will try to install the project first. For standalone scripts that don't belong to the project, use:

uv run --no-project script.py

Quick Reference

TaskCommand
Run a script with depsuv run --with pkg script.py
Run a script (inline deps)uv run script.py
Init new projectuv init project-name
Add dependencyuv add package-name
Add dev dependencyuv add --dev package-name
Remove dependencyuv remove package-name
Run in project envuv run python main.py
Sync environmentuv sync
Lock dependenciesuv lock
Create venvuv venv
pip install (low-level)uv pip install package
Install from requirementsuv pip install -r requirements.txt
Run a CLI tooluvx tool-name
Install a CLI tooluv tool install tool-name
Install Python versionuv python install 3.12
Pin Python versionuv python pin 3.11
View dep treeuv tree

Working with requirements.txt (Migration Path)

If a project has existing requirements.txt files:

# Create a project from existing requirements
uv init
uv add -r requirements.txt

# Or for low-level usage without a project
uv venv
uv pip install -r requirements.txt

To generate a locked requirements.txt from a project (e.g., for Docker):

uv export --format requirements-txt > requirements.txt

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.