RCH

Build offloading for coding agentsv2.1.37

Move agent builds off your machine.

RCH is a hook for Claude Code. When an agent runs cargo test, gcc, make or go build, RCH runs it on one of your Linux servers over SSH, streams the output back as it happens, copies the build outputs into your project and exits with the server’s exit code. To the agent it looks like a local build. If no server frees up in time, it runs locally as usual.

Where builds run

Agents building

– local CPU demand

0 building here0 on the fleet0 waiting

An illustration, not a benchmark: 16 local cores, six 32-core workers, builds that each want 8 cores for 14 to 26 seconds of work, and 3 seconds added to every round trip. The figures come from this model.

01The problem

Many agents, one set of cores.

One agent running cargo test is fine. Ten agents in ten worktrees start ten compiler process trees on the same cores. Each build gets a slice of the machine, so each takes longer, so more of them overlap, and your editor, your browser and the agents’ own tool calls slow down with them.

On record

One repository, 127 compilers.

A repository whose .cargo/config.toml set jobs = -1 started 127 rustc processes at once on a 128-thread host. Each forked a linker of about 1 GB. RAM and swap ran out, and the machine sat at 100% disk utilization for hours.

Read it in the shim’s source

Sent to a worker

  • Compiling and linkingcargo build, rustc, gcc, clang, make, cmake --build, ninja, meson compile, go build
  • Tests and benchmarkscargo test, cargo nextest run, cargo bench, go test, bun test
  • Checkscargo check, cargo clippy, cargo doc, go vet, tsc --noEmit, bun typecheck
  • Nix buildsnix build, nix flake check, on workers that have Nix

Stays on your machine

  • Changes to local statecargo install, cargo add, cargo fmt, bun install, go mod tidy
  • Servers and watchersbun dev, bun run, go run, cargo watch, bun test --watch
  • Everything elsegit, your editor, the agent itself, and any command without a build keyword

One that doesn’t stay: cargo run builds and runs the program on the worker, with its output streamed back. That suits tools that print and exit, not a server you want on localhost.

The incident is written up in the source of rch shim, which now caps parallelism on every local fallback. rch’s job is to keep work like that off the machine where you and your agents are typing.

02The hook

It sees each command before the shell does.

Claude Code asks rch about every Bash command before running it. Most aren’t builds, and for those rch answers and exits before it parses arguments, starts logging or creates an async runtime. A build gets rewritten to rch exec -- <command>, and Claude Code runs that instead.

Type a command an agent might run, or pick one.

Runs the real classifierInteractive

Sent to a worker

cargo_testconfidence 0.95 ≥ 0.85

  1. 0Empty commandcommand presentpassed
  2. 1Shell structureno pipes/redirects/backgroundingpassed
  3. 2Build keywordkeyword presentpassed
  4. 3Never-intercept listno never-intercept matchpassed
  5. 4Full classificationcargo testpassed

Claude Code runs

rch exec -- cargo test --workspace

Builds

Stay local

This box runs classify_command from rch-common/src/patterns.rs (commit 52ff5555, 2026-11-12), compiled to WebAssembly. Nothing you type leaves the page. After this check the hook applies your config, such as force_local and the execution allowlist, before rewriting anything.

Stays local on purpose

Some commands belong here.

A deny list of 60 patterns covers commands that change local state, start dev servers or watchers, or just print a version. Chains are split conservatively: cd api && cargo build keeps the cd and wraps only the build, cargo build 2>&1 | tail -20 keeps the pipe on your side, and cargo build && ./target/release/app stays local, since rch only splits a && chain whose last command is the build.

The full list in patterns.rs
  • cargo install
  • cargo add
  • cargo update
  • cargo fmt
  • cargo fix
  • cargo clean
  • cargo watch
  • cargo new
  • bun install
  • bun add
  • bun run
  • bun dev
  • bun build
  • go get
  • go mod
  • go run
  • cargo nextest list
  • and 43 more

03The fleet

A score for every worker, on every build.

