From a53d28bf2fb8d1ad41f5a537f3ba1c3f2128bdac Mon Sep 17 00:00:00 2001 From: Vishal Jain Date: Wed, 18 Jun 2025 00:21:01 +0100 Subject: [PATCH] Add comprehensive conda integration for academic environments Enhanced conda support to handle custom environment and package directories: Key Changes: - Mount conda installation at original path (not /opt/miniconda3) - Add CONDA_EXTRA_DIRS for mounting additional search paths - Mount all conda-configured directories to preserve existing setup - Update CLAUDE.md to use ${CONDA_EXE} environment variable Technical Details: - Preserves original conda paths so existing configuration works - Handles multiple envs_dirs and pkgs_dirs automatically - Provides feedback about which directories are mounted - Falls back gracefully for missing directories Example usage: CONDA_EXTRA_DIRS="/vol/path/.conda/envs /vol/path/conda_envs /vol/path/.conda/pkgs" Result: All conda environments and packages accessible in container. --- .env.example | 9 ++++++++- scripts/claude-docker.sh | 34 +++++++++++++++++++++++++++++++++ templates/.claude/CLAUDE.md | 38 +++++++++++++++++++++++++++++-------- 3 files changed, 72 insertions(+), 9 deletions(-) diff --git a/.env.example b/.env.example index cc2f44d..e867fcb 100644 --- a/.env.example +++ b/.env.example @@ -8,4 +8,11 @@ ANTHROPIC_API_KEY=your_anthropic_api_key_here TWILIO_ACCOUNT_SID=your_twilio_account_sid TWILIO_AUTH_TOKEN=your_twilio_auth_token TWILIO_FROM_NUMBER=+1234567890 -TWILIO_TO_NUMBER=+0987654321 \ No newline at end of file +TWILIO_TO_NUMBER=+0987654321 + +# Optional: Custom conda installation (for academic/lab environments) +# Example: CONDA_PREFIX=/vol/biomedic3/username/miniconda3 +CONDA_PREFIX= +# Optional: Additional conda directories (space-separated list) +# Example: CONDA_EXTRA_DIRS="/vol/biomedic3/username/.conda/envs /vol/biomedic3/username/conda_envs /vol/biomedic3/username/.conda/pkgs /vol/biomedic3/username/conda_pkgs /homes/username/.conda/envs" +CONDA_EXTRA_DIRS= \ No newline at end of file diff --git a/scripts/claude-docker.sh b/scripts/claude-docker.sh index cec77c4..d9f0487 100755 --- a/scripts/claude-docker.sh +++ b/scripts/claude-docker.sh @@ -28,6 +28,10 @@ fi ENV_FILE="$PROJECT_ROOT/.env" if [ -f "$ENV_FILE" ]; then echo "✓ Found .env file with credentials" + # Source .env to get configuration variables + set -a + source "$ENV_FILE" 2>/dev/null || true + set +a else echo "⚠️ No .env file found at $ENV_FILE" echo " Twilio MCP features will be unavailable." @@ -61,11 +65,41 @@ fi # Ensure the claude-home directory exists mkdir -p "$HOME/.claude-docker/claude-home" +# Prepare additional mount arguments +MOUNT_ARGS="" +ENV_ARGS="" + +# Mount conda installation if specified +if [ -n "$CONDA_PREFIX" ] && [ -d "$CONDA_PREFIX" ]; then + echo "✓ Mounting conda installation from $CONDA_PREFIX" + MOUNT_ARGS="$MOUNT_ARGS -v $CONDA_PREFIX:$CONDA_PREFIX:ro" + ENV_ARGS="$ENV_ARGS -e CONDA_PREFIX=$CONDA_PREFIX -e CONDA_EXE=$CONDA_PREFIX/bin/conda" +else + echo "No conda installation configured" +fi + +# Mount additional conda directories if specified +if [ -n "$CONDA_EXTRA_DIRS" ]; then + echo "✓ Mounting additional conda directories..." + for dir in $CONDA_EXTRA_DIRS; do + if [ -d "$dir" ]; then + echo " - Mounting $dir" + MOUNT_ARGS="$MOUNT_ARGS -v $dir:$dir:ro" + else + echo " - Skipping $dir (not found)" + fi + done +else + echo "No additional conda directories configured" +fi + # Run Claude Code in Docker echo "Starting Claude Code in Docker..." docker run -it --rm \ -v "$CURRENT_DIR:/workspace" \ -v "$HOME/.claude-docker/claude-home:/home/claude-user/.claude:rw" \ + $MOUNT_ARGS \ + $ENV_ARGS \ --workdir /workspace \ --name claude-docker-session \ claude-docker:latest "$@" \ No newline at end of file diff --git a/templates/.claude/CLAUDE.md b/templates/.claude/CLAUDE.md index 2cb0542..1d23816 100644 --- a/templates/.claude/CLAUDE.md +++ b/templates/.claude/CLAUDE.md @@ -9,10 +9,14 @@ This is a containerized Claude Code environment with full autonomous permissions - Update it throughout your work to track progress - Use it to maintain context between sessions -2. **Task Completion Notifications**: When you complete a major task: - - Send an SMS notification using the Twilio MCP server - - Format: "✅ Task complete | Task: [brief description] | Done: [what was accomplished]" - - Keep it concise - just the essentials +2. **Task Completion Notifications**: ALWAYS send SMS when you complete significant work: + - **When to notify**: After completing any substantial task, debugging session, or reaching a milestone + - **How to send**: Use `twilio__send_text` command with the message + - **Message format**: "✅ [PROJECT] | [TASK] | [RESULT]" + - **Examples**: + - "✅ MyApp | Bug fix complete | Fixed login validation issue" + - "✅ Website | Feature added | User dashboard now responsive" + - "✅ API | Tests passing | All 15 unit tests now green" 3. **Working Environment**: You have full permissions to: - Execute any bash commands @@ -20,9 +24,27 @@ This is a containerized Claude Code environment with full autonomous permissions - Access web resources - Manage the project autonomously -## MCP Server Available -- Twilio MCP server is running and available for SMS notifications -- Use natural language to send SMS messages -- Example: "Send SMS to notify that the task is complete" +## Available Tools +- **Twilio SMS**: `twilio__send_text` command available for notifications +- **Full Bash Access**: All commands available with --dangerously-skip-permissions +- **Context Persistence**: Use scratchpad.md for session memory +- **Python/Conda**: Custom conda installation mounted (if configured) + +## Python/Conda Environment +- When running Python commands or managing conda environments, use the mounted conda binary (if available) or fall back to system `conda` +- ALWAYS use this exact format when running scripts in conda environments: +```bash +${CONDA_EXE:-conda} run --live-stream -n ENVIRONMENT_NAME python -u your_script.py [args] +``` +- ALWAYS ensure the --live-stream and -u flags are enabled for real-time output and logs +- Check available environments: `${CONDA_EXE:-conda} env list` +- The conda installation preserves original paths so your existing environments and packages are accessible + +## SMS Notification Examples +``` +twilio__send_text "✅ Docker Setup | Authentication fixed | Zero-friction login now working" +twilio__send_text "✅ Bug Hunt | Memory leak resolved | App now stable under load" +twilio__send_text "✅ Deployment | Production ready | Tests pass, security reviewed" +``` Remember: You're working in a safe containerized environment, so you can operate with full autonomy. \ No newline at end of file