using-uv
UV
UV is a fast Python package manager. Two modes:
Scripts vs Projects
Use scripts when:
- Single .py file
- Quick utility, one-off task
- No shared dependencies across files
Use projects when:
- Multiple files, modules, or packages
- Team collaboration
- Need reproducible environments
- Building a library or application
Scripts
Standalone Python files with inline dependencies (PEP 723).
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.12"
# dependencies = ["requests", "rich"]
# ///
import requests
from rich import print
Run: uv run script.py
See references/scripts.md for full guide.
Projects
Structured Python with pyproject.toml and lockfile.
uv init myproject
cd myproject
uv add requests
uv run python main.py
Key files:
pyproject.toml- metadata and dependenciesuv.lock- exact versions for reproducibility.python-version- Python version
See references/projects.md for full guide.
Common Patterns
uv run pytest # Run in project env
uv add --dev pytest # Dev dependency
uvx ruff check . # One-off tool execution
uv run --with rich script.py # Script with ad-hoc dep
More from lexler/skill-factory
hexagonal-architecture
Applies hexagonal (ports & adapters) architecture. Use when designing application structure, separating domain from infrastructure, creating testable boundaries, or when user mentions ports, adapters, hexagonal, or clean architecture.
13approval-tests
Writes approval tests (snapshot/golden master testing) for Python, JavaScript/TypeScript, or Java. Use when verifying complex output, characterization testing legacy code, testing combinations, or working with .approved/.received files.
5refactoring
Refactoring process. Invoke immediately when user or document mentions refactoring, or proactively when code gets too complex or messy.
5git-worktrees
Creates git worktrees for parallel development. Use when creating a git worktree, setting up multiple working directories, or working on features in parallel.
5nullables
Writes tests without mocks using Nullables. Use when writing tests, especially testing code with external I/O (HTTP, files, databases, clocks, random numbers), designing infrastructure wrappers or replacing mocking libraries.
5ai-patterns
Reference patterns for augmented coding with AI. Use when discussing AI coding patterns, anti-patterns, obstacles, context management, steering AI, or looking up Lexler's patterns collection.
5