rchd, the daemon on your machine, tracks each worker’s free slots, recent failures, SSH latency, free disk, and which projects it built recently. For each build, the default balanced strategy turns those into one score per worker and takes the highest.

Change the fleet and watch which worker gets the build.

InteractiveWorked example
bolt last built here
bolt’s busy slots
  • speed
  • free slots × load
  • health
  • cache warmth
  • latency
  • priority
  • free disk
  • penalty
  1. atlas8 of 64 slots busy · 45 msbuilt here never · 1200 GB free
    1.84
  2. bolt4 of 32 slots busy · 14 msbuilt here 18 min ago · 400 GB free
    1.99picked
  3. cinder2% errors36 of 48 slots busy · 22 msbuilt here 3 h ago · 600 GB free
    1.71
  4. driftdisk allows 5 of 16 slots8% errorsno AVX2 ×0.50 of 5 slots busy · 160 msbuilt here never · 60 GB free
    0.95

bolt gets the build with 1.99.

0.5·speed + 0.4·free·load + 0.3·health + 0.2·cache + 0.1·latency + 0.5·priority
× 0.5 if the circuit is half-open, × 0.5 on x86 without AVX2, × (1 − pressure and reliability penalties)
+ 0.2·free disk

Weights and curves are read from rchd/src/selection.rs and rch-common/src/types.rs when this site is built. The four workers are made up and share one priority, so that term adds the same 0.5 to each. Cache warmth is 1.0 for an hour, falls to 0.5 at six hours and 0.2 at a day, then decays. A test build counts a worker that only built the project at 0.6× warmth.

When the fleet is full

Wait for a slot, then fall back.

Queue

300 s

With every slot taken, a build waits in the daemon’s queue for up to 5 minutes before it runs locally. Slots are reserved, so a worker never takes more builds than it has room for.

Circuit breaker

3 in a row

A worker that fails 3 health checks in a row, or half of its last 10 results, is skipped for 30 s, doubling up to 480 s. Then it admits 1 probe build at a time, and 2 successes in a row close the circuit.

Warm targets

per project

Each worker keeps a target directory per project, toolchain, target, profile and feature set, so cargo reuses what it compiled there last time. That’s why recent builds count in the score.

Disk

10 GiB a slot

A worker’s usable slots shrink as its disk fills: each concurrent build needs 10 GiB beyond a 10 GiB floor by default, and a worker with critically low disk takes nothing new.

04The round trip

Output streams back. Binaries land in target/.

rch exec uploads the project with rsync and zstd, runs the command on the worker over SSH and prints its output as it arrives. A build’s outputs come back into your local target/. Then rch exits with the worker’s status: whatever cargo or the compiler returned, such as 101 for a failed test, or 128 plus a signal number.

Step through one cargo test, from the agent’s call to its exit code.

Worked example

1 · Your machine

The agent runs a test

Claude Code is about to run a Bash command and asks the PreToolUse hook first. rch classifies it as cargo_test with confidence 0.95, at or above the 0.85 threshold, and answers with a rewritten command.

Hook input → hook output, abridged
{"tool_name":"Bash","tool_input":{"command":"cargo test -p api"}}

{"hookSpecificOutput":{"hookEventName":"PreToolUse",
  "permissionDecision":"allow",
  "updatedInput":{"command":"rch exec -- cargo test -p api"}}}

2 · Your machine

rchd picks a worker

rch exec writes a job lease, then asks the local daemon over a Unix socket for a worker with 4 free slots. The daemon reserves them on bolt, which built this project twenty minutes ago.

Unix socket, abridged
GET /select-worker?project=acme-api&cores=4
→ worker: bolt   reason: success   slots: 4 of 32 reserved

3 · Over SSH

The source goes up

rsync sends only what changed since the last build, compressed with zstd. By default target/, .git/, node_modules/ and 32 credential-file patterns stay behind. The mirror lands at the same path on the worker.

rsync, abridged
rsync -az --partial-dir=.rch-partial --compress-choice=zstd \
  --exclude target/ --exclude .git/ --exclude .env … \
  /data/projects/acme-api/ bolt:/data/projects/acme-api/

