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 installand 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
- Install uv with the official installer, Homebrew (
brew install uv) or WinGet (winget install --id=astral-sh.uv -e). Confirm withuv --version. - In an empty folder, run
uv init. This writespyproject.tomland a.python-versionfile. To pin the interpreter, runuv python pin 3.12. - Add a library with
uv add requests. Add a dev tool withuv add --dev ruff. uv updatespyproject.tomland the lockfile, and creates.venvif needed. - On another machine, or in CI, run
uv sync --frozenso the install matchesuv.lockand does not resolve again. - Run tools through uv so you do not activate the venv:
uv run python main.pyoruv run ruff check. - When you want newer versions, run
uv lock --upgradeand read the diff before you commit it. - Ignore
.venv. Do not ignoreuv.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 installis a pip-compatible escape hatch. Preferuv addso the lockfile stays the source of truth.uv syncwithout--frozenmay update the lock. In CI, use--frozenso a surprise upgrade fails the job.- Deleting
.venvis safe.uv syncrebuilds 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.tomlanduv.lockare committed, and.venvis ignored.uv sync --frozensucceeds 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