Implements orchestration on macOS and provisioning on Linux for isolated Claude Code environments Adds interactive component selection with visual menu interface Enables secure VM creation with disabled host filesystem access Provides comprehensive toolchain including PostgreSQL, Erlang/Elixir, and browser automation Configures VNC desktop access for OAuth workflows and browser-based tasks
4.1 KiB
4.1 KiB
CLAUDE.md
Project Overview
This repository contains a dual-mode setup script for creating OrbStack-based development sandboxes tailored for Claude Code with Elixir/Erlang, browser automation, and PostgreSQL.
Repository Structure
setup_env.sh - Main script (macOS host mode + Linux VM provisioning mode)
config.env.example - Example credentials file
config.env - User credentials (gitignored, created on first run)
.gitignore - Ignores config.env
README.md - User-facing documentation
CLAUDE.md - This file (context for Claude Code sessions)
How the Script Works
The script has two modes, detected via uname -s:
- Darwin (macOS): Orchestrator mode. Checks for OrbStack, reads/creates
config.env, creates a VM, copies itself in, runs itself inside the VM with--non-interactive. - Linux (VM): Provisioning mode. Installs all tools, configures PostgreSQL, sets up VNC, installs Claude Code plugins.
This means ./setup_env.sh my-vm on macOS does everything end-to-end.
Key Technical Details
- Target environment: OrbStack Ubuntu VM on macOS Apple Silicon (ARM64)
- Version manager: mise (manages Node.js, Erlang, Elixir)
- Language versions: Configured at the top of
setup_env.shas variables (ERLANG_VERSION,ELIXIR_VERSION) - PostgreSQL auth: Peer for local socket, trust for localhost TCP (127.0.0.1), scram-sha-256 for host network (192.168.0.0/16)
- Browser: Chromium (no Chrome ARM64 Linux builds exist), symlinked to
google-chrome - VNC: TigerVNC + XFCE on display :1 (port 5901), controlled via
vnc-start/vnc-stophelpers in~/bin - Shared credentials:
config.envis created once and reused for all VMs
Working on This Project
Editing setup_env.sh
- The macOS host-mode block is at the top (inside the
if [[ "$(uname -s)" == "Darwin" ]]block) - The Linux VM-mode block is everything after that conditional
- Version numbers are defined as variables at the top (
ERLANG_VERSION,ELIXIR_VERSION) - All installation steps must be idempotent (safe to run multiple times)
- Use
log_info,log_warn,log_errorhelpers for output - New apt packages go in the base dependencies section
- New Claude plugins go in the appropriate array (
ANTHROPIC_PLUGINSorSUPERPOWERS_PLUGINS) - Redirect verbose output to
$LOG_FILE, show only meaningful progress to the user - The
LOG_FILEvariable is only set in VM mode (not available in macOS host mode) - Each optional component is wrapped in
prompt_install "Name" "Description"— this handles both interactive prompts and--yes/--non-interactiveauto-accept - Track dependency flags (
INSTALLED_NODE,INSTALLED_CHROMIUM) to skip dependent components gracefully
Script Conventions
set -euo pipefailis enforced - handle potential failures with|| trueor explicit checks- Use
command_existsto check for already-installed tools - Use
apt-get(notapt) for scripting reliability - Quote all variable expansions
- Use
findfor PostgreSQL config paths (version-agnostic) - The
--non-interactiveflag is for VM mode (implies--yes); macOS mode always uses config.env --yes/-yaccepts all components without prompting but still allows interactive credential entryMISE_GLOBAL_CONFIG_FILEandMISE_CONFIG_DIRare set to prevent OrbStack host-mount config pollution
Testing
There are no automated tests. To test changes:
- Remove an existing test VM:
orb delete test-sandbox - Run:
./setup_env.sh test-sandbox - Verify provisioning completes
- Run again to verify idempotency:
ssh test-sandbox@orb -- bash /tmp/setup_env.sh --non-interactive(will need env vars) - Test VNC:
ssh test-sandbox@orb -- vnc-start, thenopen vnc://test-sandbox.orb.local:5901 - Clean up:
orb delete test-sandbox
Security Considerations
config.envis chmod 600 and gitignored- PostgreSQL remote access uses scram-sha-256 (not trust)
- The script refuses to run as root inside the VM
- VNC password is required (min 6 chars)
- VNC binds to all interfaces (
-localhost no) to allow connections from the macOS host — this is intentional for the OrbStack use case