No slash command · from lab-skills
Conda environment activation for Python commands. Use when running Python scripts, pip, or conda-dependent tools.
Ships in lab-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
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.
Record pip installs in environment.yml. When you fall back to pip, add the package under a pip: subsection (and ensure pip is listed as a conda dependency). conda env export --from-history does not capture pip-installed packages, so they are otherwise silently lost:
dependencies:
- python=3.11
- pip # required for the pip: section below
- numpy
- pip:
- some-pip-only-package==1.2.3
Detect what was pip-installed (channel shows as pypi):
conda list | awk 'NR>3 && $NF=="pypi" {print $1"=="$2}'
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.environment.yml is hand-curated and portable. Use --from-history for the conda
packages — it records only explicitly installed packages, not platform-specific transitive
deps:
conda env export --from-history # conda packages — does NOT include pip installs
--from-history silently omits pip-installed packages. Capture those separately and
record them under a pip: subsection (with pip listed as a conda dependency):
conda list | awk 'NR>3 && $NF=="pypi" {print $1"=="$2}' # pip-installed packages
Prefer reconciling the existing hand-curated environment.yml (add new conda packages
to dependencies:, new pip packages to the pip: subsection) over overwriting it — a full
conda env export produces pinned, platform-specific build strings that aren't portable.
Hygiene — keep out of environment.yml:
prefix: line — machine-specific absolute path, not portabledefaults channel — 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.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub musserlab/lab-claude-skills --plugin lab-skills34 skills in this plugin
/audit-projectPeriodic project health check - cross-check docs, prune conventions, find drift. Use when project documentation feels stale, before milestones, or when CLAUDE.md is getting long. Do NOT load for auditing skills (use /audit-skills) or data analysis scripts (use /audit-script).
/audit-scriptSystematic audit of data analysis scripts for bugs, analytical reasoning, data handling, style, and reproducibility. Includes domain verification phase that researches tools, file formats, and methods to catch domain-specific errors (not just code bugs). Use when auditing a script, reviewing code for correctness, checking for bugs, preparing a script for publication, or when the user says "audit this script", "review this code", "check this for bugs", or "is this script correct". Three modes: thorough (collaborative section-by-section), fast (Claude-driven with discussion), and report-only. Do NOT load for quick one-off questions about a single line or function.
/audit-skillsAudit Claude Code skills for bloat, trigger accuracy, structural quality, redundancy, and pruning opportunities. Use when skills feel bloated, before publishing to lab repo, after building several new skills, when reviewing a single newly-created skill before publishing, or when the user says "audit my skills", "review skills", "check skill quality", "audit this skill", or invokes /audit-skills. Covers both user-level (~/.claude/skills/) and project-level (.claude/skills/) skills, and supports both full-library scans and single-skill reviews. Do NOT load for auditing data analysis scripts (use /audit-script) or project documentation (use /audit-project).
/cleanup-scriptsSession-scoped script cleanup for data science projects. Checks scripts/scratch/ for working files that need consolidation into .qmd scripts, flags numbered non-.qmd files in scripts/, and verifies script-output directory correspondence. Use when finishing a coding session, when scripts/scratch/ has accumulated files, or when the user says "clean up scripts", "consolidate scratch", or "check script conventions". Lightweight and fast — reads files, no expensive computation.
/data-handlingData handling best practices for R and Python data science analysis scripts. Use when writing data manipulation code, analysis pipelines, or .qmd scripts that process scientific/analytical data (e.g., filtering, joining, normalizing datasets). Do NOT load for general Python scripting, infrastructure code, or configuration management.
/debugging-before-patchingSystematic debugging and error diagnosis. Use when debugging errors, fixing bugs, diagnosing problems in code or data, or when the user reports something not working.