Three steps, every time
Ask before you start another session. The answer comes with its own fix.
- 1
Run it
Type
host-headroom. It reads memory, disk and what is running. It usually takes a few seconds, and it changes nothing. - 2
Read the verdict
The first line is the answer: room for how many, room once you free something, or no room and why.
- 3
Run the printed fix
Each problem comes with the exact command, biggest first. Run the ones you agree with, then ask again.
What it checks
Twelve checks, in two groups: what is using memory right now, and what is filling the disk. Each one can be turned off in the config.
How it decides “room for N”
Memory and disk are worked out the same way: what is left above a safety floor, divided by what one more session costs. The smaller answer wins.
Swipe sideways to see the whole diagram.
- Idle or running its tests
- An idle session costs what a running agent typically holds by itself (the median of the agents running now, 0.8 GB when none are). A session that runs its tests also needs room for the largest test run seen, 3 GB until one has been measured. The verdict gives both: “room for 2 idle sessions, or 1 that runs its tests.”
- Available memory
- What could be handed to a new process right now. On a Mac that is free, speculative and purgeable pages, plus inactive pages only as far as files back them. Memory that can only be compressed or swapped does not count.
- The safety floor
- 15% of memory always stays free. On a Mac whose compressor already holds 20% or more of memory, the floor rises to 25%, and the verdict says memory is heavily compressed.
- Room if you free
- When nothing fits, it adds the biggest fixes from the problem list, one at a time, until one session would fit, and names them. A hard stop is cleared only by its own fix.
- Couldn't check
- If memory or disk cannot be read, the answer is never “room”. Any check that could not run is named at the end of the verdict.
Where it runs
It works out where it is first, then reads what that place really has. Inside a container, that means the container's own limits, not the host's.
| Environment | Memory | Disk | Processes and ports |
|---|---|---|---|
| macOS | vm_stat pages and the compressor, swap from sysctl vm.swapusage, and the system's memory pressure level | The Data volume; floor 20% of it, 2 to 15 GB | ps and lsof; also looks for leftover Chrome copies |
| Linux host | MemAvailable and swap from /proc/meminfo; out-of-memory kills from /proc/vmstat | The root volume; floor 20% of it, 2 to 15 GB | ps and ss, or /proc when either is missing |
| Container | The cgroup limit (memory.max, or the v1 limit) less what is in use, plus file pages it can drop; out-of-memory kills from memory.events | The root volume, 5 GB floor | The same as a Linux host, inside the container |
A container is recognized by /.dockerenv, a container= variable on its first process, or a cgroup memory limit.
Install
Python 3.9 or newer. Nothing else.
With pipx
pipx install git+https://github.com/workingBen/host-headroom
That works once the repository is public. Until then, clone it and run pipx install . from the clone.
As a single file
mkdir -p ~/.local/bin
cp host_headroom.py ~/.local/bin/host-headroom
chmod +x ~/.local/bin/host-headroom
Make sure ~/.local/bin is on your PATH.
Claude Code plugin
/plugin marketplace add workingBen/host-headroom
/plugin install host-headroom@host-headroom
Adds a “check the machine” skill and a session-start warning that stays silent unless something is red.
Worktrunk add-on
wt headroom
wt headroom install-hook
Copy wt-headroom onto your PATH and Worktrunk finds it. install-hook prints a pre-remove hook that refuses to remove a busy worktree.
The promise
Read-only
It never stops a process and never deletes a file. Fixes are printed as commands for you to run. The only things it writes are a small cache in ~/.cache/host-headroom/ and the --html page you ask for.
It never guesses
If a check cannot run, it says “couldn't check” and the verdict names it. It never reports all clear while something is unknown.
Tested on real machines
Known problems are planted on a real machine, host-headroom runs, and each one is graded: named, or not. The misses are published too.
- 72 of 77planted problems named
- 8full runs
- 0false all-clears
macOS and Linux host only, so far. Runs in containers are still to come.
Every run, every plant