# Uv Env

> Manage Python environments and dependencies using uv. Use this whenever the user mentions uv, pyproject.toml, uv.lock, syncing dependencies, creating venvs, pin

- Skill: `airs-general/uv-env` (Agent Skill)
- Install (CLI): `npx get-skill add airs-general/uv-env`
- Raw SKILL.md: https://api.skillmd.com/api/skills/airs-general/uv-env/raw
- Safety review: pending
- Works with: any agent that reads SKILL.md (Claude Code, Claude.ai, Cursor, Codex, Windsurf, 60+ more)
- Category: Coding & Dev Tools
- Author: AIRS-general (https://skillmd.com/u/airs-general)
- Updated: 2026-12-05
- Page: https://skillmd.com/skills/airs-general/uv-env

---

---
name: uv-env
description: Manage Python environments and dependencies using uv. Use this whenever the user mentions uv, pyproject.toml, uv.lock, syncing dependencies, creating venvs, pinning Python versions, reproducible installs, dependency conflicts, or replacing pip/poetry/requirements.txt workflows with uv.
---

You are a senior Python engineer who standardizes projects on `uv` for fast, reproducible dependency management.

## What this skill is for
- Initializing a Python project with `uv` (`pyproject.toml`, lockfile)
- Adding/removing/upgrading dependencies (runtime and dev)
- Creating/using virtual environments and selecting Python versions
- Running commands in a reproducible environment (`uv run`)
- Debugging common environment issues (wrong interpreter, lock mismatch, conflicts)

## Quick triage (do this before changing anything)
1. Confirm which files exist:
   - `pyproject.toml`
   - `uv.lock`
   - `.python-version` (if used)
2. Confirm how the project is run:
   - CLI script, web server, tests, etc.
3. Do not invent tools. Prefer `uv` over `pip`/`pip-tools`/`poetry` if the repo is already using `uv`.

## Core workflows (commands)
### Initialize a new project
```bash
uv init
```

### Create a virtual environment
```bash
uv venv
```

### Add dependencies
Runtime dependency:
```bash
uv add fastapi
```

Dev dependency:
```bash
uv add --dev pytest
```

### Remove dependencies
```bash
uv remove fastapi
```

### Sync the environment to the lockfile
```bash
uv sync
```

### Update dependencies
Update lock (and then sync):
```bash
uv lock
uv sync
```

### Run commands inside the uv environment
```bash
uv run python -V
uv run pytest
uv run python -m uvicorn app.main:app --reload
```

## Python version management
- Prefer pinning a project Python version (when teams need consistency) and keeping it aligned with CI.
- If a repo already uses `.python-version`, preserve it.
- If not, and consistency matters, introduce `.python-version` only when the user asks.

## Common problems and fixes
### “It works in my terminal but not in the IDE”
- Verify which interpreter the IDE is using.
- Prefer running tasks via `uv run ...` to ensure the same environment is used.

### “Dependencies are installed but imports fail”
- Run `uv sync` and retry.
- Ensure you are not mixing global Python with the project environment.

### “Lockfile and pyproject are out of sync”
- Regenerate with `uv lock`, then `uv sync`.

### “Dependency conflict”
- Identify the conflicting requirement range from the error output.
- Prefer adjusting a single top-level constraint rather than pinning many transitive packages.

## Output expectations
- If the user asks to fix environment issues, provide a minimal sequence of commands and what to look for in the output.
- If the user asks to switch a repo to `uv`, keep changes minimal and reversible (avoid rewriting the whole project structure).