4 · The worker

The worker builds and tests

The command runs in a pooled target directory that persists between builds of this project, toolchain and profile, so cargo reuses what it compiled last time. Output streams back line by line as it is printed.

Streamed to the agent’s terminal
   Compiling api v0.3.0 (/data/projects/acme-api/api)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 9.84s
     Running unittests src/lib.rs (target/debug/deps/api-3f1c9a)
running 42 tests
test routes::tests::rejects_expired_token ... FAILED
test result: FAILED. 41 passed; 1 failed; 0 ignored

5 · Over SSH

Results come back

For a test run the result is the output, which already streamed, and the exit status. The test binaries stay in the worker’s warm target for next time; rch doesn’t copy them home. A cargo build is different: its outputs come back into your local target/, without the incremental and fingerprint caches.

What comes back
cargo test -p api        the output and the exit status
cargo build --release    target/release/, without the caches
cargo build --bin api    only the api binary

6 · Your machine

Exit 101, as cargo would

rch exec exits with the worker’s status. cargo test exits 101 when a test fails, so the agent sees 101, reads the failure and fixes the token check, as it would after a local run.

What the agent sees
failures:
    routes::tests::rejects_expired_token

error: test failed, to rerun pass `-p api --lib`
exit status 101
1 of 6
A worked example: the project, worker name and test output are made up. The hook exchange and the rsync flags are abridged from what rch sends.

What leaves your machine

Keys and .env files stay home.

By default the upload skips build output and dependency folders, which the worker makes for itself, and 32 common credential-file patterns at any depth. Pick a file to see what happens to it.

Pick a file in this project.

Interactive

.env

Never sent

Matches .env, one of the credential and key patterns rch never uploads. A name without a slash matches at any depth.

Patterns are the defaults from default_excludes() in rch-common/src/types.rs, read when this site is built. A .rchignore file adds patterns for one project; an explicit exclude_patterns list replaces the defaults.

If the connection drops

A dropped connection doesn’t rerun the build.

rch writes a job lease before it asks for a worker. If the link drops after the build may have started, it doesn’t run the build again on your machine. rch jobs recover <id> collects the outputs from the worker later, without compiling again, and reports the original exit status.

bash
rch jobs                     # list durable job leases
rch jobs attach <id>         # watch a running job
rch jobs recover <id>        # collect outputs; never recompiles

05Fail-open

When rch can’t place a build, it runs here.

rch sits in front of every Bash command, so its own failures must not stop your agents. If it can’t get a build onto a worker, or every worker it tries lacks the toolchain, the build runs locally. Once a build may have run remotely and rch can’t confirm how it ended, it never runs it again here. If the hook itself crashes, it exits 0 with nothing on stdout, and Claude Code runs the original command.

Pick a failure, then switch to Strict.

Worked example

Strict is RCH_REQUIRE_REMOTE=1

It isn’t a build

Default

Runs locally

The hook answers on its fast path, before argument parsing or logging start, and Claude Code runs the command unchanged.

Exit status: the command’s own

Strict: RCH_REQUIRE_REMOTE=1

Runs locally

Strict mode governs builds only. The hook leaves other commands alone in either mode.

Exit status: the command’s own

rchd isn’t running

Default

Runs locally

[RCH] local (daemon unavailable)

rch records incident RCH-I010, starts the daemon and asks once more. If the daemon answers, the build goes remote as usual. If it doesn’t, the build runs here.

Exit status: the build’s own

Strict: RCH_REQUIRE_REMOTE=1

Refused

[RCH] remote required; refusing local fallback (daemon unavailable) — retryable

Same restart attempt, but if it fails nothing runs. Exit 103 marks the refusal as worth retrying.

Exit status: 103

Every worker is busy

Default

Runs locally

[RCH] local (selection error: queue_timeout)

The build waits in the daemon’s queue for up to 5 minutes. If a slot frees up, it runs there. Only when the wait runs out does it run here.

Exit status: the build’s own

