AgentSkillsCN

bx-uv

适用于使用 uv 作为包管理器、虚拟环境管理器、Python 版本管理器,或替代 pip 的 Python 项目编写、配置、调试或部署时使用。涵盖项目搭建、依赖管理、锁文件、脚本、工具、构建、发布、Docker、CI/CD、身份验证、缓存,以及从 pip/pip-tools 的迁移。本部分覆盖了 uv 2026-02-12 的 0.10.2 版本。

SKILL.md
--- frontmatter
name: bx-uv
description: >
  Use when writing, configuring, debugging, or deploying Python projects that use
  uv as the package manager, virtual environment manager, Python version manager,
  or pip replacement. Covers project setup, dependency management, lockfiles,
  scripts, tools, building, publishing, Docker, CI/CD, authentication, caching,
  and migration from pip/pip-tools. This covers Version 0.10.2 of uv 2026-02-12

uv - Python Package & Project Manager

All documentation files are flat, numbered markdown files. Use the Read tool to load referenced files identified as relevant for full details.


Command-to-Document Quick Reference

CommandWhat it doesPrimary docAlso see
uv initCreate a new project02-projects.md
uv add / uv removeAdd/remove dependencies04-dependencies.md05-resolution.md
uv syncSync environment to lockfile02-projects.md04-dependencies.md
uv lockUpdate the lockfile04-dependencies.md05-resolution.md
uv runRun a command in the project env02-projects.md07-tools-and-scripts.md
uv buildBuild sdist/wheel08-building-and-publishing.md
uv publishPublish to PyPI08-building-and-publishing.md11-authentication.md
uv exportExport lockfile (requirements.txt, pylock.toml, CycloneDX)04-dependencies.md09-pip-interface.md
uv python installInstall Python versions06-python-versions.md
uv python listList available/installed Pythons06-python-versions.md
uv python pinPin Python version for project06-python-versions.md10-configuration.md
uv python findFind a Python interpreter06-python-versions.md
uv tool run / uvxRun a tool in isolation07-tools-and-scripts.md
uv tool installInstall a tool globally07-tools-and-scripts.md
uv tool listList installed tools07-tools-and-scripts.md
uv venvCreate a virtual environment09-pip-interface.md
uv pip installInstall packages (pip compat)09-pip-interface.md
uv pip compileLock requirements (pip compat)09-pip-interface.md05-resolution.md
uv pip syncSync env to requirements.txt09-pip-interface.md
uv pip uninstallRemove packages (pip compat)09-pip-interface.md
uv pip freezeOutput installed packages09-pip-interface.md
uv pip listList installed packages09-pip-interface.md
uv pip showShow package details09-pip-interface.md
uv pip treeShow dependency tree09-pip-interface.md
uv pip checkVerify env consistency09-pip-interface.md
uv cache cleanClear cache10-configuration.md
uv cache pruneRemove unused cache entries10-configuration.md
uv versionView/bump project version02-projects.md08-building-and-publishing.md
uv treeShow project dependency tree02-projects.md
uv auth login / uv auth logoutManage index credentials11-authentication.md
uv auth tokenPrint stored auth token11-authentication.md
uv python uninstallRemove managed Python versions06-python-versions.md
uv python upgradeUpgrade Python patch version06-python-versions.md
uv tool upgradeUpgrade installed tools07-tools-and-scripts.md
uv tool uninstallRemove an installed tool07-tools-and-scripts.md
uv tool update-shellUpdate shell PATH for tools07-tools-and-scripts.md
uv cache dir / uv tool dir / uv python dirShow storage directories01-getting-started.md10-configuration.md
uv self updateUpdate uv itself01-getting-started.md
uv self versionShow uv's own version01-getting-started.md

Document Index

