Can an AI agent drive UTM?
Claude Code created, booted, snapshotted and deleted a UTM Linux VM from scripts, and tested a limit on a macOS VM. What worked and what took me.
Yes for a throwaway Linux VM, and partly for macOS. Claude Code used UTM in two ways: a macOS 26 VM to settle a question about a password limit, and an Alpine Linux VM that it created, booted, logged in to, snapshotted and deleted with no clicks. The macOS VM needed me for the first boot and setup.
I reach for a VM when a test needs a different OS or a machine that can be thrown away. OrbStack is much quicker when Linux containers are enough.
| Verdict | |
|---|---|
| Create a Linux VM with AppleScript | Works, after two wrong turns |
Start, stop and delete with utmctl | Works |
| Run commands in the guest over a serial port | Works: Alpine |
Snapshot and restore with utmctl | Works: Linux VM |
utmctl exec and ip-address | Didn’t work: this guest has no guest agent |
| Install macOS into a VM by script | Works |
| Start a macOS VM by script | Didn’t work: timed out once, then started from the window |
| Set up macOS inside the VM | Not tried: I clicked through Setup Assistant |
| Report failure through the exit code | Works in utmctl for a missing VM and bad arguments |
| Check its own work | Works: it reads the guest’s output |
| Run unattended | Works with limits: utmctl refuses SSH |
The way in
UTM has two: utmctl, a command inside the app, and an AppleScript dictionary. Creating a VM
takes the dictionary. This is what built the Linux VM, with 512 MB of memory, a 1 GB disk and
a serial port for Claude to type into. Download the
Alpine “virtual” ISO for aarch64 to the current folder first:
osascript - "$PWD/alpine-virt-3.24.3-aarch64.iso" <<'EOF'
on run argv
set iso to POSIX file (item 1 of argv)
tell application "UTM"
make new virtual machine with properties {backend:qemu, configuration:{name:"zz-spike-alpine", architecture:"aarch64", memory:512, cpu cores:2, hypervisor:true, uefi:true, drives:{{removable:true, source:iso}, {guest size:1024}}, network interfaces:{{mode:shared}}, «class SrPt»:{{interface:ptty}}}}
end tell
end run
EOFutmctl handles the rest. It’s inside the app, so give its full path:
UTMCTL=/Applications/UTM.app/Contents/MacOS/utmctl
"$UTMCTL" start zz-spike-alpine
"$UTMCTL" snapshot create zz-spike-alpine --name s1
"$UTMCTL" snapshot restore zz-spike-alpine --snapshot s1
"$UTMCTL" stop zz-spike-alpine
"$UTMCTL" delete zz-spike-alpineDelete doesn’t ask for confirmation. To get into the guest, AppleScript gives the serial port’s
device path, which was /dev/ttys003 here:
osascript -e 'tell application "UTM" to get address of serial ports of virtual machine named "zz-spike-alpine"'A short Python script opened that device, logged in as root, which needs no password on
Alpine’s live ISO, and ran commands. The guest got a network address and downloaded a file over
HTTPS. In the run I timed:
| Step | Time |
|---|---|
| Create the VM | About 2 seconds, in an earlier run |
utmctl start to a login prompt | 15.0 seconds |
utmctl start to the first command’s result | 17.5 seconds |
| Snapshot | 0.7 seconds, 140 MB |
| Restore | 0.7 seconds |
To prove the restore worked, Claude wrote a marker file, took a snapshot, then changed the file. After the restore, the file had its old contents.
A real test: a password limit on macOS 26
Purrchiver’s pages said Apple Encrypted Archive passwords had a 32-character minimum, a number
recorded in May without a boundary test. The Mac in front of Claude ran 27.2, where 20 worked. So
it built a macOS 26.6.2 VM on my Mac mini. While that was being set up, it published that the
minimum had been 32 on macOS 26. Apple’s aa tool in the VM failed at 19 characters and worked at
20, 31 and 32, so that was wrong too.
The full steps and costs are in Run older macOS in a UTM VM. It took a 19.8 GB restore image and a 27 GB VM. Installing macOS by script took about three minutes. I still had to click Allow on the mini, start the VM in UTM’s window, click through Setup Assistant, turn on Remote Login and copy over an SSH key.
What failed
- Running a “read-only” check. A setup check of
utmctl versionandutmctl listlaunched UTM when it wasn’t running. It’s a small side effect here, but the same kind of check on OrbStack started a tunnel. - Two errors building the VM. Writing
POSIX fileinside thetellblock failed (-1728).serial ports:in the record then compiled to the singularserial portand failed (-1700), which is why the script uses the property’s raw code,«class SrPt», from the dictionary. - Guest commands.
utmctl execandip-addressneed the QEMU guest agent, and the Alpine live ISO didn’t have it running. That’s what led to the serial port. - A restore that wasn’t. My first restore command had the wrong arguments and exited 64, and my script carried on. The marker still showed the new contents. The next run had the right flag.
- A boot time that wasn’t. My first measurement said 11.8 seconds. The script had read a
#in Alpine’s progress bar as a shell prompt. The 15.0 seconds above waits for the login prompt. utmctlover SSH. It gave error -1743 and UTM’s note that it doesn’t work from SSH sessions or before logging in.osascriptdid work over SSH once someone had clicked Allow on that Mac.- The macOS VM’s first start.
startby AppleScript timed out (-1712) and the VM stayed stopped. It started from the window, and I don’t know what blocked it.
Can it check its own work?
Yes, more than most tools here. It reads what the guest prints, so a result like uname or the
marker file comes from inside the machine. utmctl exited 1 for a missing VM and 64 for bad
arguments. It can’t see the VM’s screen this way, though, so this only suits a guest with a text
console.
Can it run unattended?
Partly. The Linux run needed no clicks at the laptop, but someone was logged in there. Over SSH, utmctl is out and AppleScript needs that one earlier click. I
haven’t tried a schedule.
Security
- What’s in the guest: the guest is a separate machine, which is the appeal, but it isn’t cut off. On shared networking, this one reached the internet. I didn’t test whether it could reach the host’s services, and I didn’t share any folders with it.
- Destructive commands: UTM’s dictionary says
deleteandinstallerase data with no confirmation.delete snapshotis the same. Name throwaway VMs so a script can’t hit the wrong one. - Automation permission: whatever runs
osascriptneeds permission to control UTM. - Downloads: check what you boot. The Alpine ISO’s SHA-256 matched Alpine’s release list. On the earlier macOS run, I didn’t compare a checksum, as the guide says.
- Passwords: Remote Login in a guest is a way in. Type the VM’s password yourself, not through a script or the agent. Keys work after that.
- The app: my copy has the App Sandbox entitlement. I didn’t test what that limits.
Not tried
utmctl attach,fileandusb- A guest with the QEMU guest agent installed
- Snapshots on the Apple Virtualization backend, which UTM’s docs limit on older macOS
- Installing a Linux guest to its disk, or Windows
- Two VMs talking to each other
- Running on a schedule
Tested on
UTM 5.0.8. The Linux VM ran on an M2 Pro MacBook Pro with 16 GB, macOS 27.2, on November 4, 2026, using Alpine 3.24.3. The macOS 26.6.2 VM ran on a Mac mini with 16 GB, macOS 27.2, on October 30, 2026. I deleted the Linux VM, and the macOS VM went to the Trash on the mini.