skills/conda-env/SKILL.md
Conda environment activation for Python commands. Use when running Python scripts, pip, or conda-dependent tools.
npx skillsauth add musserlab/lab-claude-skills conda-envInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Claude Code runs in a non-interactive shell where conda isn't automatically initialized. Always source the conda setup script before activating environments.
The activation command depends on the environment:
Local (macOS):
source ~/miniconda3/etc/profile.d/conda.sh && conda activate ENV_NAME && YOUR_COMMAND
Cluster (HPC — Bouchet/McCleary):
module load miniconda && source $(conda info --base)/etc/profile.d/conda.sh && conda activate ENV_NAME && YOUR_COMMAND
How to detect which to use: Check if the module command exists:
type module &>/dev/null && echo "cluster" || echo "local"
On the cluster, conda is provided via module load miniconda — there is no ~/miniconda3.
On local macOS, module doesn't exist.
Customize: On macOS, replace
~/miniconda3with your actual conda installation path if different (e.g.,~/miniforge3). Find it withconda info --base.
Check if the project has a conda environment:
environment.yml, environment.yaml, or conda env name in project's .claude/CLAUDE.mdList available environments:
source ~/miniconda3/etc/profile.d/conda.sh && conda env list
If the project specifies a conda environment, always activate it before running:
Always install packages into the project's conda environment, never into the system Python or base env.
Prefer conda install — it resolves dependencies against the full environment:
source ~/miniconda3/etc/profile.d/conda.sh && conda activate ENV_NAME && conda install PACKAGE
Fall back to pip only within the active conda env — if a package isn't available via conda/conda-forge:
source ~/miniconda3/etc/profile.d/conda.sh && conda activate ENV_NAME && pip install PACKAGE
Never run bare pip install without first activating the project's conda environment. This would install into the wrong Python and cause confusion.
When suggesting install commands to users (e.g., for students or collaborators), always include the conda activation step.
Run once on a new machine to ensure consistent package resolution:
conda config --set channel_priority strict
conda config --set solver libmamba
conda config --add channels conda-forge
defaults.Always use --from-history for portable environment files:
conda env export --from-history > environment.yml
This records only explicitly installed packages (not platform-specific transitive dependencies), making the file portable across OS and architectures.
Post-export hygiene — always clean up the exported file:
prefix: line — machine-specific absolute path, not portabledefaults from channels — conflicts with bioconda strict channel priorityconda-forge is listed as a channellab-general — shared environment for general projectsAll general-type projects (documentation sites, infrastructure tools, Quarto books, utility scripts) use the shared lab-general conda environment by default, regardless of whether they currently use Python. This ensures a consistent environment is always available if Python is needed later.
Contents: python 3.11, ipykernel, pyyaml, requests, pandas
When to use lab-general:
project-type: general project without complex dependenciesWhen to create a project-specific env instead:
lab-generalIdentifying which env a project uses: Check the project's .claude/CLAUDE.md — it will say either lab-general (shared) or {project_name} (project-specific) in the Environment section.
base environment — always use a named environmentlab-general by default — use the shared environment unless the project needs specialized dependencies, in which case create a project-specific oneipykernel — required for Quarto to execute Python chunksconda install over pip install — conda resolves dependencies holistically. Use pip only as a fallback for packages not available via conda/conda-forge~/miniconda3 or ~/miniforge3.module load miniconda — no local install.development
Phylogenetic tree visualization and formatting with ggtree (R) or iTOL (web). Use when rendering a phylogenetic tree as a figure, choosing tree layout, coloring branches or labels by taxonomy, collapsing clades, displaying support values, or adding overlays to a tree. Do NOT load for tree inference (use protein-phylogeny skill) or domain annotation (future separate skill).
development
Configure and manage Claude Code security protections for sensitive files, credentials, and data. Use when the user invokes /security-setup to set up or modify protections against unauthorized file access, credential exposure, or sensitive data leaks.
development
Script organization for data science analysis projects with numbered scripts, data/outs/ directories, and reproducibility conventions. Use when creating new analysis scripts in projects that follow data science conventions (numbered XX_ prefix scripts, outs/ directories, BUILD_INFO.txt). Do NOT load for documentation projects (Quarto books), infrastructure repos, or projects without data/outs/ directory structure.
testing
R renv package management for data science projects. Use when working with renv (renv.lock, renv::restore, renv::snapshot) in R analysis projects. Do NOT load for projects that do not use R or renv.