python-env

Fast Python environment management with uv (10-100x faster than pip). Triggers on: uv, venv, pip, pyproject, python environment, install package, dependencies.

16 stars

Best use case

python-env is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Fast Python environment management with uv (10-100x faster than pip). Triggers on: uv, venv, pip, pyproject, python environment, install package, dependencies.

Teams using python-env should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/python-env/SKILL.md --create-dirs "https://raw.githubusercontent.com/0xDarkMatter/claude-mods/main/skills/python-env/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/python-env/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How python-env Compares

Feature / Agentpython-envStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Fast Python environment management with uv (10-100x faster than pip). Triggers on: uv, venv, pip, pyproject, python environment, install package, dependencies.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Python Environment

Fast Python environment management with uv. Prefer the uv **project** workflow
(`uv add` / `uv sync` / `uv run`) over the `uv pip` compatibility layer — it
manages `pyproject.toml` + a lockfile for you and is reproducible.

## Quick Commands

| Task | Command |
|------|---------|
| Start a project | `uv init <name>` (app) · `uv init --package <name>` (installable, `src/` layout) |
| Add dependency | `uv add httpx` |
| Add dev dependency | `uv add --dev pytest ruff` |
| Remove dependency | `uv remove httpx` |
| Sync env from lockfile | `uv sync` |
| Run in project env | `uv run pytest` |
| Update lockfile | `uv lock` |
| Install a CLI tool | `uv tool install ruff` · one-shot: `uvx ruff` |
| Install a Python | `uv python install 3.12` |

## Start a Project

```bash
# Application (flat layout, no package build)
uv init myapp

# Installable package (src/ layout — separate tests/ that import by name)
uv init --package wordtools
# → src/wordtools/__init__.py, pyproject.toml with build-system
```

`uv init` creates `pyproject.toml`, pins a Python version, and prepares the
project for `uv add` / `uv sync`. The `--package` (src) layout is preferred for
anything with a test suite or that you intend to ship.

## Manage Dependencies

```bash
# Add runtime deps (writes to [project.dependencies] + updates the lockfile)
uv add "httpx>=0.25" pydantic

# Add dev-only deps (writes to the dev dependency-group)
uv add --dev pytest ruff mypy

# Add with extras
uv add "fastapi[standard]"

# Remove
uv remove httpx

# Install everything from pyproject + uv.lock into .venv (reproducible)
uv sync

# Refresh the lockfile (e.g. after manual pyproject edits)
uv lock
```

`uv` creates and manages `.venv` automatically — you rarely activate it; just
prefix commands with `uv run`.

## Run Code

```bash
uv run python script.py     # run a script in the project env
uv run pytest               # run a tool from the dev group
uv run -- ruff check .      # `--` ends uv flag parsing
```

Never call bare `python` / `pytest` / `ruff` in a uv project — they may resolve
to a different interpreter. Always `uv run`.

## CLI Tools (global, not project deps)

```bash
uv tool install ruff        # persistent, isolated, on PATH
uv tool upgrade ruff
uvx ruff check .            # ephemeral one-shot run, nothing installed
```

Use `uv tool` / `uvx` for developer CLIs (ruff, pre-commit, httpie). Use
`uv add` only for things your code imports.

## Python Versions

```bash
uv python install 3.12      # download a managed interpreter
uv python list              # show available + installed
uv init --python 3.12 app   # pin a project to a version
```

3.13 is the current stable release (free-threading and JIT, both opt-in); 3.11+
is a sensible floor for new projects (TaskGroup, `Self`, faster interpreter).

## Minimal pyproject.toml

```toml
[project]
name = "my-project"
version = "0.1.0"
requires-python = ">=3.11"
dependencies = [
    "httpx>=0.25",
    "pydantic>=2.0",
]

# Dev deps live here; `uv add --dev <pkg>` manages this group.
[dependency-groups]
dev = [
    "pytest>=8.0",
    "ruff>=0.4",
    "mypy>=1.10",
]
```

## Compatibility Layer (`uv pip`) — last resort

