agentleFS
jhutchison0jhutchison0/tacsop/.claude/skills/python-venv-management/SKILL.md

python-venv-management

Skill0 starsChanged 23 days agoApache-2.0View on GitHub

Creating, managing, and troubleshooting Python virtual environments with uv. Use when setting up isolated Python environments, resolving dependency conflicts, managing multiple project environments, automating setup with scripts or Makefiles, or migrating off system Python, pyenv, or conda.

  • Pipes a download into a shell
  • Reads credentials
  • Installs packages

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    One venv per project: Default; deviate only with a documented reason.

    line 24
  2. Very specific:

    uv is the engine: All environment and package operations go through uv venv and uv pip.

    line 25

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Python Virtual Environment Management (uv)

Isolate Python dependencies per project, prevent conflicts between projects requiring different package versions. uv (Astral) is the engine for all of it: interpreters, environments, and packages. This SKILL.md is the entry point; deep procedural content lives in two sidecar files loaded on demand.

Philosophy: "One project, one environment. Isolate dependencies, document requirements, automate setup."

When to Use

  • Setting up a new Python project (always)
  • Resolving a dependency conflict between two packages
  • Managing multiple environments for the same project (Python version matrix, optional heavy deps)
  • Writing or auditing a project's setup script / Makefile
  • Migrating an existing codebase off system Python, pyenv, or conda/miniforge
  • Diagnosing "module not found" or "wrong Python version" errors

Core Principles

  1. One venv per project. Default; deviate only with a documented reason.
  2. uv is the engine. All environment and package operations go through uv venv and uv pip. Never sudo pip; never system pip.
  3. Managed interpreters. uv venv --managed-python builds the venv on a uv-downloaded CPython. The venv then survives removal of pyenv, conda, or a system Python upgrade.
  4. Pin production dependencies. Reproducible builds beat flexibility-at-deploy-time.
  5. Never commit secrets or the venv directory. .venv/ and .env both belong in .gitignore.

Quick Reference

Essential Commands

TaskCommand
Install uvcurl -LsSf https://astral.sh/uv/install.sh | sh
Install an interpreteruv python install 3.12
Create venvuv venv --managed-python
Activate (Linux/Mac)source .venv/bin/activate
Activate (Windows).venv\Scripts\activate
Deactivatedeactivate
Install depsuv pip install --python .venv -r requirements.txt
Install project (editable)uv pip install --python .venv -e .
Install with dev depsuv pip install --python .venv -e ".[dev]"
Freeze deps to fileuv pip freeze --python .venv > requirements.txt
List packagesuv pip list --python .venv
Show package infouv pip show --python .venv <package>
Check what's activewhich python (should show .venv/bin/python)

Every uv pip command names its target with --python .venv. A bare uv pip targets an active or inherited VIRTUAL_ENV before the project's .venv, so a variable left over from another repo's shell sends the install there. When the target is not the .venv in the current directory, uv prints Using Python <version> environment at: <path> before it acts; that path is where the packages go. A uv venv does not bundle pip; .venv/bin/pip does not exist, and that is by design.

Directory Conventions

project/
├── .venv/                  # Virtual environment (gitignored)
├── requirements.txt        # Production dependencies
├── requirements-dev.txt    # Development dependencies
├── requirements-test.txt   # Test dependencies (optional)
└── pyproject.toml          # Modern Python project config (preferred)

.gitignore Essentials

# Virtual environments
.venv/
venv/
ENV/
.venv-*/

# Environment files (secrets)
.env
.env.local
.env.*.local

# Keep templates
!.env.example

Sidecar Files

Loaded on demand when this SKILL.md cites them.

  • SETUP.md — single-vs-multiple environments, setup patterns (bash script, Makefile, pyproject.toml), requirements file organization, pinning strategy, Python version management with uv python, migrating off pyenv/conda.
  • TROUBLESHOOTING.md — dependency conflict resolution, environment variables and secrets, the most common venv failure modes with diagnoses and fixes, do/don't checklist.

Quick Anti-Pattern Reference

  • sudo pip install — never. Indicates you're installing to system Python, not your venv.
  • Calling .venv/bin/pip — it does not exist in a uv venv. Use uv pip .... Seed pip only if a tool genuinely requires it (uv venv --seed).
  • Building the venv on an incumbent's interpreter — a venv symlinked into ~/.pyenv/versions/ or a conda install breaks the day that incumbent is removed. Use --managed-python.
  • Committing .venv/ — adds gigabytes of OS-specific binaries to git.
  • uv pip freeze --python .venv > requirements.txt as your only spec — captures transitive deps and platform quirks; combine with hand-curated direct deps in pyproject.toml.
  • Sharing a venv across projects — defeats the isolation that's the entire point.
  • Mixing system Python and venv — which python should always point at your .venv/bin/python when activated.

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.