Awesome-omni-skill conda-env-setup
This skill should be used when the user asks to "setup conda environment", "configure Python environment", "activate conda automatically", "set conda environment for workspace", or mentions conda environment activation for Claude Code. Provides automatic conda environment configuration for workspaces.
git clone https://github.com/diegosouzapw/awesome-omni-skill
T=$(mktemp -d) && git clone --depth=1 https://github.com/diegosouzapw/awesome-omni-skill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/development/conda-env-setup" ~/.claude/skills/diegosouzapw-awesome-omni-skill-conda-env-setup && rm -rf "$T"
skills/development/conda-env-setup/SKILL.mdConda Environment Setup Skill
Automatically configure conda environments for Claude Code workspaces using environment variables instead of shell activation.
Purpose
Conda environments cannot be activated through standard
conda activate in Claude Code's bash sessions because each command runs in a new, non-interactive shell. This skill provides an alternative approach using workspace-level environment variables to make Python interpreters and packages available without shell activation.
When to Use
Invoke this skill when:
- User requests conda environment activation for a workspace
- Python commands fail due to missing packages or wrong interpreter
- User mentions "activate conda", "setup Python environment", or similar
- Workspace needs specific conda environment for development
Core Concept
Instead of activating conda environments with
conda activate (which requires interactive shells), configure the workspace's .claude/settings.json to prioritize the conda environment's paths in the PATH environment variable.
This works because:
- Shell commands look up executables using PATH
- First match in PATH gets used
- No shell initialization required
Setup Process
Step 1: Gather Environment Information
Identify the conda installation and environment details:
# Locate conda installation which conda # List all environments conda env list # Find environment path conda env list | grep "env_name"
Typical conda installation locations:
- Windows:
orC:\ProgramData\anaconda3C:\Users\<username>\anaconda3 - Linux/macOS:
or/home/<username>/anaconda3/opt/anaconda3
Environment paths typically follow:
<conda_base>/envs/<env_name>- Example:
C:\ProgramData\anaconda3\envs\hrms-algo
Step 2: Create or Update Workspace Configuration
Check if workspace already has configuration:
# Check for existing config cat .claude/settings.json
If
.claude/settings.json exists, update it. If not, create it with the following template:
{ "env": { "PATH": "<env_path>:<env_path>/Scripts:<conda_base>/condabin:${PATH}", "CONDA_DEFAULT_ENV": "<env_name>", "CONDA_PREFIX": "<env_path>", "PYTHONPATH": "<env_path>/Lib/site-packages:${PYTHONPATH}" } }
Windows path format for Git Bash:
- Replace backslashes with forward slashes
- Use drive letter format:
/c/Program Files/anaconda3 - Example:
/c/ProgramData/anaconda3/envs/hrms-algo
Linux/macOS path format:
- Use standard Unix paths
- Example:
/home/user/anaconda3/envs/hrms-algo
Step 3: Verify Configuration
Test the configuration:
# Check environment variables echo $CONDA_DEFAULT_ENV echo $CONDA_PREFIX # Verify Python interpreter which python python -c "import sys; print(sys.executable)" # Verify package availability python -c "import <package_name>; print(<package_name>.__version__)"
Expected results:
should show the environment nameCONDA_DEFAULT_ENV
should point to the conda environmentwhich python- Package imports should work without errors
Troubleshooting
Python Not Found in Environment
If
which python doesn't show the conda environment:
- Verify PATH entries are correct
- Check for path syntax errors (Windows: use forward slashes)
- Ensure
is valid JSON.claude/settings.json - Restart Claude Code to reload configuration
Packages Not Found
If packages are missing:
- Verify PYTHONPATH includes the environment's site-packages
- Check that packages are actually installed in the conda environment:
/path/to/conda/envs/env_name/python -m pip list - Install missing packages if needed
Configuration Not Applied
If environment variables don't appear to be set:
- Confirm
is in the workspace root.claude/settings.json - Validate JSON syntax (no trailing commas, proper quotes)
- Check for conflicting global settings in
~/.claude/settings.json - Restart Claude Code session
Additional Resources
Validation Script
Use the bundled validation script to verify setup:
# Run validation python .claude/skills/conda-env-setup/scripts/validate_env.py
Reference Documentation
- Windows path conversion guide for Git Bashreferences/windows-paths.md
- Detailed environment variable referencereferences/environment-variables.md
- Working configuration examplesexamples/example-config.json
Quick Reference
Environment Variable Template
{ "env": { "PATH": "<env_path>:<env_path>/Scripts:<conda_base>/condabin:${PATH}", "CONDA_DEFAULT_ENV": "<env_name>", "CONDA_PREFIX": "<env_path>" } }
Common Path Formats
Windows (Git Bash):
/c/ProgramData/anaconda3/envs/myenv /d/Program Files/anaconda3/envs/myenv
Linux/macOS:
/home/user/anaconda3/envs/myenv /opt/anaconda3/envs/myenv
Validation Commands
echo $CONDA_DEFAULT_ENV # Should show env name which python # Should show env python python -c "import sys; print(sys.executable)" # Full path
Why This Works
Problem:
conda activate requires interactive shell with initialization
Solution: Set PATH to prioritize conda environment executables
Benefits:
- No shell initialization needed
- Works across platforms
- Persistent across commands
- No subprocess overhead