Strict: RCH_REQUIRE_REMOTE=1

Refused

[RCH] remote required; refusing local fallback (selection error: queue_timeout) — retryable

Same queue and wait. When the wait runs out, rch refuses instead of using your cores.

Exit status: 103

The worker lacks the toolchain

Default

Runs locally

[RCH] local (toolchain missing on bolt; remote retries exhausted)

A missing toolchain is the worker’s fault, not the build’s, so rch tries other workers first, up to 3 attempts in all. Only when they all fail does the build run here. (A missing system library or an out-of-memory kill gets the same retries, but then exits with the worker’s status and a remediation line instead of running locally.)

Exit status: the build’s own

Strict: RCH_REQUIRE_REMOTE=1

Refused

[RCH] remote required; refusing local fallback (toolchain missing on bolt; remote retries exhausted) — retryable

The same retries on other workers. If they all fail, rch refuses instead of running locally. Run in the project, rch workers sync-toolchain --all installs its Rust toolchain on every worker.

Exit status: 103

The connection drops mid-build

Default

Kept for recovery

[RCH] remote bolt completion unconfirmed; ownership retained for recovery (no local fallback)

Once a build may have started, running it again here could do the work twice. rch keeps the job’s lease, and rch jobs recover <id> collects its outputs later without compiling again.

Exit status: 1

Strict: RCH_REQUIRE_REMOTE=1

Kept for recovery

[RCH] remote bolt completion unconfirmed; ownership retained for recovery (no local fallback)

Identical in both modes. Recovery never reruns the command.

Exit status: 1

The hook crashes

Default

Runs locally

[rch] hook panicked; falling open. (set RUST_BACKTRACE=1 to see)

In hook mode a panic handler writes that line to stderr and exits 0 with nothing on stdout. Claude Code reads that as no objection and runs the original command.

Exit status: the build’s own

Strict: RCH_REQUIRE_REMOTE=1

Runs locally

[rch] hook panicked; falling open. (set RUST_BACKTRACE=1 to see)

The hook’s crash path doesn’t consult strict mode, so the command runs as typed.

Exit status: the build’s own

[RCH] local (…) lines need RCH_VISIBILITY=summary; by default the hook prints none of them. Refusals and failure lines always print. Exit 103 marks a refusal worth retrying.

Strict mode

When a local run would be wrong.

On a laptop on battery, or in a gate that must show the build ran remotely, set RCH_REQUIRE_REMOTE=1 or pass rch exec --require-remote. rch then refuses with a reason instead of running locally. The cargo shim sets it for every agent it wraps.

bash
RCH_REQUIRE_REMOTE=1 rch exec -- cargo test --workspace
rch exec --require-remote -- cargo clippy --all-targets -- -D warnings

06For agents

Output an agent can act on.

Agents end up running rch’s own commands when a build looks wrong. So every command has a JSON form with one envelope, every error has a stable code with steps to fix it, and rch diagnose explains a decision before it happens.

Real output from rch 2.1.37, captured for this page.

Worked example

rch --json diagnose "cargo test --workspace"

Why a build would or wouldn’t go remote, before it runs. This one was captured while the fleet was full, and every worker says why it declined.

{
  "api_version": "1.0",
  "command": "diagnose",
  "success": true,
  "data": {
    "classification": {
      "is_compilation": true, "confidence": 0.95, "kind": "cargo_test", "reason": "cargo test"
    },
    "decision": {
      "would_intercept": true,
      "reason": "Compilation command with confidence 0.95 >= threshold 0.85"
    },
    "worker_selection": {
      "estimated_cores": 4,
      "worker": null,
      "reason": "all_workers_busy",
      "inventory": [
        { "worker_id": "atlas", "outcome": "excluded",
          "reason": "build disk headroom requires 50 GiB including active reservations and the reserve floor; worker reported 25 GiB free",
          "reason_codes": ["disk_headroom_insufficient"] },
        { "worker_id": "bolt", "outcome": "excluded",
          "reason": "available slots 2 < 4", "reason_codes": ["slots.insufficient"] },
        { "worker_id": "cinder", "outcome": "excluded",
          "reason": "worker status is Unreachable", "reason_codes": ["worker.status_not_assignable"] },
        { "worker_id": "win1", "outcome": "excluded",
          "reason": "worker declares os=windows, so it takes only commands targeting that OS",
          "reason_codes": ["os.declared_mismatch"] },
        …
      ]
    },
    "placement": { "strict_remote_policy": "off", "queue_policy": "queue_when_busy", "target_dir_policy": "pooled" }
  }
}

