This guide covers all Claude VM commands with detailed examples.
- Setup
- Run Claude
- Shell Access
- Project Information
- Configuration Management
- Worktree Management
- Template Management
- Updates
- Global Options
Create a template VM for your project with the tools you need.
# Minimal setup with git configuration
claude-vm setup --git
# With Docker support
claude-vm setup --git --docker
# With Node.js
claude-vm setup --git --node
# With Python
claude-vm setup --git --python# Install everything
claude-vm setup --allThis installs:
- Docker Engine + Docker Compose
- Node.js (LTS) + npm
- Python 3 + pip
- Chromium + Chrome DevTools MCP
- GPG agent forwarding
- GitHub CLI
- Git identity configuration
--git- Configure git identity and signing--docker- Docker Engine + Docker Compose--node- Node.js (LTS) + npm--python- Python 3 + pip--chromium- Chromium browser + debugging tools--gpg- GPG agent forwarding for signing--gh- GitHub CLI + authentication--all- Install all tools
Run additional setup scripts during template creation:
claude-vm setup --git --setup-script ./my-setup.shCustomize VM resources:
# Set disk, memory, and CPUs
claude-vm setup --disk 30 --memory 16 --cpus 4 --git --node
# Use environment variables
CLAUDE_VM_DISK=30 CLAUDE_VM_MEMORY=16 CLAUDE_VM_CPUS=4 claude-vm setup --gitMount directories only during setup (for copying files):
# Mount binaries during setup
claude-vm setup --mount ~/local-tools:/tmp/tools --git
# Use in setup script (.claude-vm.setup.sh):
# cp /tmp/tools/my-tool /usr/local/bin/See Custom Mounts for more details.
Run Claude in an isolated VM. The VM is automatically created from your template and destroyed when Claude exits.
Both invocation patterns work identically:
claude-vm "help me code" # Shorthand
claude-vm agent "help me code" # Explicit agent commandThe shorthand form automatically routes to the agent command. All examples below use the shorthand form — you can always prefix with agent for the same result.
# Start Claude interactively
claude-vm
# Run with a prompt
claude-vm "help me understand this code"
# Multiple-word prompts
claude-vm "analyze the database schema and suggest improvements"If no template exists, Claude VM can create one automatically:
# With prompt
claude-vm --auto-setup "help me code"
# Or enable permanently in config
[defaults]
auto_setup = true# Set individual variables
claude-vm --env API_KEY=secret --env DEBUG=true
# Load from file
claude-vm --env-file .env
# Inherit from host
claude-vm --inherit-env PATH --inherit-env USER
# Combine multiple sources
claude-vm --env-file .env --env API_KEY=override --inherit-env USER# Mount additional directories
claude-vm --mount ~/datasets:/data:ro "analyze this dataset"
# Multiple mounts
claude-vm --mount ~/data1 --mount ~/data2:ro "process the data"Forward your SSH agent for git operations:
# Enable SSH agent forwarding
claude-vm -A "git push to remote"
# Or use long form
claude-vm --forward-ssh-agent# Disable conversation history mounting
claude-vm --no-conversations
# Verbose output (show Lima logs)
claude-vm --verbose "help me debug"
# Custom runtime scripts
claude-vm --runtime-script ./setup-env.shOpen an interactive shell or execute commands in an ephemeral VM.
Shell also supports the explicit command form: claude-vm shell [flags] [args].
# Open bash shell in VM
claude-vm shellOnce in the shell, you have full access to:
- Your project directory (mounted)
- All installed tools (docker, node, etc.)
- Git repository (if in worktree, main repo is also mounted)
# Run tests
claude-vm shell npm test
# Check git status
claude-vm shell git status
# Run docker compose
claude-vm shell docker-compose up -d
# Execute arbitrary commands
claude-vm shell "npm install && npm test"# Set environment for command
claude-vm --env NODE_ENV=test shell npm test
# Load from file
claude-vm --env-file .env.test shell npm start
# Inherit from host
claude-vm --inherit-env PATH shell which node# Mount additional data
claude-vm --mount ~/datasets:/data shell python process.py
# Multiple mounts
claude-vm --mount /data1 --mount /data2:ro shell ./analyze.shDisplay information about the current project's template.
claude-vm infoOutput includes:
- Project path and calculated template name
- Template status (running, stopped, not created)
- VM configuration (disk, memory)
- Enabled capabilities (docker, node, etc.)
- Configured mounts
- Runtime scripts
Example output:
Project: /Users/me/my-project
Template: claude-tpl_my-project_abc123de
Status: stopped
Configuration:
Disk: 20 GB
Memory: 8 GB
Capabilities: docker, node, git
Mounts:
/Users/me/my-project -> /Users/me/my-project (writable)
Runtime Scripts:
./.claude-vm.runtime.sh
Manage and validate configuration files.
Check configuration files for errors:
# Validate current project config
claude-vm config validateThis checks:
- TOML syntax
- Valid value ranges (disk: 1-1000, memory: 1-64)
- Required fields
- Type correctness
Display the final merged configuration:
# Show complete configuration
claude-vm config showThis shows the result after applying precedence:
- Command-line flags
- Environment variables
- Project config (
./.claude-vm.toml) - Global config (
~/.claude-vm.toml) - Built-in defaults
Example output:
[vm]
disk = 30 # From project config
memory = 16 # From CLI flag
[tools]
docker = true # From global config
node = true # From project config
[defaults]
auto_setup = false # Built-in defaultManage git worktrees for parallel branch development. See Git Integration for comprehensive worktree documentation.
Create a new worktree with a branch name:
# Create from current branch
claude-vm worktree create feature-branch
# Create from specific base branch
claude-vm worktree create feature-branch mainThe system automatically:
- Creates the worktree directory
- Checks out the branch
- Uses configurable path templates for organization
The --worktree flag on agent and shell commands provides one-command worktree creation:
# Create/resume worktree and run agent
claude-vm agent --worktree feature-branch
# Specify base branch
claude-vm agent --worktree feature-branch main
# Open shell in worktree
claude-vm shell --worktree feature-branch
# Use -- to separate worktree args from Claude/shell args
claude-vm agent --worktree feature-branch -- /clear
claude-vm shell --worktree feature-branch -- ls -laThe system will:
- Resume existing worktree if branch is already checked out
- Create new worktree if branch exists but not checked out
- Provide clear messaging about resume vs create behavior
Show all worktrees with branch, path, and status:
# List all worktrees
claude-vm worktree listExample output:
+ main /Users/me/project
feature-1 /Users/me/project-worktrees/project-feature-1
bugfix /Users/me/project-worktrees/project-bugfix
The + indicates the main repository.
Remove worktree directories while preserving branches. The remove command supports two modes:
Remove one or more worktrees by name:
# Remove single worktree
claude-vm worktree remove feature-branch
# Remove multiple worktrees
claude-vm worktree remove feature-1 feature-2 feature-3
# Use short alias
claude-vm worktree rm feature-branch
# Skip confirmation prompt
claude-vm worktree remove feature-branch --yes
# Preview what would be removed (dry-run)
claude-vm worktree remove feature-branch --dry-runAutomatically remove worktrees for branches that have been merged:
# Remove worktrees merged into current branch
claude-vm worktree remove --merged
# Remove worktrees merged into specific branch (supports local and remote)
claude-vm worktree remove --merged main
claude-vm worktree remove --merged origin/main
# Include locked worktrees
claude-vm worktree remove --merged main --locked
# Preview merged worktrees (dry-run)
claude-vm worktree remove --merged --dry-run
# Skip confirmation
claude-vm worktree remove --merged --yesNotes:
- Only removes the worktree directory; branches are preserved
- Best-effort deletion: continues on failures
- When using
--mergedwithout a branch, uses the current branch - Supports both local branches (e.g.,
main) and remote branches (e.g.,origin/main) - Locked worktrees are excluded by default (use
--lockedto include them)
Configure worktree behavior in .claude-vm.toml:
[worktree]
# Default location for worktrees
location = "/path/to/worktrees" # Default: {repo_root}-worktrees/
# Path template for worktree directories
path_template = "{repo}-{branch}" # Default templateAvailable template variables:
{repo}- Repository name{branch}- Branch name (sanitized)
- Automatic git worktree pruning: Orphaned metadata cleaned before operations
- Locked worktree detection: Clear errors with unlock instructions
- Submodule warnings: Alerts when operating on repositories with submodules
- Git version validation: Ensures git 2.5+ for worktree support
Manage VM templates for your projects.
# List all templates
claude-vm listExample output:
claude-tpl_project1_abc123de (stopped)
claude-tpl_project2_def456ab (running)
claude-tpl_test_789xyz01 (stopped)
# Show disk usage
claude-vm list --disk-usageExample output:
claude-tpl_project1_abc123de (stopped) - 5.2 GB
claude-tpl_project2_def456ab (running) - 12.8 GB
claude-tpl_test_789xyz01 (stopped) - 3.1 GB
Find templates not accessed in 30+ days:
# Show only unused templates
claude-vm list --unusedUseful for cleaning up old project templates.
Remove the template for the current project:
# Clean with confirmation prompt
claude-vm clean
# Clean without prompt
claude-vm clean --yesThis removes the template VM and frees up disk space. The template can be recreated with claude-vm setup.
Remove all Claude VM templates:
# Clean all with confirmation
claude-vm clean-all
# Clean all without prompt
claude-vm clean-all --yesWarning: This removes templates for all projects. You'll need to run claude-vm setup in each project to recreate them.
Check for and install updates to Claude VM.
# Check if updates are available
claude-vm update --checkExample output:
Current version: 0.3.0
Latest version: 0.4.0
Update available!
# Update to latest version
claude-vm updateThis will:
- Download the latest release from GitHub
- Verify the download
- Replace the current binary
- Verify the new version
# Install specific version
claude-vm update --version 0.4.0Updates are downloaded from GitHub Releases.
Runtime flags are available on the agent, shell, and setup commands. They are not shown on commands that don't use them (like list or clean).
Both invocation patterns accept the same flags:
claude-vm --disk 30 "help me code"
claude-vm agent --disk 30 "help me code"# Set disk size (GB)
--disk 30
# Set memory size (GB)
--memory 16
# Set number of CPUs
--cpus 4
# Example
claude-vm --disk 30 --memory 16 --cpus 4 setup --git# Set variable
--env KEY=value
# Load from file
--env-file .env
# Inherit from host
--inherit-env VAR
# Example
claude-vm --env API_KEY=secret --env-file .env --inherit-env USER shell# Mount directory (writable)
--mount /host/path
# Mount with custom VM path
--mount /host/path:/vm/path
# Mount read-only
--mount /host/path:/vm/path:ro
# Example
claude-vm --mount ~/data:/data:ro shell# Execute script before main command
--runtime-script ./setup.sh
# Multiple scripts
--runtime-script ./script1.sh --runtime-script ./script2.sh
# Example
claude-vm --runtime-script ./start-services.sh shell# Forward SSH agent
-A, --forward-ssh-agent
# Example
claude-vm -A "git push"# Verbose output (show Lima logs)
--verbose
# Don't mount conversation history
--no-conversations
# Auto-create template if missing
--auto-setup
# Example
claude-vm --verbose --auto-setup "help me"# Create template with all tools
claude-vm setup --all
# Run Claude with environment
claude-vm --env-file .env "help me implement the API"
# Test in isolated environment
claude-vm shell npm test
# Check project info
claude-vm info# Run tests in clean VM
claude-vm --auto-setup shell npm test
# Build and test
claude-vm shell "npm install && npm run build && npm test"
# Cleanup after
claude-vm clean --yes# Setup with Python
claude-vm setup --python
# Mount dataset and analyze
claude-vm --mount ~/datasets:/data:ro "help me analyze the data in /data"
# Run analysis script
claude-vm shell python analyze.py# Setup with Docker and Node.js
claude-vm setup --docker --node --git
# Start services and run tests
claude-vm --runtime-script ./start-services.sh shell npm test
# Run with SSH forwarding for git push
claude-vm -A "implement feature and push to remote"- Configuration - Configure VM settings, tools, and scripts
- Runtime Scripts - Automate environment setup
- Agent Forwarding - Configure GPG, SSH, and Git
- Troubleshooting - Debug common issues