`uv pip` mirrors pip's interface for environments uv doesn't manage (a hand-made
venv, a legacy `requirements.txt`, CI that isn't uv-native). It does **not**
update `pyproject.toml` or the lockfile — prefer `uv add` / `uv sync` whenever
you control the project.

```bash
uv venv                              # bare venv (no project)
uv pip install -r requirements.txt   # legacy requirements file
uv pip install -e .                  # editable install into an unmanaged venv
uv pip compile requirements.in -o requirements.txt   # pin a requirements.txt
```

## Troubleshooting

| Issue | Solution |
|-------|----------|
| "No Python found" | `uv python install 3.12` |
| Pin project Python | `uv init --python 3.12` or edit `requires-python` |
| Lock/resolve conflict | `uv lock --resolution=lowest-direct` to probe, then loosen bounds |
| Stale env after pull | `uv sync` |
| Cache issues | `uv cache clean` |

## When to Use

- **Always** use uv over pip — 10-100x faster
- `uv add` / `uv remove` / `uv sync` for project dependencies (not `uv pip install`)
- `uv run` to execute anything inside the project env
- `uv tool install` / `uvx` for standalone developer CLIs
- `uv pip` only for environments uv doesn't manage

## Additional Resources

For detailed patterns, load:
- `./references/pyproject-patterns.md` - Full pyproject.toml examples, tool configs
- `./references/dependency-management.md` - Lock files, workspaces, private packages
- `./references/publishing.md` - PyPI publishing, versioning, CI/CD

---

## See Also

This is a **foundation skill** with no prerequisites.

**Build on this skill:**
- `python-typing-ops` - Type hints for projects
- `python-pytest-ops` - Testing infrastructure
- `python-fastapi-ops` - Web API development

Related Skills

python-typing-ops

16
from 0xDarkMatter/claude-mods

Python type hints and type safety patterns. Triggers on: type hints, typing, TypeVar, Generic, Protocol, mypy, pyright, type annotation, overload, TypedDict.

python-pytest-ops

16
from 0xDarkMatter/claude-mods

pytest testing patterns for Python. Triggers on: pytest, fixture, mark, parametrize, mock, conftest, test coverage, unit test, integration test, pytest.raises.

python-observability-ops

16
from 0xDarkMatter/claude-mods

Observability patterns for Python applications. Triggers on: logging, metrics, tracing, opentelemetry, prometheus, observability, monitoring, structlog, correlation id.

python-fastapi-ops

16
from 0xDarkMatter/claude-mods

FastAPI web framework patterns. Triggers on: fastapi, api endpoint, dependency injection, pydantic model, openapi, swagger, starlette, async api, rest api, uvicorn.

python-database-ops

16
from 0xDarkMatter/claude-mods

SQLAlchemy and database patterns for Python. Triggers on: sqlalchemy, database, orm, migration, alembic, async database, connection pool, repository pattern, unit of work.

python-cli-ops

16
from 0xDarkMatter/claude-mods

CLI application patterns for Python. Triggers on: cli, command line, typer, click, argparse, terminal, rich, console, terminal ui.

python-async-ops

16
from 0xDarkMatter/claude-mods

Python asyncio patterns for concurrent programming. Triggers on: asyncio, async, await, coroutine, gather, semaphore, TaskGroup, event loop, aiohttp, concurrent.

windows-ops

16
from 0xDarkMatter/claude-mods

Comprehensive Windows workstation operations - diagnose slow boot, identify failing drives, decode BSOD crashes, manage startup apps, audit event logs. Use for: Windows is slow, slow bootup, won't boot, blue screen, BSOD, kernel crash, drive failing, SMART errors, disk errors, Event 41, Event 129, storahci reset, BugCheck, CRITICAL_PROCESS_DIED, crash dump, MEMORY.DMP, minidump, msconfig, services.msc, registry Run keys, StartupApproved, scheduled tasks at logon, slow login, high CPU at boot, Adobe startup, Docker startup, disable startup app.

vue-ops

16
from 0xDarkMatter/claude-mods

Vue 3 development patterns, Composition API, Pinia state management, Vue Router, and Nuxt 3. Use for: vue, vuejs, composition api, pinia, vue router, nuxt, nuxt3, script setup, composable, reactive, defineProps, defineEmits, defineModel, v-model, provide inject, vue3.

unfold-admin

16
from 0xDarkMatter/claude-mods

Django Unfold admin theme - build, configure, and enhance modern Django admin interfaces with Unfold. Use when working with: (1) Django admin UI customisation or theming, (2) Unfold ModelAdmin, inlines, actions, filters, widgets, or decorators, (3) Admin dashboard components and KPI cards, (4) Sidebar navigation, tabs, or conditional fields, (5) Any mention of 'unfold', 'django-unfold', or 'unfold admin'. Covers the full Unfold feature set: site configuration, actions system, display decorators, filter types, widget overrides, inline variants, dashboard components, datasets, sections, theming, and third-party integrations.

typescript-ops

16
from 0xDarkMatter/claude-mods

TypeScript type system, generics, utility types, strict mode, and ecosystem patterns. Use for: typescript, ts, type, generic, utility type, Partial, Pick, Omit, Record, Exclude, Extract, ReturnType, Parameters, keyof, typeof, infer, mapped type, conditional type, template literal type, discriminated union, type guard, type assertion, type narrowing, tsconfig, strict mode, declaration file, zod, valibot.

tool-discovery

16
from 0xDarkMatter/claude-mods

Recommend the right agents and skills for any task. Covers both heavyweight agents (Task tool) and lightweight skills (Skill tool). Triggers on: which agent, which skill, what tool should I use, help me choose, recommend agent, find the right tool.