From python-venv
Before running Python scripts or installing packages, you MUST use a virtual environment in the current working directory. This applies to: running .py files, using pip/uv pip install, or any task requiring third-party packages. Exceptions: simple one-liners using only Python standard library.
How this skill is triggered — by the user, by Claude, or both
Slash command
/python-venv:python-venvThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
**Use virtual environment when installing packages or running scripts that require third-party dependencies.**
Use virtual environment when installing packages or running scripts that require third-party dependencies.
| Scenario | Required? | Reason |
|---|---|---|
pip install / uv pip install | ✅ YES | Installing packages |
Running .py files with third-party imports | ✅ YES | Needs dependencies |
python script.py with requirements.txt | ✅ YES | Project dependencies |
| Multi-file Python projects | ✅ YES | Isolation needed |
| Scenario | Required? | Example |
|---|---|---|
| Simple one-liner with stdlib only | ❌ NO | python3 -c "print('hello')" |
| Quick math/string operations | ❌ NO | python3 -c "print(2**10)" |
| Using only built-in modules | ❌ NO | python3 -c "import json; ..." |
| Checking Python version | ❌ NO | python3 --version |
These modules are built-in and don't require virtual environment:
os, sys, json, re, math, datetime, pathlib, subprocess,
collections, itertools, functools, argparse, logging,
urllib, http, socket, threading, multiprocessing, etc.
1. Check if virtual environment exists (.venv, venv, env, .env) → If YES, activate and reuse it
2. If NOT exists → Create with uv (if available) or python3 -m venv
3. Activate, then proceed with Python commands
Check in this order (first match wins):
# Common virtual environment directory names
.venv/ → Most common (preferred)
venv/ → Also common
env/ → Sometimes used
.env/ → Less common (be careful: may conflict with dotenv files)
# Create virtual environment
uv venv
# Activate (Linux/macOS)
source .venv/bin/activate
# Activate (Windows PowerShell)
.venv\Scripts\Activate.ps1
# Activate (Windows CMD)
.venv\Scripts\activate.bat
# Install packages
uv pip install <package>
# Create virtual environment
python3 -m venv .venv
# Activate (Linux/macOS)
source .venv/bin/activate
# Activate (Windows PowerShell)
.venv\Scripts\Activate.ps1
# Activate (Windows CMD)
.venv\Scripts\activate.bat
# Install packages
pip install <package>
# Create environment
conda create -n myenv python=3.11
# Activate
conda activate myenv
# Install packages
conda install <package>
# or
pip install <package>
Before Python operations requiring venv:
.venv/, venv/, env/, .env/conda info --envs or check if CONDA_PREFIX is setuv venv (preferred) or python3 -m venv .venv (fallback)Priority: Always reuse existing virtual environment to preserve installed packages.
| Task | Linux/macOS | Windows |
|---|---|---|
| Create venv (uv) | uv venv | uv venv |
| Create venv (standard) | python3 -m venv .venv | python -m venv .venv |
| Activate | source .venv/bin/activate | .venv\Scripts\activate |
| Install package (uv) | uv pip install <pkg> | uv pip install <pkg> |
| Install package (pip) | pip install <pkg> | pip install <pkg> |
| Install from requirements | uv pip install -r requirements.txt | uv pip install -r requirements.txt |
| Install from pyproject.toml | uv pip install -e . | uv pip install -e . |
| Deactivate | deactivate | deactivate |
| Conda activate | conda activate <env> | conda activate <env> |
# Find existing venv or create new one (uv with fallback to venv)
if [ -d .venv ]; then
source .venv/bin/activate
elif [ -d venv ]; then
source venv/bin/activate
elif [ -d env ]; then
source env/bin/activate
elif command -v uv &> /dev/null; then
uv venv && source .venv/bin/activate
else
python3 -m venv .venv && source .venv/bin/activate
fi
# Quick version: check .venv, fallback to create
[ -d .venv ] && source .venv/bin/activate || { command -v uv &>/dev/null && uv venv || python3 -m venv .venv; source .venv/bin/activate; }
# Find existing venv or create new one
if (Test-Path .venv) { .\.venv\Scripts\Activate.ps1 }
elseif (Test-Path venv) { .\venv\Scripts\Activate.ps1 }
elseif (Get-Command uv -ErrorAction SilentlyContinue) { uv venv; .\.venv\Scripts\Activate.ps1 }
else { python -m venv .venv; .\.venv\Scripts\Activate.ps1 }
# Activate existing or create new
[ -d .venv ] && source .venv/bin/activate || { command -v uv &>/dev/null && uv venv || python3 -m venv .venv; source .venv/bin/activate; }
# Install dependencies (check both requirements.txt and pyproject.toml)
[ -f requirements.txt ] && pip install -r requirements.txt
[ -f pyproject.toml ] && pip install -e .
# Run script
python script.py
# Should show path containing .venv, venv, or env
which python
# Or check VIRTUAL_ENV environment variable
echo $VIRTUAL_ENV
# Check CONDA_PREFIX
echo $CONDA_PREFIX
# List all conda environments
conda info --envs
pip install with system Python (always use venv)python3 -c "print('hello')"python3 -c "import os; print(os.getcwd())"python3 --version| File Present | Project Type | Install Command |
|---|---|---|
requirements.txt | Traditional | pip install -r requirements.txt |
pyproject.toml | Modern (PEP 517/518) | pip install -e . or uv pip install -e . |
pyproject.toml + poetry.lock | Poetry | poetry install |
pyproject.toml + uv.lock | uv native | uv sync |
setup.py | Legacy | pip install -e . |
Pipfile | Pipenv | pipenv install |
environment.yml | Conda | conda env create -f environment.yml |
If venv is broken (import errors, missing packages after install):
# Remove and recreate
rm -rf .venv
uv venv && source .venv/bin/activate
# or
python3 -m venv .venv && source .venv/bin/activate
# Specify Python version with uv
uv venv --python 3.11
# Or with standard venv
python3.11 -m venv .venv
Run PowerShell as Administrator, or:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Use Linux commands in WSL:
# Same as Linux/macOS
source .venv/bin/activate
Note: Don't mix Windows venv with WSL. Create separate venv for each environment.
Guides completion of development work by verifying tests, detecting environment, and presenting structured options for merge, PR, or cleanup.
Guides creation and editing of skills using test-driven development with pressure scenarios and subagents to verify agent compliance.
Dispatches multiple subagents concurrently for independent tasks without shared state. Use when facing 2+ unrelated failures or subsystems that can be investigated in parallel.
npx claudepluginhub cikichen/claude-code-skills --plugin skill-creator