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?
| Feature | Farhand (fh) |
ssh + rsync scripts |
Remote Desktop / SSH VSCode |
|---|---|---|---|
| No External System Binaries | Yes (pure static Rust) | No (requires rsync, ssh, tar) |
No (heavy daemon) |
| Zstandard (zstd) Wire Compression | Yes (negotiated, 3โ5x faster) | No (gzip or none) | N/A |
| Global Content-Addressable Storage (CAS) | Yes (zero-copy CoW hydration) | No | No |
| Persistent Dependency Cache | Yes (node_modules stays remote) |
Often wipes or conflicts | Local to remote box |
| 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 |
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. - ๐ 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. - ๐ 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.
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
โก 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 (v1.7.0)
Pre-compiled static release packages and checksums are available on the Farhand v1.7.0 Release:
| Platform | Architecture | Package Archive |
|---|---|---|
| Linux | x86_64 (64-bit) | farhand-v1.7.0-x86_64-unknown-linux-musl.tar.gz |
| Linux | aarch64 (ARM64) | farhand-v1.7.0-aarch64-unknown-linux-musl.tar.gz |
| macOS | Apple Silicon (M1/M2/M3/M4) | farhand-v1.7.0-aarch64-apple-darwin.tar.gz |
| macOS | Intel x86_64 | farhand-v1.7.0-x86_64-apple-darwin.tar.gz |
| Windows | x86_64 (Standalone Static) | farhand-v1.7.0-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 names are
farhand-cliandfarhand-agent, notfhandfhd. The binaries arefhandfhd;cargo installtakes crate names. (farhanditself is unavailable on crates.io โ an unrelated project already owns it.)
โ๏ธ 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
# 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) | 77 ms vs 322 ms โ 4.2ร faster |
| Delta tar unpack, zstd vs gzip | 19 ms vs 60 ms โ 3.1ร faster |
| Scan + SHA-256 hash, 320 files (~2.4 MiB) | 7.3 ms |
| CAS hydration (CoW reflink), 256 KiB file | ~24 ยตs (flat vs payload size) |
| Workspace branch clone (CoW, 100-file tree) | ~4 ms |
| Manifest diff, warm workspace (nothing changed) | ~1.1 ms |
Reproduce: scripts/run_benchmarks.sh regenerates BENCHMARKS.md from
criterion's saved estimates.
Detailed Documentation
Deep-dive guides covering architecture, server setup, and configuration:
- ๐ Observability โ live
fh top, plus an opt-in Prometheus endpoint (fhd --metrics-port) with an importable Grafana dashboard. - ๐ Internal Architecture & Wire Protocol โ Binary framing specs, frame layouts, state machines, and Section 5.1 deletion safety.
- ๐ 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. - โ๏ธ 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.
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.