#FileContents
0101-getting-started.mdFeature overview, installation methods (standalone, pip, pipx, Homebrew, Conda, Docker, etc.), shell completion, self-update, uninstallation, installer env vars (UV_INSTALL_DIR, UV_NO_MODIFY_PATH), first-steps tutorial, getting help
0202-projects.mdProject creation (uv init), templates (--app, --lib, --package), project layout (flat vs src), running commands (uv run, --with, --no-project), syncing environments (uv sync, --frozen, --locked, --group, --only-group, --inexact), uv version (view/bump), uv tree
0303-project-config.md[project] table (name, version, requires-python, scripts, entry-points, gui-scripts), [tool.uv] settings (dev-dependencies, managed, package, python-preference, default-groups, environments), build systems, project packaging
0404-dependencies.mduv add/uv remove, dependency groups (--group dev), optional deps (--optional), platform-specific deps, source deps (git, path, URL, editable, workspace), uv lock, constraints ([tool.uv.constraint-dependencies]), uv export to requirements.txt/pylock.toml/CycloneDX (--no-hashes, --group, --all-groups, --format)
0505-resolution.mdResolution strategies (--resolution lowest/lowest-direct/highest), pre-release handling (--prerelease), dependency overrides ([tool.uv.override-dependencies]), constraints, --exclude-newer / UV_EXCLUDE_NEWER, platform-specific resolution, reproducibility, forking resolver
0606-python-versions.mduv python install/list/find/pin, version request syntax, discovery order, .python-version/.python-versions files, python-downloads setting, UV_PYTHON, UV_PYTHON_PREFERENCE, requires-python, PyPy support
0707-tools-and-scripts.mdTools: uv tool run/uvx, --from, --with, version requests, uv tool install/list/upgrade/uninstall/update-shell/dir, tool directories and PATH. Scripts: uv run script.py, PEP 723 inline metadata (# /// script), uv init --script, uv add --script, shebangs
0808-building-and-publishing.mduv build (sdists, wheels, --sdist, --wheel, --out-dir, --package), uv's build backend (uv_build), [build-system] config, [tool.uv.build-backend] settings, uv publish, trusted publishers (PyPI/GitHub OIDC), token auth, --publish-url
0909-pip-interface.mduv venv (creating envs, --python, --system), uv pip install/uninstall (PyPI, git, URLs, --system, --target, --prefix, editable), uv pip compile/sync (pip-tools workflow), uv pip show/list/tree/check/freeze, dependency formats (requirements.txt, pyproject.toml, setup.py), pip compatibility differences
1010-configuration.mdConfig files (pyproject.toml [tool.uv], uv.toml, .python-version), precedence (CLI > env > project > user), package indexes (--index, --default-index, [[tool.uv.index]], --index-strategy, per-package pinning), cache (uv cache clean/prune, UV_CACHE_DIR, --no-cache), preview features (--preview, UV_PREVIEW), storage locations (UV_CACHE_DIR, UV_TOOL_DIR, UV_PYTHON_INSTALL_DIR)
1111-authentication.mduv auth login/logout/token, HTTP auth (credentials in URLs, .netrc, keyring --keyring-provider, UV_INDEX_<NAME>_USERNAME/PASSWORD), Git auth (SSH, credential helpers, GitHub/GitLab tokens), insecure hosts (--allow-insecure-host), TLS/SSL (--cert, SSL_CERT_FILE, SSL_CLIENT_CERT), third-party indexes (Google Artifact Registry, AWS CodeArtifact, Azure Artifacts, Hugging Face, JFrog Artifactory)
1212-workspaces.mdMonorepo/multi-package projects: [tool.uv.workspace] with members/exclude, workspace root, path dependencies, shared lockfile, --package flag
1313-docker.mdDocker integration: multi-stage builds, installing uv (ghcr.io image, pip, copy from stage), UV_COMPILE_BYTECODE, UV_LINK_MODE, layer caching strategies, non-root users, best practices
1414-ci-cd.mdGitHub Actions: setup-uv action, caching, Python version matrix. GitLab CI/CD: configuration examples, caching, Docker pipelines
1515-integrations.mdFastAPI, Jupyter, Marimo, pre-commit, PyTorch/CUDA indexes (--torch-backend), AWS Lambda (packaging, Docker, layers), alternative indexes ([[tool.uv.index]]), dependency bots (Renovate, Dependabot), Coiled (Dask)
1616-migration.mdMigrating from pip + requirements.txt to uv projects: converting requirements, creating pyproject.toml, handling constraints files, replacing pip-tools workflows
1717-troubleshooting.mdBuild failures (missing system libs, C compiler, --no-build-isolation), reproducible examples for bug reports, supported platforms matrix (Linux, macOS, Windows, musl/glibc, aarch64, x86_64, etc.)

Cross-Reference by Scenario

ScenarioRead these docs
"Set up a new Python project"02-projects.md, 03-project-config.md
"Add a dependency"04-dependencies.md, 05-resolution.md
"Add a dev dependency"04-dependencies.md (search: dependency groups, --group dev)
"Pin Python version"06-python-versions.md, 10-configuration.md
"Use a private package index"10-configuration.md, 11-authentication.md, 15-integrations.md (Alternative Indexes section)
"Docker build with uv"13-docker.md, 01-getting-started.md
"GitHub Actions CI"14-ci-cd.md
"GitLab CI"14-ci-cd.md
"Deploy to AWS Lambda"15-integrations.md (AWS Lambda section), 04-dependencies.md
"Migrate from pip/requirements.txt"16-migration.md, 09-pip-interface.md
"Use pip-tools workflow (compile/sync)"09-pip-interface.md
"Monorepo / workspace"12-workspaces.md, 04-dependencies.md
"Run a one-off tool (like ruff, black)"07-tools-and-scripts.md (Tools section)
"Run a script with inline deps"07-tools-and-scripts.md (Scripts section)
"Build and publish a package"08-building-and-publishing.md, 11-authentication.md
"Configure resolution (pre-releases, overrides)"05-resolution.md, 04-dependencies.md
"Use PyTorch / CUDA indexes"15-integrations.md (PyTorch section), 10-configuration.md
"Jupyter notebook with uv"15-integrations.md (Jupyter section)
"FastAPI project"15-integrations.md (FastAPI section), 02-projects.md
"SSL/TLS certificate issues"11-authentication.md, 17-troubleshooting.md
"Build failures / missing C libs"17-troubleshooting.md, 10-configuration.md
"Cache problems / disk space"10-configuration.md (Cache and Storage sections)
"Lock reproducibility / --exclude-newer"05-resolution.md, 02-projects.md
"pre-commit hooks"15-integrations.md (pre-commit section)
"Dependency update bots"15-integrations.md (Dependency Bots section)
"Export lockfile (requirements.txt, pylock.toml, CycloneDX)"04-dependencies.md (Export section), 09-pip-interface.md
"Editable installs"09-pip-interface.md, 04-dependencies.md
"Using system Python / --system"09-pip-interface.md, 06-python-versions.md
"View or bump project version"02-projects.md, 08-building-and-publishing.md
"Manage index credentials (login/logout)"11-authentication.md
"Export SBOM (CycloneDX)"04-dependencies.md (Export section)
"Marimo notebooks with uv"15-integrations.md (Marimo section)
"Hugging Face model index"11-authentication.md, 15-integrations.md
"Build isolation issues (flash-attn, deepspeed)"03-project-config.md, 17-troubleshooting.md

Key Environment Variables

VariablePurposeDoc
UV_CACHE_DIROverride cache directory10-configuration.md
UV_TOOL_DIROverride tool install directory10-configuration.md
UV_PYTHON_INSTALL_DIROverride managed Python directory10-configuration.md
UV_PYTHONOverride Python interpreter06-python-versions.md
UV_PYTHON_PREFERENCEPrefer managed vs system Python06-python-versions.md
UV_SYSTEM_PYTHONUse system Python by default14-ci-cd.md
UV_PREVIEWEnable preview features10-configuration.md
UV_EXCLUDE_NEWERExclude packages after date05-resolution.md
UV_INDEX_<NAME>_USERNAMEIndex auth username11-authentication.md
UV_INDEX_<NAME>_PASSWORDIndex auth password/token11-authentication.md
UV_INSTALL_DIROverride uv install location01-getting-started.md
UV_COMPILE_BYTECODECompile .pyc during install13-docker.md
UV_LINK_MODEInstall link mode (copy/hardlink)13-docker.md
SSL_CERT_FILECustom CA certificate bundle11-authentication.md
SSL_CLIENT_CERTClient TLS certificate11-authentication.md

Key Configuration Snippets

pyproject.toml [tool.uv] settings

Full details: 03-project-config.md, 10-configuration.md

toml
[tool.uv]
dev-dependencies = ["pytest>=8.0", "ruff>=0.5"]
python-preference = "managed"       # prefer uv-managed Python
package = false                     # treat as non-package (app)
default-groups = ["dev"]            # groups installed by default

[[tool.uv.index]]
name = "custom"
url = "https://custom.pypi.org/simple"
explicit = true                     # only use for packages that request it

[tool.uv.sources]
my-pkg = { git = "https://github.com/org/repo", tag = "v1.0" }

Workspace configuration

Full details: 12-workspaces.md

toml
[tool.uv.workspace]
members = ["packages/*"]
exclude = ["packages/experimental"]

Dependency overrides and constraints

Full details: 05-resolution.md, 04-dependencies.md

toml
[tool.uv]
override-dependencies = ["package==1.0.0"]
constraint-dependencies = ["package>=1.0,<2.0"]

Index configuration with authentication

Full details: 10-configuration.md, 11-authentication.md

toml
[[tool.uv.index]]
name = "private"
url = "https://private.pypi.org/simple"
bash
export UV_INDEX_PRIVATE_USERNAME=user
export UV_INDEX_PRIVATE_PASSWORD=token

Instructions for the Agent

  1. Identify the topic from the user's question using the Command Reference or Cross-Reference tables above.
  2. Read the primary doc listed for that topic. All files are at ./<filename> relative to this SKILL.md.
  3. Read secondary docs from the "Also see" column or Cross-Reference table if the primary doc doesn't fully answer the question.
  4. Each file is self-contained per topic - you typically need only 1-2 files per question.
  5. When generating pyproject.toml configuration, cross-check with 03-project-config.md and 10-configuration.md.
  6. When suggesting commands, verify flags and options against the relevant doc before recommending them.
  7. For integration-specific questions (FastAPI, Jupyter, PyTorch, etc.), check 15-integrations.md first - each integration has its own ## section.