rch error explain RCH-E100

Every error code has a category, a description and steps to try. rch error list prints all of them.

RCH-E100  SshConnectionFailed
Category:     network                         Namespace: error (RCH-Ennn)

Description:
  SSH connection to worker failed

Remediation:
  - Verify the worker host is reachable: ping <host>
  - Check that SSH service is running on the worker
  - Verify firewall allows SSH (port 22)
  - Try connecting manually: ssh <user>@<host>

rch capabilities --json

One call tells an agent the commands, environment variables, output formats and what each exit code means for its next step. These codes are for rch’s own commands; a build run through rch exec exits with the build’s status.

{
  "data": {
    "exit_codes": [
      { "code": 0, "meaning": "success",
        "agent_action": "Continue; stdout contains the requested data in machine mode." },
      { "code": 1, "meaning": "general error or degraded health",
        "agent_action": "Read stderr or the JSON error/remediation fields; do not retry blindly." },
      { "code": 100, "meaning": "network or SSH failure",
        "agent_action": "Run `rch workers probe --all --json` and inspect RCH-E1xx errors." },
      { "code": 101, "meaning": "worker error",
        "agent_action": "Inspect `rch workers list --json` and worker capability mismatches." },
      …
    ],
    "commands": […], "env_vars": […], "output_formats": […], "recommended_commands": […]
  }
}
Worker names are changed and long lists are cut at “…”. The catalog holds 103 error codes, each with a category and remediation steps; rch error list prints them all.

Not on Claude Code

Codex, scripts and CI: the cargo shim.

The PreToolUse hook covers Claude Code. Everything else that calls cargo directly, such as Codex, shell scripts, Makefiles and CI, can go through rch shim install. It writes a cargo wrapper to ~/.rch/shims and prints the PATH line that puts it first. The wrapper sends build and test subcommands through rch exec, keeps rust-analyzer’s calls and cargo clippy’s inner check local, and runs the real cargo if rch isn’t installed.

bash
rch shim install           # cargo wrapper for agents and scripts
rch exec -- make -j32      # send one build by hand
rch exec --job -- ./fuzz.sh  # anything that isn't a build
rch --robot-triage --json  # health, problems, next commands
rch robot-docs guide       # the operating guide, in the tool

Job mode runs work that isn’t a build on the fleet: sharded test runners, fuzzers, benchmarks. rch exec --job -- ./run_shards.sh returns the remote exit status unchanged, and declared --result-dir folders come back whatever it is.

Verified tools. --require-tool clang only admits workers whose configured probe for that tool succeeded. A name no worker has verified admits none, so a typo can’t route the job to a machine that will fail it.

Exact runtimes. --require-toolchain bun@1.3.2 or node@22.11.0 filters workers by the version they report. Rust pins come from rust-toolchain.toml, which rch sends with the build.

07The numbers

What a round trip costs.

Sending a build away adds a fixed cost: syncing the source, opening SSH, copying outputs back. In exchange the build’s CPU, memory and linker run elsewhere. Whether one build finishes sooner depends on how your machine compares with your workers.

Wall time for one build, run on the server itself and sent through RCH to the fleet.

Measured

The rch workspace

  • cold check1.27× faster

    On the server151 sThrough rch exec118 s
  • cold build1.31× faster

    On the server242 sThrough rch exec185 s
  • incremental check mean of 24.1× slower

    On the server1.4 sThrough rch exec6.0 s

