Run Claude Code's builds and tests on a spare Mac
Copy the project to the spare Mac with rsync, run the command there with ssh (its exit code comes back), and forward dev server ports with ssh -L. hivemux swarm does this for Claude Code. A hook sends heavy commands like npm test or cargo build to the Mac with room, and the output, exit code and localhost ports come back as if they ran locally.
Three or four Claude Code sessions are cheap on their own. What slows the Mac down is what they run: each one starts npm test, cargo build, a dev server or a Docker compose stack, often at the same moment. Fans spin up, the editor stutters, and builds that took 40 seconds take three minutes. Meanwhile a second Mac at home or at work, an older MacBook or a Mac mini, sits idle. Its cores can take that load.
Why the main Mac bogs down
Claude Code itself spends most of its time waiting for the model, so the sessions are light. The commands they start are not:
- Test runners and compilers use every core they can get, and two sessions running them at once compete for the same cores.
- Each session that runs
npm run devkeeps a dev server and a file watcher alive. - Docker containers hold memory for as long as they run.
- Worktrees multiply
node_modules,targetand build caches, which fills the disk and keeps Spotlight indexing.
Adding sessions adds this load on one machine. A spare Mac adds cores, memory and disk, as long as the commands actually run there.
Doing it by hand with ssh and rsync
Turn on System Settings → General → Sharing → Remote Login on the spare Mac, and set up key login so ssh does not ask for a password. Then copy the project over, leaving out the dependency and build folders so the other Mac keeps its own:
ssh me@spare-mac.local 'mkdir -p ~/build/shop'rsync -az --delete --exclude .git --exclude node_modules --exclude dist \ ./ me@spare-mac.local:build/shop/Run the command there. ssh returns the remote command’s exit code, so a failing test fails here too:
ssh me@spare-mac.local 'cd ~/build/shop && npm ci && npm test'For a dev server, forward its port in the same connection and open http://localhost:5173 on your own Mac:
ssh -L 5173:localhost:5173 me@spare-mac.local 'cd ~/build/shop && npm run dev'This works, and for one long build now and then it is enough. With Claude Code doing the running, the gaps show:
- Syncing. Every run needs a fresh rsync first, or the other Mac tests old code. Claude does not know that unless you put a wrapper script and instructions in CLAUDE.md, and it still runs
npm testlocally when it forgets. - Tools. Node, Rust or Python versions have to match on both Macs. A non-interactive ssh command also skips
~/.zprofile, where Homebrew usually adds itself toPATH, sonpm: command not foundis common. - Paths. Errors name
~/build/shop/...instead of your real folder, so Claude reads paths that do not exist on your Mac. - Ports. Each dev server needs its own
-L, chosen before Claude picks the port. - Which Mac is free. You decide by hand each time. With two spare Macs, or with the main Mac idle, nothing balances the work.
Doing it with hivemux swarm
hivemux swarm automates the steps above for Claude Code. A Claude Code PreToolUse hook sees a heavy Bash command, such as npm test, cargo build or npm run dev, in a project you turned on, and rewrites it to hivemux-swarm run -c '...'. A scheduler on your Mac measures every computer’s cores, memory and disk every 2 seconds, knows how much each job usually takes, and sends it to the Mac with room. Claude reads the same output and exit code it would get locally, and dev server ports open on your Mac’s localhost.
Install it on the main Mac (the master):
brew install hivemux/tap/hivemux-swarmIt works on its own as hivemux-swarm. With hivemux 0.1.105 or later it is also available as hivemux swarm.
Add the spare Mac. On the master:
hivemux-swarm add # prints one line (also on the clipboard) and waitsPaste that line in Terminal on the spare Mac. It lets swarm’s own key in, without touching ~/.ssh on the master, opens Sharing settings if Remote Login is off, asks for the Xcode command line tools if they are missing, and tells the master its address. The master checks the Mac and adds it as a worker. If you already ssh in without a password, hivemux-swarm add me@spare-mac.local works too.
Turn on a project, install the hook, and check:
cd ~/project/shop && hivemux-swarm onhivemux-swarm hook install # Claude sessions started from now on use ithivemux-swarm statusstatus shows every computer’s load, memory, disk, jobs, queue and forwarded ports. Set HIVEMUX_SWARM_VERBOSE=1 to print one line naming the computer for each run.
What stays safe:
- What is sent. Only the files git tracks plus
.env*, over rsync. Putenv = falseunder[files]in the project’s.hivemux-swarm.tomlto keep.env*files on the master.node_modules,targetand.venvare never copied; dependencies are installed on the worker when the lock file changes. - The worker’s own files. Never touched. Copies live under
~/hivemux-swarm.noindex/, a folder Spotlight does not index, and copies unused for 14 days are removed. - Permissions. Not widened. The hook says allow only when your rules allowed the original command; otherwise Claude Code asks as usual. A command your deny rules match is never rewritten.
- One command local. Prefix it with
HIVEMUX_SWARM=0. - Room on the master. The master runs jobs too, but keeps 2 cores and 4 GB of memory for Claude and you.
- A worker drops. Tests and builds that were running there start again on another computer by themselves. If the scheduler itself is stuck, commands run on the master as if swarm were not installed.
Docker jobs, tools missing on a worker, and project settings are covered in the hivemux swarm docs.
Comparison
| ssh + rsync by hand | hivemux swarm | |
|---|---|---|
| Getting the code there | rsync before every run | Synced before each run (git-tracked files plus .env*) |
| What Claude runs | A wrapper you tell it to use | The usual command; the hook rewrites it |
| Choosing the Mac | You, each time | The scheduler, by free cores, memory and disk |
| Tools on the other Mac | Installed and kept in step by you | Installed the way they are on the master |
| Paths in output | The other Mac’s paths | Mapped back to the master’s |
| Dev server ports | One ssh -L each, chosen in advance |
Open on the master’s localhost |
| Other Mac goes away | The command fails | Tests and builds rerun elsewhere |
| Setup on the other Mac | Remote Login, keys, every tool | Remote Login and one pasted line |
For running the sessions themselves side by side, see How to run multiple Claude Code sessions at once. For dev servers on a remote Mac in general, see Open a remote Mac’s dev server on your laptop’s localhost, and for how PreToolUse and other hooks work, Claude Code hooks in practice.
FAQ
Does the spare Mac need anything installed?
For hivemux swarm, only Remote Login turned on. The line that hivemux-swarm add prints sets up swarm's own key and asks for the Xcode command line tools if they are missing; a small agent is sent over ssh on connect. Tools a project needs are installed on the worker the way they are installed on your main Mac.
Will my files on the spare Mac be touched?
No. Copies live under ~/hivemux-swarm.noindex on the worker, away from its own folders, and Spotlight skips them. The worker's own files are never touched, and copies unused for 14 days are removed.
What is sent to the other Mac?
The files git tracks plus .env* files, over rsync. Put env = false under [files] in the project's .hivemux-swarm.toml to keep .env* files on your Mac. node_modules, target, .venv and the like are never copied; each Mac installs its own.
Does the hook skip Claude Code's permission prompts?
No. It says allow only when your rules allowed the original command; otherwise Claude Code asks as usual, showing the wrapped command. A command your deny rules match is never rewritten.
How do I keep one command on my own Mac?
Prefix it with HIVEMUX_SWARM=0. To keep a command local for a whole project, list it under remove in [commands] in .hivemux-swarm.toml.
What happens if the spare Mac sleeps or drops off the network?
Tests and builds that were running on it start again on another computer by themselves. Dev servers report that the worker went away. If the command itself failed, it is not rerun.