Agent skill
conda-env
Conda environment activation for Python commands. Use when running Python scripts, pip, or conda-dependent tools.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/conda-env
SKILL.md
Conda Environment Management
Claude Code runs in a non-interactive shell where conda isn't automatically initialized. Always source the conda setup script before activating environments.
Activation Pattern
source ~/miniconda3/etc/profile.d/conda.sh && conda activate ENV_NAME && YOUR_COMMAND
Or for miniforge3:
source ~/miniforge3/etc/profile.d/conda.sh && conda activate ENV_NAME && YOUR_COMMAND
Customize: Replace
~/miniconda3or~/miniforge3with your actual conda installation path. Find it withconda info --base.
Before Running Commands
-
Check if the project has a conda environment:
- Look for
environment.yml,environment.yaml, or conda env name in project's.claude/CLAUDE.md - Check for an env name matching the project directory name
- Look for
-
List available environments:
bashsource ~/miniconda3/etc/profile.d/conda.sh && conda env list -
If the project specifies a conda environment, always activate it before running:
- Python scripts
- Shell commands that depend on conda packages
- Tools like quarto (in some setups)
Package Installation
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:bashsource ~/miniconda3/etc/profile.d/conda.sh && conda activate ENV_NAME && conda install PACKAGE -
Fall back to
piponly within the active conda env — if a package isn't available via conda/conda-forge:bashsource ~/miniconda3/etc/profile.d/conda.sh && conda activate ENV_NAME && pip install PACKAGE -
Never run bare
pip installwithout 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.
One-Time Configuration
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
- strict channel priority: When a package exists in multiple channels, conda uses only the highest-priority channel. Prevents mixing incompatible builds.
- libmamba solver: Dramatically speeds up environment creation and package installation. The default solver can be very slow with complex dependencies.
- conda-forge channel: Community-maintained packages, often more up-to-date than
defaults.
Environment Export
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.
Shared Environments
lab-general — shared environment for general projects
All 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:
- Documentation projects (Quarto books/sites)
- Infrastructure and tooling projects
- Small utility scripts that don't need specialized packages
- Any
project-type: generalproject without complex dependencies
When to create a project-specific env instead:
- The project needs packages that would conflict with or bloat
lab-general - The project has strict reproducibility requirements (pin exact versions)
- Data science projects (always project-specific — see lab policy below)
Identifying 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.
Lab Policy
- Never install into the
baseenvironment — always use a named environment - Data science projects: one environment per project — named to match the project directory
- General projects:
lab-generalby default — use the shared environment unless the project needs specialized dependencies, in which case create a project-specific one - Always include
ipykernel— required for Quarto to execute Python chunks - Prefer
conda installoverpip install— conda resolves dependencies holistically. Use pip only as a fallback for packages not available via conda/conda-forge - Install conda packages before pip packages — if mixing both, conda packages first to avoid conflicts
Shell Environment
- Shell: zsh (macOS default)
- Conda base: Typically
~/miniconda3or~/miniforge3— customize to match your installation
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?