asupersync

  • cold check1.21× faster

    On the server96 sThrough rch exec79 s
  • cold build1.27× faster

    On the server163 sThrough rch exec128 s
  • incremental check mean of 21.28× faster

    On the server82 sThrough rch exec64 s
One run per scenario (two for incremental checks, averaged), started on hetzner2 with rustc 1.99.0-nightly (09ee43b2d 2026-07-27). The file doesn’t record which worker ran each build. Source: benchmarks/baselines/hetzner2-nightly-09ee43b2d.ndjson.

When it pays off

The case for RCH is concurrency.

In that run, cold builds and checks finished 1.2 to 1.3 times sooner through rch. A small incremental check got slower, from about 1.4 seconds to 6, because the round trip costs a few seconds however small the build.

It can go the other way. On an M5 Ultra Mac Studio, a cold cargo check -p rch-common --lib took 12.4 seconds locally and 143.1 seconds on a worker.

Either way, the load lands on the workers. With slots reserved per worker, the fifth agent’s build doesn’t take cores from the first four, or from you.

If your desk machine is faster than your servers, turn on the speed gate with compilation.local_slots. It times both sides per project and command, keeps a build local when the local median is under 2 seconds or the workers aren’t at least 1.2× faster, and caps how many run locally at once. It is off by default.

Alternatives

Next to sccache, distcc and Bazel.

These tools solve neighbouring problems. For agents, the main difference is that RCH moves the whole command, tests included, and leaves the build files alone.

What runs elsewhereYour build filesShared cacheLanguages
RCHThe whole command: compile, link, run testsUnchanged: cargo, make, go, bunNo; each worker keeps warm targets per projectRust, C, C++, Go, Bun tests, TypeScript checks, Nix
sccacheIndividual compiler calls, cached and optionally distributed; tests run locallyUnchanged; set as a compiler wrapperYes: local disk, S3, Redis and othersRust, C, C++, CUDA
distcc, icecreamC and C++ compile steps; linking stays localUnchanged; set as CCNoC, C++
Bazel, Buck2 remote executionAny action, tests includedRewritten as BUILD or BUCK rulesYesAnything with rules

08Install

One line to install.

The installer puts rch and rchd in ~/.local/bin, writes a starting config, registers the Claude Code hook, can start the daemon, and adds the rch skill for Claude Code and Codex. It runs on macOS and Linux, on x86_64 and arm64.

macOS or Linux · x86_64 or arm64
curl -fsSL "https://raw.githubusercontent.com/Dicklesworthstone/remote_compilation_helper/main/install.sh?$(date +%s)" | bash -s -- --easy-mode

Then run rch init

  1. 1Initialize configurationstarting config files in ~/.config/rch
  2. 2Discover potential workersfrom the hosts in your ~/.ssh/config
  3. 3Add discovered workersyou choose which ones join
  4. 4Probe worker connectivitySSH and what each worker has
  5. 5Deploy worker binaryrch-wkr, the worker-side agent
  6. 6Synchronize Rust toolchainthe toolchain of the project you run it in
  7. 7Start daemonrchd, which tracks the fleet
  8. 8Install Claude Code hookthe PreToolUse entry in Claude Code’s settings

What workers need

Linux with key-based SSH, rsync and zstd, and the toolchains your projects use. Eight or more cores and fast NVMe storage help; a rented server works as well as one under a desk.

On macOS, brew install rsync gets rsync 3 with zstd. RCH also drives the stock openrsync, more slowly, and rch doctor says which one it found.

Where your projects live

rch mirrors each project at the same path on the worker, so your projects need to sit under one root: /data/projects by default, or the directory you set as [path_topology] canonical_root. A build outside that root runs locally, and rch diagnose says so.

Check it

bash
rch doctor                          # health check, with --fix
rch status --workers --jobs         # the fleet right now
rch diagnose "cargo build --release"   # what would happen, and why

Rust · MIT with an OpenAI/Anthropic rider

Start with one server.

One Linux box you can reach over SSH is enough to try it. Add workers as your agent count grows; rch spreads the builds across them, and your own machine stays responsive.