What is Farhand?
Modern software projects have heavy compilation, bundling, and testing pipelines. Running tsc -p ., cargo build --release, vitest run, or docker build on a thin laptop or MacBook Air drains battery, spins loud fans, and throttles your system.
Farhand (fh + fhd) allows you to keep editing code locally in your favorite editor (VS Code, Neovim, Zed) while offloading heavy compilation to a powerful remote machine (such as an Apple Silicon Mac Mini, a Linux workstation, or an internal build server).
Logs stream directly into your terminal in real time, and build artifacts (like ./dist or ./target/release) are automatically synced back to your local project directory.
Why Farhand?
| Farhand | VS Code Remote SSH | Bazel remote exec | mosh + tmux | ssh + rsync |
|
|---|---|---|---|---|---|
| Scope | Run one command on a build box | Full remote dev environment | Hermetic reproducible builds | Resilient shell over lossy links | Ad-hoc file + command copy |
| Zstd wire compression | Yes, negotiated | No | Bazel-specific | No | gzip or none |
| Cross-project content dedup (CAS) | Yes | No | Content-addressable store | No | No |
| Dependency cache survives between runs | Yes, per branch | Yes | Yes (natively) | n/a | Often wiped or conflicts |
Bring a dev server back to localhost |
Yes, -L |
Yes | No | No | Needs a separate ssh -L |
| Cancel kills the whole remote process tree | Yes | Yes | Yes | n/a | Often orphans it |
| Language-server offload | Yes | Yes | No | No | No |
| Multi-agent failover | Yes | No | Yes | No | No |
| External binaries required | None | VS Code, extension host | Bazel, RBE | mosh, tmux | ssh, rsync, tar |
| Local CPU still used for build | Never | Configurable | Never | Yes, always | Yes, always |
| Windows agent host | Yes | No | Rarely | No | No |
| Hermetic/reproducible by construction | No โ it runs your build | No | Yes | No | No |
| Works without a project system (no Bazel setup) | Yes | Yes | No | Yes | Yes |
Where Farhand loses, plainly. It is not a hermetic build system: Bazel
reproduces a result from a content-addressed graph, while Farhand runs whatever
your project's own tooling runs and inherits its determinism. It cannot replace
Bazel for that reason. It has no Windows agent story beyond the basics, it
cannot make your local machine faster by moving only part of a build, and
because the remote box keeps its own node_modules/target, a mismatch
between local and remote toolchain versions is your problem to manage. VS Code
Remote gives you a whole remote environment, not just a command runner.
If you need reproducible builds, use Bazel. If you want a thin, fast way to run
a project's own build and a dev server on a spare machine, that is this.
| Multi-Branch APFS CoW Forking | Yes (< 100ms, 0-byte duplicate) | No (duplicates entire folder) | No |
| Delta Source Sync | Yes (SHA-256 manifests over TCP) | Yes (rsync delta) | N/A (entire edit remote) |
| Clean Process Cancellation | Yes (kills remote process tree) | No (orphans compiler processes) | Yes |
| Offline Multi-Agent Failover| Yes (automatic load-balancing) | No | No |
| Works with Any Local Editor | Yes (pure CLI wrapper) | Yes | No |
| Remote Dev Server Reachable at localhost | Yes (-L, rides the build connection) | Needs a separate ssh -L | Yes (full remote desktop) |
Core Features
- โก No External System Binaries: Pure static Rust binaries. Never invokes or depends on system
ssh,rsync,tar, orgzip(templates are compiled in โ nothing is read from disk or executed). - ๐ High-Speed Zstandard (zstd) Wire Compression: Automatic handshake negotiation chooses
zstd(level 3) for delta and artifact transfers, delivering 3โ5ร faster compression throughput than gzip with minimal CPU overhead. - ๐๏ธ Global Content-Addressable Storage (CAS): Files with matching SHA-256 hashes are deduplicated globally on the agent host across all branches and projects, hydrated instantly via zero-copy CoW reflinks (
clonefileon macOS /FICLONEioctl on Linux). Zero-byte uploads for known files! - ๐ Persistent Workspace Cache: Remote dependencies (
node_modules/,target/,.venv/) remain on the agent host across runs. Only changed source files are transferred. - โก Stat-Gated Warm Sync: the agent keeps a digest index (
.farhand-hashindex.json) in each workspace, so an unchanged build re-stats the tree instead of re-reading it. A warm no-op sync costs ~1.1 ms on a 320-file tree rather than a full re-hash. Cold scans hash in parallel across all cores. - ๐ Instant APFS Copy-on-Write (CoW) Forking: When working across different branches on shared hosts, new branch workspaces are cloned from canonical seeds (
main/master) in < 100ms using 0 additional disk blocks. - ๐งน Automated Two-Tier LRU & Emergency GC: Daemon automatically soft-prunes intermediate caches, performs pre-flight emergency GC when disk space is tight (
--min-disk-gb), and evicts stale branch workspaces. - ๐๏ธ Continuous Watch Mode (
fh watch): Automatically debounces local file changes, syncs source deltas, and re-triggers remote builds with zero manual intervention. - ๐ฅ๏ธ Interactive Shell & Ad-Hoc Exec (
fh shell,fh exec): Drop into an interactive remote PTY shell inside your project workspace or run diagnostic commands without triggering hooks. - ๐ Branch-Aware Project Addressing: Automatically detects git branches and scopes workspaces as
<repo>__<branch>so multiple developers never collide. - ๐ก๏ธ Section 5.1 Deletion Safety: Strictly protects remote dependencies and build outputs from being deleted during manifest synchronization.
- ๐ Process Group Isolation: Spawns compilation inside isolated process groups (
setpgid). If youCtrl+Clocally, the entire remote compiler hierarchy is gracefully terminated. - ๐ Reverse Port Forwarding (
-L): run the dev server on the build box and open it on your laptop as if it were local โfh -L 3000:3000 -- npm run dev, then browsehttp://localhost:3000. Repeatable, loopback-only, and multiplexed over the existing build connection, so there is no second tunnel to keep alive and no extra inbound port on the agent. See the guide. - ๐ Multi-Agent Pool & Tag Routing: Automatically discovers, health-checks, and load-balances jobs across a cluster of build agents.
- ๐ Native Zero-Config TLS & Mutual TLS (mTLS): Pure-Rust, memory-safe TLS via
rustls(zero OpenSSL / C library dependencies). Supports automatic self-signed cert generation (fhd --tls-auto), SHA-256 fingerprint verification (fh --tls-fingerprint <sha256>), CA verification (--tls-ca), and mutual TLS client certificates (--tls-cert,--tls-key). - ๐ ๏ธ Declarative Toolchain Manager Hooks: Declare language versions per project in
.farhand.yamlor via CLI (-T rust=nightly). Farhand automatically configuresRUSTUP_TOOLCHAIN,PYENV_VERSION,NODE_VERSION, and wraps remote invocations withnvm,fnm,pyenv, orgoenv. - ๐ Run Observability: Query execution history, exit codes, synced bytes, and duration using
fh historyand host status viafh status. - ๐ Transfer Transparency (
fh sync,fh why): See exactly what a build would upload โ file count, bytes, and the share of the project that would cross the network โ withfh sync --dry-run; ask about any single path withfh why, which names the ignore rule that excluded it or reports the content-addressed hit that skipped it. - ๐ฉบ
fh doctor: One read-only pass over everything that commonly breaks a remote build โ where it is pointed, whether the token is present and stored safely, whether the transport is encrypted, declared toolchains, and the agent's connectivity, disk, queue, and load. It distinguishes "cannot reach the agent" from "reached it and it rejected your token", and exits 125 when something is actually broken.
How It Works
your machine the build box
โโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ you edit files โ โ fhd โ
โ โ โ โ โโโ auth + TLS โ
โ โผ โ one TCP โ โโโ workspace per โ
โ fh โ connection โ โ project + branch โ
โ โโโ scan + SHA-256 โโโโโโโโโโโโโโโบโ โ (CoW-cloned) โ
โ โโโ diff vs agent โ frames: โ โโโ CAS: content โ
โ โโโ delta tar โโโโโโโผโโโโโโโโโโโโโโบโ โ addressed, shared โ
โ โ โ โ โโโ run in its own โ
โ โโโ live stdout โโโโโผโโโโโโโโโโโโโโโค โ process group โ
โ โโโ stderr โโโโโโโโโโผโโโโโโโโโโโโโโโค โโโ send artifacts โ
โ โโโ artifacts โโโโโโโผโโโโโโโโโโโโโโโค โ
โ โ โ โ ~/.farhand/workspaces/ โ
โ โโโ -L 3000:3000 โโโโผโโโโโโโโโโโโโโบโ my-app__main โ
โโโโโโโโโโโโโโโโโโโโโโโโโโ โ my-app__feat-x โ
โ cas/objects/โฆ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Logs, file deltas, artifact transfer, and port forwards all ride the same
multiplexed connection โ there is no second tunnel to open and no extra port
on the agent. -L reopens a port on your loopback that the agent relays to
its own, so a dev server on the build box appears at localhost locally.
Full protocol detail in the architecture guide.
The Two Binaries
fh(Client): Scans the local project directory, hashes files, uploads deltas, requests remote command execution, streams live logs, and retrieves generated artifacts.fhd(Daemon): Listens on TCP (port9876), authenticates connections via token, maintains per-project workspaces, unpacks deltas, runs commands in process groups, streamsstdout/stderr, and returns artifacts.
Quickstart
1. Installation
Using cargo? The crate is
farhand-cli/farhand-agent, notfarhandโ that name belongs to an unrelated project on crates.io. See the "Via Cargo" section below for the exact commands.
โก One-Liner Install
Linux & macOS (Terminal):
|
Windows (PowerShell โ works whether MSVC / Visual Studio is installed or not):
irm https://raw.githubusercontent.com/Rayrsn/farhand/main/scripts/install.ps1 | iex
Windows (Command Prompt / cmd.exe):
powershell -ExecutionPolicy Bypass -Command "irm https://raw.githubusercontent.com/Rayrsn/farhand/main/scripts/install.ps1 | iex"
Note for Windows Users: Windows binaries are compiled with static C-runtime linking (
+crt-static). They are 100% self-contained and run on any clean Windows machine out of the box without requiring Visual Studio, MSVC build tools, or the Microsoft Visual C++ Redistributable.
๐ฆ Pre-Built Release Packages
Pre-compiled static release packages, each published with a .sha256
alongside it. These latest links always resolve to the newest release, so
this table cannot go stale:
| Platform | Architecture | Package Archive |
|---|---|---|
| Linux | x86_64 (64-bit) | farhand-x86_64-unknown-linux-musl.tar.gz |
| Linux | aarch64 (ARM64) | farhand-aarch64-unknown-linux-musl.tar.gz |
| macOS | Apple Silicon (M1/M2/M3/M4) | farhand-aarch64-apple-darwin.tar.gz |
| macOS | Intel x86_64 | farhand-x86_64-apple-darwin.tar.gz |
| Windows | x86_64 (Standalone Static) | farhand-x86_64-pc-windows-msvc.zip |
๐บ Via Homebrew (macOS)
๐ฆ Via Cargo
# The two binaries come from two crates, because the agent is published
# separately: a client-only user should not have to build a daemon.
Or straight from the repository, if you want unreleased changes:
The crate is not called
farhand.cargo install farhandinstalls someone else's project โ an unrelated tool already owns that name on crates.io. The crates here arefarhand-cli(thefhclient) andfarhand-agent(thefhddaemon). Note the split:cargo installtakes crate names, while the binaries you run arefhandfhd. The Homebrew formula, by contrast, really isfarhandโ sobrew install farhandis correct andcargo install farhandis not.
โ๏ธ Automated Remote Setup (SSH Over Cloudflare Tunnel)
To automatically install all prerequisites (cloudflared, OpenSSH, and fh) on your local client machine and configure seamless SSH port forwarding:
- Linux & macOS:
| # Or run locally from repository: - Windows (PowerShell):
& { irm https://raw.githubusercontent.com/Rayrsn/farhand/main/scripts/setup_remote_ssh.ps1 } -Hostname mac.yourdomain.com -HostAlias mac-mini -RemoteUser builder # Or run locally from repository: .\scripts\setup_remote_ssh.ps1
(See the complete Remote Access via Cloudflare Tunnel Guide for full architecture details).
2. Start the Daemon (fhd)
On your remote build machine or Mac Mini:
# Generate a secret token
# Run the daemon (token required โ fhd refuses to start unauthenticated by default)
# Development only: allow unauthenticated local clients explicitly
fhdwarns on non-loopback binds: without--tls, tokens travel in cleartext โ use--tls/--tls-autoor a tunnel on untrusted networks. Concurrent connections are capped via--max-connections(default 32).
(For production background services on macOS or Linux, see the Apple Silicon Mac Mini Setup Guide or systemd service units).
3. Run Builds Remotely (fh)
In your local project directory, initialize Farhand configuration automatically:
# Auto-detect project type and generate .farhand.yaml
# Or optionally generate customizable template definitions (.farhand/templates/<name>.yaml)
This generates a .farhand.yaml tailored to your project:
# .farhand.yaml
host: "192.168.254.68:9876" # Remote agent address or Tailscale name
token: "${FARHAND_TOKEN}"
# Unpack artifacts directly into the project directory (e.g. ./dist)
outDir: "."
# Outputs to pull back from the agent upon success
outputs:
- "dist"
Now execute any command remotely by prefixing it with fh:
# Offload TypeScript compilation
# Run unit tests on the remote machine
# Compile Rust binaries
# Continuous watch mode: sync and rebuild on local file saves
# Run the dev server on the build box, browse it at localhost:3000
# Or declare it once in .farhand.yaml, then just run the build:
# forward:
# - "3000:3000"
# Interactive remote workspace shell (allocated PTY inside remote repo)
# Ad-hoc command execution (bypasses dependency hooks and artifact downloads)
# Override or suppress artifact downloads on the fly
# Run with secrets from Infisical (env vars forwarded automatically)
# Or disable ambient env forwarding / pass explicit variables
# Zero-config TLS with SHA-256 fingerprint verification
# Select language toolchain version on the fly
# Inspect execution history and agent status (including available remote disk space)
# See exactly what a build would transfer โ nothing leaves your machine
# Ask why any single path is (or is not) on the agent
# One-shot diagnosis: config, token handling, transport, connectivity, and agent capacity
# Watch mode honours each template's ignoreExtra, and the debounce is tunable
# Nix (flake or plain nix-build)
&&
# Shell completions and man pages, generated from the binary's own CLI definition
# Prometheus metrics for Grafana/Prometheus (opt-in on the agent)
# Live terminal resource dashboard & host telemetry
# Remote Language Server Protocol (LSP) offloading (rust-analyzer, pyright, gopls, etc.)
# Free remote disk space for the current branch
Daily Developer Workflow
# 1. Start working on a new feature branch locally
# 2. Trigger build remotely
# Farhand automatically APFS-clones the seed workspace from main in < 100ms (0 bytes duplicate storage)
# 3. Modify source code locally
# 4. Re-run build
# Farhand only uploads the single changed file (0-byte delta sync for everything else)
# 5. Finished with the branch? Free remote workspace space
Performance
Measured with criterion (cargo bench -p fileset -p workspace, release profile)
on an Intel Core Ultra 7 256V, /tmp on tmpfs โ full methodology and
reproduction steps in BENCHMARKS.md:
| Metric | Result |
|---|---|
| Delta tar pack, zstd-3 vs gzip (2.4 MiB payload) | 74 ms vs 312 ms โ 4.2ร faster |
| Delta tar unpack, zstd vs gzip | 18 ms vs 57 ms โ 3.1ร faster |
| Scan + SHA-256 hash, 320 files (~2.4 MiB) | 3.1 ms (parallel across cores) |
| Warm sync of an unchanged workspace | 1.1 ms โ stats only, reads no file content |
| CAS hydration (CoW reflink), 256 KiB file | ~24 ยตs (flat vs payload size) |
| Workspace branch clone (CoW, 100-file tree) | ~4 ms |
Reproduce: scripts/run_benchmarks.sh regenerates BENCHMARKS.md from
criterion's saved estimates.
End to end, on a real project
The microbenchmarks above measure the parts. This is the whole command,
fh <anything>, against a live agent over loopback, on a 304-file Rust
project (~1.2 MiB of source):
| Run | Wall clock | Agent scan |
|---|---|---|
| First build (cold workspace) | 255 ms | 305 files hashed |
| Second build | 168 ms | 305 files re-hashed โ see below |
| Third and every run after | ~150 ms | 304 digests reused, 0 re-hashed |
Two honest notes. The second run deliberately re-hashes everything: a file whose mtime is not strictly older than the digest index's own write is treated as unsafe rather than trusted, and everything synced a moment earlier falls inside that window. The gate engages from the third run on, and costs one re-hash in exchange for never trusting a file that changed in the same tick it was recorded.
And the 150 ms floor is process start, handshake, and round trips โ at 304 small files the fixed costs dominate, so the end-to-end win here is roughly 40%. The win is in the scan itself (3.11 ms โ 1.13 ms on this fixture), and that is the term that grows with your tree; on a project ten times this size the fixed costs are the same and the scan is the part that hurts.
Detailed Documentation
Deep-dive guides covering architecture, server setup, and configuration:
- ๐ฅ๏ธ CLI Reference โ Every command, subcommand, and flag, plus the exit-code contract.
- ๐ฆ Templates โ How build templates detect projects and drive dependency installs, and how to override them.
- ๐ง The Agent (
fhd) โ Every daemon flag, the security posture, resource limits, GC and CAS tuning, and running it as a service. - ๐ Ignore Rules โ What gets synced and what does not: built-in defaults,
.gitignore,.farhand-ignore, and template rules. - ๐ Observability โ live
fh top, plus an opt-in Prometheus endpoint (fhd --metrics-port) with an importable Grafana dashboard. - ๐ Apple Silicon Mac Mini Setup Guide โ Production step-by-step guide for turning a Mac Mini into a multi-developer build server (
launchd, firewalls, network access). - ๐พ Storage Optimization & Caching Guide โ Deep dive into APFS Copy-on-Write cloning, LRU garbage collection, and shared toolchain caches (
sccache). - โ๏ธ Configuration Guide (
.farhand.yaml) โ Complete reference for config discovery, field definitions, and environment variable interpolation. - ๐ Multi-Agent Pool & Dynamic Load Balancing โ Setup guide for multi-agent clusters, health probing, and hardware tag routing (
--agent-tag). - โก Language Server Protocol (LSP) Offloading Guide โ Offload
rust-analyzer,pyright,gopls, andclangdto remote agent with VS Code, Neovim, Helix, and Zed. - ๐ Reverse Port Forwarding Guide โ Run a dev server, database, or any port on the build box and reach it at
localhostwith-L, multiplexed over the existing build connection. - โ๏ธ Remote Access via Cloudflare Tunnel โ Connect securely over the internet with
cloudflared access tcpwithout opening inbound router ports. - ๐ Benchmarks โ Reproducible criterion numbers behind the performance claims above.
Recipes
- ๐ณ Migrate from
rsync+sshโ what the script did, what replaces each part, and how to check a path is actually being sent. - โ๏ธ Run in GitHub Actions โ using a cheap hosted runner for orchestration while the build happens on a machine you control.
Project & Community
- ๐ Changelog โ Notable changes per release.
- ๐ค Contributing Guide โ Dev setup, code style, commit conventions, testing expectations.
- ๐ Security Policy โ Supported versions, private vulnerability reporting, and the
fhdthreat model.
License
Dual-licensed under either:
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
at your option.