Backend · Skill

Set up Python with uv

set-up-python-with-uv

Sets up a Python project with uv - install the tool, create pyproject.toml, add packages, write a lockfile, and run commands without activating a venv by hand. Use when the user wants uv, a Python lockfile, or to replace pip and virtualenv for a project.

Works with: Any AI Not yet model-tested; testing Jan 2027

Paste it into ChatGPT, Claude, Gemini or any AI chat, then tell it about your project. How it works

Install in Claude Code, Cursor or Codex (optional)

Only for AI coding tools that read skill folders. Run one line in a terminal, in your project folder. It downloads this skill's text files from TheSkillVault and nothing else; you can read them first with “View raw SKILL.md”.

Claude Code (all your projects)

curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/set-up-python-with-uv/raw' -o ~/'.claude/skills/set-up-python-with-uv/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/set-up-python-with-uv/files/LICENSE.txt' -o ~/'.claude/skills/set-up-python-with-uv/LICENSE.txt'

Cursor (this project)

curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/set-up-python-with-uv/raw' -o '.cursor/skills/set-up-python-with-uv/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/set-up-python-with-uv/files/LICENSE.txt' -o '.cursor/skills/set-up-python-with-uv/LICENSE.txt'

Codex and other Agent Skills tools (this project)

curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/set-up-python-with-uv/raw' -o '.agents/skills/set-up-python-with-uv/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/set-up-python-with-uv/files/LICENSE.txt' -o '.agents/skills/set-up-python-with-uv/LICENSE.txt'

Or connect the whole library over MCP

Add TheSkillVault to Cursor or add this to your app's MCP settings (read-only; help):

{
  "mcpServers": {
    "theskillvault": {
      "url": "https://theskillvault.ai/mcp"
    }
  }
}

uv installs Python packages and manages the virtual environment for you. The project file is pyproject.toml. The lockfile is uv.lock. Commit both.

When to use

  • A repo still uses pip install and a checked-in pin file that nobody updates.
  • Two machines resolve different versions from the same file.
  • You want one command that creates the environment and runs a script.

When not to use

  • You need the shape of an HTTP API. uv does not design routes.
  • You need test layout, fixtures and mocks. That is a testing task. uv can install the runner, and that is all.

Steps

  1. Install uv with the official installer, Homebrew (brew install uv) or WinGet (winget install --id=astral-sh.uv -e). Confirm with uv --version.
  2. In an empty folder, run uv init. This writes pyproject.toml and a .python-version file. To pin the interpreter, run uv python pin 3.12.
  3. Add a library with uv add requests. Add a dev tool with uv add --dev ruff. uv updates pyproject.toml and the lockfile, and creates .venv if needed.
  4. On another machine, or in CI, run uv sync --frozen so the install matches uv.lock and does not resolve again.
  5. Run tools through uv so you do not activate the venv: uv run python main.py or uv run ruff check.
  6. When you want newer versions, run uv lock --upgrade and read the diff before you commit it.
  7. Ignore .venv. Do not ignore uv.lock.
uv init
uv python pin 3.12
uv add requests
uv add --dev ruff
uv sync --frozen
uv run python main.py

Gotchas

  • Do not put an index token, password or API key in pyproject.toml. Pass private-index credentials through the environment, as uv's docs describe for that index.
  • uv pip install is a pip-compatible escape hatch. Prefer uv add so the lockfile stays the source of truth.
  • uv sync without --frozen may update the lock. In CI, use --frozen so a surprise upgrade fails the job.
  • Deleting .venv is safe. uv sync rebuilds it from the lockfile.

Portability

uv runs on macOS, Linux and Windows. If you use Poetry or pip-tools instead, keep the same rule: one project file, one lockfile, and a frozen install in CI. The commands differ. A Docker image can copy uv.lock and run uv sync --frozen rather than pip install.

Done when

  • pyproject.toml and uv.lock are committed, and .venv is ignored.
  • uv sync --frozen succeeds on a clean checkout.
  • Scripts run with uv run, and no secret is written in the project file.

Example prompt

"Move this repo off pip and a pinned package list. Set it up with uv, pin Python 3.12, and make CI install from the lockfile."

---

Adapted from "uv-package-manager" in wshobson/agents (MIT, Copyright (c) 2024 Seth Hobson). See LICENSE.txt.

Bundled files

Licence

Adapted from Seth Hobson (wshobson/agents, uv-package-manager) (Copyright (c) 2024 Seth Hobson), MIT License. Adapted by TheSkillVault: rewritten as a short uv setup (init, add, lock, sync, run) with original commands; dropped the comparison catalogue and advanced source tables; added secret handling, gotchas and done-when.

Licence: MIT License. Attribution when you reuse it: Based on work by Seth Hobson (wshobson/agents, uv-package-manager) (Copyright (c) 2024 Seth Hobson, MIT License), https://github.com/wshobson/agents/tree/7e2fb559cf4b824b27f1fec49fe88f7511066d26/plugins/python-development/skills/uv-package-manager; adapted by TheSkillVault, https://theskillvault.ai