Merge pull request #1 from sylvinus/claude/forward-vm-arguments-EeIOt
Forward arguments from claude-vm to the underlying claude command
- 作者
- Sylvain Zimmer
- 时间
- 2026/01/29 16:13
- 提交
- 180c575
这是一个合并提交,下面是和第一个上一提交相比的改动。
Forward arguments from claude-vm to the underlying claude command
这是一个合并提交,下面是和第一个上一提交相比的改动。
| @@ -44,6 +44,14 @@ claude-vm | ||
| 44 | 44 | |
| 45 | 45 | Clones the template into a fresh VM, mounts your current directory, and runs `claude --dangerously-skip-permissions`. The VM is deleted when Claude exits. |
| 46 | 46 | |
| 47 | 新增:Any arguments passed to `claude-vm` are forwarded to the `claude` command: | |
| 48 | 新增: | |
| 49 | 新增:```bash | |
| 50 | 新增:claude-vm -p "fix all lint errors" # Run with a prompt | |
| 51 | 新增:claude-vm --resume # Resume previous session | |
| 52 | 新增:claude-vm -c "explain this codebase" # Continue conversation | |
| 53 | 新增:``` | |
| 54 | 新增: | |
| 47 | 55 | ### Debug shell |
| 48 | 56 | |
| 49 | 57 | ```bash |
| @@ -77,7 +85,7 @@ docker compose up -d | ||
| 77 | 85 | ## How it works |
| 78 | 86 | |
| 79 | 87 | 1. **`claude-vm-setup`** creates a Debian 13 VM with Lima, installs dev tools + Chrome + Claude Code, and stops it as a reusable template |
| 80 | 删除:2. **`claude-vm`** clones the template, mounts your working directory read-write, runs optional `.claude-vm.runtime.sh`, then launches Claude with full permissions | |
| 88 | 新增:2. **`claude-vm [args]`** clones the template, mounts your working directory read-write, runs optional `.claude-vm.runtime.sh`, then launches Claude with full permissions (forwarding any arguments to the `claude` command) | |
| 81 | 89 | 3. On exit, the cloned VM is stopped and deleted. The template persists for reuse |
| 82 | 90 | |
| 83 | 91 | Ports opened inside the VM (e.g. by Docker containers) are automatically forwarded to your host by Lima. |
| @@ -8,7 +8,7 @@ | ||
| 8 | 8 | # |
| 9 | 9 | # Functions: |
| 10 | 10 | # claude-vm-setup - Create the VM template (run once) |
| 11 | 删除:# claude-vm - Run Claude in a fresh VM with cwd mounted | |
| 11 | 新增:# claude-vm [args] - Run Claude in a fresh VM with cwd mounted (args forwarded to claude) | |
| 12 | 12 | # claude-vm-shell - Open a debug shell in a fresh VM |
| 13 | 13 | |
| 14 | 14 | CLAUDE_VM_TEMPLATE="claude-template" |
| @@ -111,6 +111,7 @@ VMEOF | ||
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | claude-vm() { |
| 114 | 新增: local args=("$@") | |
| 114 | 115 | local vm_name="claude-$(basename "$(pwd)" | tr -cs 'a-zA-Z0-9' '-' | sed 's/^-//;s/-$//')-$$" |
| 115 | 116 | local host_dir="$(pwd)" |
| 116 | 117 | |
| @@ -139,7 +140,7 @@ claude-vm() { | ||
| 139 | 140 | limactl shell --workdir "$host_dir" "$vm_name" bash -l < "${host_dir}/.claude-vm.runtime.sh" |
| 140 | 141 | fi |
| 141 | 142 | |
| 142 | 删除: limactl shell --workdir "$host_dir" "$vm_name" claude --dangerously-skip-permissions | |
| 143 | 新增: limactl shell --workdir "$host_dir" "$vm_name" claude --dangerously-skip-permissions "${args[@]}" | |
| 143 | 144 | |
| 144 | 145 | _claude_vm_cleanup |
| 145 | 146 | trap - EXIT INT TERM |