A queue for parallel coding agents
calmrun is a machine-wide queue for tests, type checks, builds and docker. Put calmrun -- in front of a heavy
command and it waits until the machine has room, then runs it at low CPU priority and passes its exit code back. Several coding
agents and terminals can share one computer without freezing it.
# macOS / Linux $ curl --proto '=https' --tlsv1.2 -LsSf https://github.com/vannt-dev/calmrun/releases/latest/download/calmrun-installer.sh | sh # Windows (PowerShell) > powershell -ExecutionPolicy Bypass -c "irm https://github.com/vannt-dev/calmrun/releases/latest/download/calmrun-installer.ps1 | iex" $ calmrun -- npx vitest run calmrun: waiting — 4 of 6 points in use, 2nd in line (needs 2); running: npx vitest in web (3m10s), cargo build in api (1m02s)
One test run is fine. Four agents that each start vitest with a worker per core, plus a tsc and a build,
are not: they all start in the same minute, and nobody is in charge of the machine.
Each agent decides on its own to run the tests, the type check and the build. None of them knows the others are doing the same.
RAM runs out and the system swaps. The editor, the terminal and the agents themselves stop responding.
Starved runs fail on timeouts that have nothing to do with the code. Agents retry, which adds even more load.
Every calmrun process adds its job to a small state file guarded by an OS file lock, and every waiter applies the
same rules to it. There is no daemon to start or keep alive.
calmrun doctor shows the
numbers for your machine.
calmrun reads the command and picks a kind: vitest, jest, type checks and builds cost 2 points, monorepo runners 3,
linters, plain test runs and a single compiler call 1. --cost and --kind override it, and your own
kinds go in the config.
A job also waits while free RAM is below min_free_gb or its drive has less than min_free_disk_gb
free. On an idle machine it starts anyway, so nothing waits forever.
vitest, jest and JavaScript builds take their nearest node_modules, Cargo its target folder, and
Gradle, Maven, .NET, CMake, Swift or Flutter builds their project folder. Two jobs on the same folder never run together, so
caches and build output don't fight.
Commands run below normal priority (nice +10 on Unix), so your editor stays responsive. A job whose process tree
goes above ceiling_gb is stopped with exit 137.
Watch modes (vitest watch, tsc -w, gradle -t, dotnet watch, …) and attached
docker compose up would hold points forever, so calmrun refuses them and prints the one-shot command to run
instead. Dev servers and app runs start at once, outside the queue.
--wait-timeout gives up after a while (exit 75) and keeps the place in line for 10 minutes as a ticket.
--needs db takes a named resource; --id uses a separate queue.
calmrun bump puts a waiting job next: while it waits for room, later jobs may not pass it. Pick it by label,
--pos, --ticket or --dir; --prio low and bump --back send
long jobs to the end of the line.
calmrun status and the waiting lines show a running job's CPU, idle 5m, its usual time and its last
output. Test-like jobs stop after 60 minutes (exit 124, --timeout, max_run_min);
calmrun stop <id> ends one now, calmrun logs <id> --follow shows what it prints.
calmrun pause 30m --reason "video call" stops waiting jobs from starting in every queue; running jobs go on,
and the line starts again by itself when the time is up or on calmrun resume. A pause always has an end.
| Kind | Points | Detected from |
|---|---|---|
vitest | 2 | vitest |
jest | 2 | jest |
tsc | 2 | tsc, vue-tsc, tsgo, npm run typecheck |
typecheck | 2 | mypy, pyright, deno check, phpstan, psalm |
build | 2 | vite/next/ng build, webpack, npm run build and the build tools of every ecosystem below; 1 point for one compiler call (gcc, clang, cl) |
monorepo | 3 | turbo run, nx run-many/affected, pnpm -r, lerna run, rush build, moon run |
capture | 2 | playwright, puppeteer, cypress |
docker | 2 | docker compose up/build/run/create, docker build/run/buildx, podman, buildah build, packer build |
eslint | 1 | eslint, oxlint, biome, npm run lint |
lint | 1 | ruff, pylint, flake8, go vet, golangci-lint run, rubocop |
pytest | 1 | pytest, python -m pytest |
test | 1 | npm test, tox, mocha and the test runners of every ecosystem below |
other | 1 | anything else |
Key: the folder two jobs never share (the nearest one holding that file). Worker hint: what calmrun passes so a
tool that uses every core takes only its share. A flag or variable you set yourself wins, and tools that run one job at a time
unless asked (make, ctest, plain Maven) are left alone. A dash means none.
| Ecosystem | Tools | Key | Worker hint |
|---|---|---|---|
| JavaScript · TypeScript | vitest, jest, tsc, eslint, vite build, webpack, npm test, deno test | node_modules (vitest, jest, builds) | --maxWorkers (vitest), DENO_JOBS |
| Python | pytest, mypy, pyright, ruff, tox, nox | tox.ini (tox) | pytest -n auto, tox -p auto → N |
| Rust | cargo build/check/clippy/test, nextest, maturin | target | CARGO_BUILD_JOBS, NEXTEST_TEST_THREADS |
| Go | go build/test/vet, golangci-lint | – | -p N, --concurrency N |
| C · C++ | make, cmake --build, ctest, ninja, meson, bazel, buck2, scons, xmake, gcc, clang, cl | Makefile, CMakeCache.txt, build.ninja, MODULE.bazel, … | --parallel N, -jN, --jobs=N |
| JVM | gradle, mvn, mvnd, sbt, ant | settings.gradle, pom.xml, build.sbt | --max-workers=N, -T N (mvnd) |
| .NET | dotnet build/test/publish, msbuild | *.sln, *.csproj, … | -m:N (dotnet) |
| Swift · Xcode | swift build/test, xcodebuild | Package.swift, *.xcodeproj | -j N, -jobs N |
| Flutter · Dart | flutter build/test, dart test, build_runner | pubspec.yaml | --concurrency=N (tests) |
| Ruby | rspec, cucumber, rake test, rails test, parallel_rspec, rubocop | – | PARALLEL_WORKERS, PARALLEL_TEST_PROCESSORS |
| PHP | phpunit, pest, paratest, composer test, artisan test, phpstan | – | --processes=N (paratest) |
| Elixir · Erlang | mix test/compile, rebar3 | mix.exs, rebar.config | --max-cases N (mix test) |
| Haskell · OCaml · Zig | stack, cabal, dune, zig build | stack.yaml, cabal.project, dune-project, build.zig | -j N |
| Monorepo runners | turbo, nx, lerna, pnpm -r, rush, moon | node_modules | their concurrency flag or variable; turbo, nx and pnpm never above their own default |
| Containers | docker / podman compose, build; buildah, packer | – | – |
Agents don't need to remember anything: hooks for Claude Code, Codex, OpenCode and the Pi coding agent (Antigravity: experimental) catch heavy shell
commands, the MCP server gives any MCP client a queued run_task tool, and setup writes the instructions
and hooks into each agent's global files.
calmrun hook claude|codex|opencode|pi|antigravity is a PreToolUse hook for the agent's shell tool. When a command
runs a heavy tool without calmrun (also through rtk), the hook denies it and tells the agent the exact command
with each heavy part wrapped, with a --wait-timeout below the tool's time limit. Light commands pass.
calmrun setup --write --hook all installs them; for Claude Code by hand, in ~/.claude/settings.json:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash|PowerShell",
"hooks": [{ "type": "command", "command": "calmrun hook claude" }]
}
]
}
}
cd web && npx vitest run becomes cd web && calmrun -- npx vitest run. With
CALMRUN_HOOK_MODE=rewrite the hook rewrites the command itself instead of denying it.
calmrun mcp serves tools over stdio: run_task (waits in the same queue and runs the command; a job
still busy after wait_seconds goes on in the background and returns a task_id),
task_status, cancel_task, queue_status and bump. For a device or an
emulator without a command: calmrun hold emulator prints a lease, calmrun release <lease> gives
it back.
# Claude Code claude mcp add calmrun -- calmrun mcp # Codex: ~/.codex/config.toml [mcp_servers.calmrun] command = "calmrun" args = ["mcp"] tool_timeout_sec = 3600 // Cursor: ~/.cursor/mcp.json { "mcpServers": { "calmrun": { "type": "stdio", "command": "calmrun", "args": ["mcp"] } } } // Gemini CLI: ~/.gemini/settings.json (timeout in ms) { "mcpServers": { "calmrun": { "command": "calmrun", "args": ["mcp"], "timeout": 3600000 } } }
Adds a short calmrun section to the global instruction file of Claude Code, Codex, Gemini CLI, OpenCode and Pi. It is a dry run
until you add --write; every file it changes is backed up first.
$ calmrun setup # show what would change $ calmrun setup --write # apply $ calmrun setup --write --agents codex # only some agents $ calmrun setup --write --hook # also the Claude Code hook (--hook all: every agent) $ calmrun setup --write --remove --hook # take both out again
Prints short instructions to paste into an agent's context. Or add this to CLAUDE.md or AGENTS.md
by hand:
## Heavy commands This machine is shared by several agents. Run heavy commands through the calmrun queue: `calmrun -- <command>` (tests, type checks, linters, builds, Playwright, docker compose, pytest, cargo/gradle/make/dotnet/go builds). Example: `calmrun -- npx vitest run`. Run anything that may take more than a minute or two in the background and check on it later. Use `calmrun status` to see what is running or waiting. Do not wrap light commands (git, ls, cat, package installs).
calmrun [flags] -- <cmd> |
Queue the command, then run it at low priority. Flags: --kind, --cost N,
--prio high|low, --label L, --needs db,gpu, --id QUEUE,
--wait-timeout SECS, --ticket ID, --timeout SECS, --log. One quoted string runs through the shell.
|
|---|---|
calmrun status | What runs, what waits and why, the budget and free RAM; for a running job its CPU, how long it has been idle, its usual time and its last output. --json for tools. |
calmrun stats | Runs, failures, wait and run times per label over --days N (default 7). |
calmrun bump <label> | Move waiting jobs to the front, where later jobs may not pass them while they wait for room; pick them by label, --pos N, --ticket ID or --dir PATH. --back moves them to the end. |
calmrun stop <id> | Stop a running or waiting job (the id column of status, or --label); a calmrun that does not react is killed. |
calmrun logs <id> | The output of a job that keeps a log (MCP tasks, runs with --log): --tail N, --follow. |
calmrun doctor | Cores, RAM, disk, battery, where state lives, and the suggested config. |
calmrun init | Write a commented config.toml with this machine's defaults (--force overwrites). |
calmrun guide | Short instructions for coding agents. |
calmrun setup | Write or remove the calmrun block in agents' global instruction files: --write, --remove, --hook, --agents. |
calmrun hold / release | Hold a resource slot (an emulator, a database) without a command and print a lease (with the instance it holds, if the resource lists instances); release <lease> gives it back, release --ticket <id> gives up a kept place. |
calmrun hook <agent> | The PreToolUse hook of claude, codex, opencode, pi or antigravity (experimental); reads the hook JSON on stdin. |
calmrun mcp | The MCP server on stdio: run_task, task_status, cancel_task, queue_status, bump. |
| the command's own | it ran (a Unix signal n becomes 128 + n) |
|---|---|
| 2 | refused (watch mode, attached docker compose up), bad arguments or an invalid --id |
| 75 | not started within --wait-timeout; the place is kept, run the printed calmrun: next: line |
| 124 | stopped by its run time limit: --timeout, MCP timeout_s or max_run_min (60 min for test-like kinds) |
| 126 · 127 | the command could not be started · was not found |
| 130 | Ctrl+C or calmrun stop |
| 137 | stopped by the memory ceiling or the critical free-RAM floor |
Every setting is optional. calmrun init writes a commented config.toml in the state directory; an
environment variable wins over the file.
| Key · variable | Default and meaning |
|---|---|
budgetCALMRUN_BUDGET | Logical cores − 2, capped at floor(RAM GB / 2.5), at least 2. Points that may run at once. |
min_free_gbCALMRUN_MIN_FREE_GB | max(1.5, RAM / 10). Free RAM a job needs to start while others run (in any queue); 0 turns it off. |
min_free_disk_gbCALMRUN_MIN_FREE_DISK_GB | 5. Free space needed on the drive of the job's folder; 0 turns it off. |
pass_limit_minCALMRUN_PASS_MIN | 10. Minutes a waiter may be passed by smaller jobs that fit; 0 means strict order. |
vitest_workersCALMRUN_VITEST_WORKERS | 1 up to 4 cores, 2 below 12, else 3. The --maxWorkers given to direct vitest calls. |
ceiling_gbCALMRUN_CEILING_GB | Half the RAM. Memory one job's process tree may use; 0 turns it off. |
critical_free_gbCALMRUN_CRITICAL_FREE_GB | 5% of RAM, at most 1 GB. Below this for 3 seconds, the biggest job is stopped; 0 turns it off. |
[resources]CALMRUN_RESOURCES | Slots per named resource, e.g. db = 1 or db=1,gpu=2. Unlisted resources have 1 slot. Or instances, one per job: android = ["emulator-5554", "emulator-5556"], or a table with discover (adb devices), health (adb -s {instance} get-state) and env; the job gets its instance in CALMRUN_ANDROID and ANDROID_SERIAL. |
[kinds.<name>] | cost overrides a kind's points; patterns = ["make"] adds a kind of your own; max_run_min sets its run time limit. |
max_run_minCALMRUN_MAX_RUN_MIN | 60 for test, vitest, jest, pytest, typecheck, tsc, lint and eslint; no limit for builds and other kinds. Minutes a job may run before it is stopped (exit 124); 0 turns it off. |
logCALMRUN_LOG | Off. Copy every run's output to a log file (as --log) for calmrun logs; tools then see a pipe, not a terminal, and may drop colours. |
CALMRUN_LOW_CPU | 0 keeps normal priority. |
CALMRUN_HOOK_MODE | rewrite makes the hook wrap commands itself instead of denying them. |
CALMRUN_HOME · CALMRUN_CONFIG | The state directory and the config file path. |
budget = 6 min_free_gb = 4 ceiling_gb = 8 # 0 = off [resources] db = 1 android = ["emulator-5554", "emulator-5556"] # one each per job [kinds.heavy] cost = 2 patterns = ["make", "bazel build"]
npm, npx and other .cmd shims
work; the command runs in a Job Object, so its whole tree ends if calmrun is killed.
nice +10 and dies with calmrun.
One binary, no runtime. The installers put calmrun in ~/.cargo/bin (%USERPROFILE%\.cargo\bin
on Windows) and add it to PATH; open a new terminal afterwards.
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/vannt-dev/calmrun/releases/latest/download/calmrun-installer.sh | sh
powershell -ExecutionPolicy Bypass -c "irm https://github.com/vannt-dev/calmrun/releases/latest/download/calmrun-installer.ps1 | iex"
npm install -g calmrun
cargo install calmrun --locked
From Releases: calmrun-x86_64-pc-windows-msvc.zip,
calmrun-aarch64-pc-windows-msvc.zip, calmrun-x86_64-apple-darwin.tar.xz,
calmrun-aarch64-apple-darwin.tar.xz, calmrun-x86_64-unknown-linux-gnu.tar.xz,
calmrun-aarch64-unknown-linux-gnu.tar.xz, each with a .sha256. Unpack and put the binary on PATH.
$ calmrun doctor # what this machine has, the suggested budget $ calmrun -- npx vitest run # queue, then run at low priority $ calmrun "npm ci && npm test" # one quoted string runs in the shell $ calmrun status # what runs, what waits, and why $ calmrun setup --write --hook # teach your agents to use it