How I self-host my agent factory
Dmitry Kudryavtsev recently wrote up his self-hosted software development factory. He runs a Proxmox box with one VM per project, Forgejo issues that start Claude Code sessions, Semaphore for deploys, and a secrets proxy so the agents never see an API key. I read about it on the hacker news front page and I thought I would write how I do it just so that others are also encouraged to write theirs.
I've been running something with the same goal for about three months: agents doing most of the typing/coding while I review and decide. I made nearly every decision the other way round compared to Dmitry. He moved the agents off his laptop and into isolated VMs. I kept the agents on my desktop and moved the heavy commands they run onto a pile of old PCs. This post covers what that looks like, why I chose it, and where his design is better than mine. My laptop or phone now act as remote terminals only and that is why working on an Ipad is just fine in on some days.
The project behind all this is an open source Go CMS , plus a larger Go and Vue SaaS app. Both have big test suites, and one of them has a generated GraphQL file that takes about 6.4 GB of RAM to compile. This bottleneck shaped everything and why I chose this setup
The hardware
The desktop is where I work and where every agent runs:
AMD Ryzen 5 5600 (6 cores, 12 threads), 32 GB RAM, RTX 3060
Ubuntu 26.04 (Although Fedora now looks tempting)
Runs the agent harness, the terminal multiplexer, Postgres for local dev, a local Ollama for small jobs, and about twenty systemd timers
I use Pi harness, Herdr for multiplexing, Tailscale for network, systemd mostly, Github for code as it is open source and I need free actions and a heavy custom /pipeline that I wrote for all agents that has so many bells and whistles built in including a security audit at end of each run.
The build servers are six machines I already owned or picked up cheaply. None of them was bought for this:
Host | CPU | RAM | Disk | Notes |
|---|---|---|---|---|
zen-corner | i5-4460 (4c) | 24 GB | Samsung 860 EVO SSD | the workhorse, takes about half of all jobs |
zen-h97 | i5-4460 (4c) | 32 GB | MX500 SSD + HDD | the most memory, so it takes heavy compiles |
zen-komorebi | i3-6100 (2c/4t) | 24 GB | HDD | |
zen-msi | i3-7100 (2c/4t) | 24 GB | HDD | an old gaming laptop with a dead battery |
zen-asus | i7-3770K (4c/8t) | 10 GB (1333HZ - (I call this the AI turbo)) | MX500 SSD + HDD | fast CPU, little RAM, gets light jobs only |
zen-h110 | Skylake-era | 16 GB | currently offline; the queue skips it |
They all run Fedora 44 Server, headless, on the home LAN, and they're on my tailnet. Together they cost me roughly nothing, and they use less power than the desktop does when it's swapping.
Decision 1: offload commands, not agents
An agent session mostly waits. It sends a prompt, waits for the model, reads a file, and edits a file. That takes very little CPU. What hurts is what it runs: go test ./..., go vet, golangci-lint, vite build, vue-tsc. With five or six agents working at once, each running its own test suite in its own git worktree, my desktop went into OOM kills and hard freezes several times in late September.
Dmitry's answer is to move the whole agent into a VM. Mine is to keep the agents where I can see them and move only the expensive commands. I see three advantages with my approach:
One environment. Every agent shares my editor, my dotfiles, my git config, my Postgres, and my browser profile for screenshots. There's nothing to provision.
Compute adds up. Six old 4-core machines are a lot of test throughput.
Nothing changes for the agent. It runs
go testlike it always does but a wrapper decides where that actually run.
Isolation is the main decision driver here for me. I come back to that below, because it's the reason that made me change things.
The go-queue: a wrapper around go
~/.local/bin/go sits ahead of the real go on PATH. It's a bash script I built. Every go build, go test and go vet from every terminal, agent, worktree and Makefile on the desktop goes through it.
Weights. Each command gets a weight. Modules listed in a heavy file (the SaaS app with the 6.4 GB generated file) are heavy. Everything else is light. Locally, a heavy job runs alone: it waits for every running Go job and blocks new ones. Light jobs share three local slots. A turnstile lock stops light jobs from starving a waiting heavy one.
Remote hosts by memory. Each host has a line in a config file: name, SSH target, memory budget (RAM minus 2 GB), and max jobs. Every job reserves its expected peak: 7 GB for a heavy compile, 3 GB for other heavy-module work, 2 GB for light. A host accepts a job while reserved + need <= budget and it's under its job cap. The least-loaded reachable host gets the next job. Sometimes that blows up the machine despite the limits and so I built an auto reboot when that happens and the machine hangs for a while.
Routing:
Heavy work goes remote and waits for room. It only runs locally if no host is reachable.
Tests go remote first, and fall back to a local slot if every host is full.
Light builds and vets use a local slot first, then go remote when the local slots are busy.
golangci-lint,staticcheck,govulncheck,gosecandgo run <one of those>@versionalways go remote.Some things always stay local because they depend on local state or write files the agent reads straight away:
go install, benchmarks, golden-file updates,-c,-exec,-fuzz, profiles, andgo.worksetups.
Running remotely. A companion script rsyncs the worktree to the same absolute path on the build host, so paths in error messages are the same everywhere. It then opens reverse SSH tunnels for any local database or service ports named in the environment (DATABASE_URL=...localhost:5432... just works on the remote side), streams output back, returns the real exit code, and copies back anything the command produced (-o binaries, coverage profiles). Hosts that don't answer are skipped for 60 seconds.
Safety details that took me a while to learn:
Locks are
flock(1), so the kernel releases them when a process dies. A killed build can never wedge the queue.A test that shells out to
go buildwould deadlock waiting for its own slot. AGO_QUEUE_HELDenv var lets nested calls skip the queue.Every local job runs in a transient systemd scope capped at 14 GB RAM and 2 GB swap, so one runaway compile can't take the desktop down.
go list -exportis queued too. Three unqueuedmake checkruns each loaded every package's syntax at once and caused a global OOM on October 5.Max jobs per host is 3. I started at 6 to 8, but
go testalready uses every core, so more jobs only thrashed and broke timing-sensitive tests. I saw load averages above 20.Fedora 44's SELinux policy only lets sshd bind forwarded ports in 32768 to 60999, which silently broke the Postgres tunnel on one host. I then wrote a small local SELinux module, installed by the host setup script and this issue is now fixed. That took an evening to find and a whole lot of travel time because these six computers sit in my office and stopped responding that day.
The numbers. Since October 22 the queue has sent 93,500 commands to the build servers: about 38,000 go test runs and 20,000 npm builds and checks. The median sync before a remote run is 0.6 seconds and the 90th percentile is 2.9 seconds, so remote is nearly free for anything longer than a few seconds. The desktop hasn't frozen since the queue went in.
Decision 2: Tailscale instead of VLANs, a domain and a DNS server
Dmitry bought a domain, runs Technitium for DNS and DHCP, set up a DHCP relay container because his router couldn't relay across VLANs, and keeps services and dev machines in separate VLANs.
I use Tailscale for nearly all of that. MagicDNS gives every machine a name. tailscale serve gives internal dashboards HTTPS with a real certificate. The dashboards bind to 127.0.0.1 and are published on the tailnet only. My phone can reach everything wherever it is, and nothing is port-forwarded on the router. I run no DNS, DHCP or VPN server of my own.
The trade-off: VLANs give him segmentation that I only get once I write Tailscale ACLs. More on that in the security section.
Decision 3: GitHub, not Forgejo
He self-hosts Forgejo and its runner because he wants no dependence on outside services. I don't share that goal for source control. GitHub Actions, branch protection and the gh CLI are what my agents already know best, and the repos are partly open source anyway. I'd rather spend the effort on the build farm.
Decision 4: a pipeline with script gates, not issue labels
His agents pick up Forgejo issues labelled status/ready, with stage/research, stage/plan and stage/implement labels steering each session. Mine work from a pipeline: a set of skill files for the agent harness (I use pi) plus shell scripts. It runs:
sharpen -> plan -> execute -> review + forge -> push (full gate) -> PR -> Gate 2 -> ship -> cleanup
Sharpen turns a one-line idea into a brief. It greps the idea against the code, checks read-only production facts so data questions get settled up front, then asks me up to eight questions in two rounds and writes
brief.md, including an ASCII mockup of what the user will see.Plan turns the brief into file-disjoint workstreams. Workers can write in parallel only when they don't touch the same files.
Execute runs one worker per workstream, each in its own git worktree.
Review + forge is covered in the next section.
Gates are shell scripts with exit codes. An agent's report that "all tests pass" is a claim. The final output at every barrier is the exit code of
pipeline-gate.sh. Non-zero means stop and paste the output.Ship merges, builds from a clean worktree of
main, backs up the database, runs migrations with the new binary before restarting, health-checks the service and the site, and rolls back automatically (binary, unit file, and database if the migration version changed) if anything is red.
Hands-off by default. I used to get asked questions mid-run. One import feature stopped about 35 times for things like "should I continue to the next part?" Now every question for every part is asked up front in the pipeline run. After that, a decision rule replaces the questions: take the recommended option, otherwise the most reversible one (smaller scope, feature flag off, log and skip rather than block). Each choice is written to the ledger and to a ## Decisions taken section in the PR, so I can review the decisions instead of being interrupted by them. --gated puts the human gates back for risky work.
This has significantly reduced waiting times for the agent and I get to a final output and rarely need to go back.
When I measured my spend, the orchestrating session was 65% of it, sessions over 300k tokens were 53%, and rebuilding the prompt cache after idle gaps was 28%. So a small extension in the harness now blocks the orchestrator from reading code (it has to send a scout), caps a run at 300k tokens of context, and makes the run hand off to a fresh session at the limit. Resuming costs about 30k tokens. Carrying on in a bloated session costs far more.
This has dramatically increased my claude usage and I now get more bang out of the buck for my Claude.
Decision 5: review in herdr lanes, not tmux sessions on VMs
He presses prefix J in tmux to see every VM and every Claude session. I use herdr, a terminal workspace built for coding agents. It shows each pane's agent and its state (working, idle, waiting on me) on the pane border.
When I run /pipeline on a multi-part feature, the tab I typed it in becomes the coordinator and each part gets its own lane: a herdr tab with its own agent, worktree and ledger. Up to 8 lanes run at once, fewer if free memory drops under 4 GB. The rest wait in a queue, and parts that depend on another part wait until it ships.
Lanes don't talk to me. They write event files (DONE <PR> <sha>, BLOCKED <reason>) that the coordinator's watcher picks up. Screen-scraping was fragile, files aren't. A lane that has left its tab, or sat idle with an unchanged screen for 30 minutes, is reported as GONE or STALLED. The coordinator answers a blocked lane with a decision that I can read in that lane's tab, and the lane carries on.
The review itself:
Cycle 1. A fresh Claude Opus reviewer gets only the diff (
git diff origin/main...HEAD) and is told to assume it's broken. It writes P0 to P3 findings, each withfile:lineand a concrete failure. A second, cheaper reviewer takes one lens that fits the change, such as tenant isolation, migrations or UI consistency.Disprove. If there are P0s, another Opus pass gets all of them at once and tries to prove each one wrong. Plenty of "critical" findings don't hold up when someone checks.
Forge. Each confirmed P0 or P1 gets one worker: the smallest change that fixes it, a test that fails if the bug comes back, and its own commit. A forge that finds the bug isn't real commits nothing.
Cycle 2. One delta review of only the forge commits. There's no cycle 3: anything still open gets listed at Gate 2.
Gate 2 is where I come in. I get the brief's mockup, real screenshots of the change (taken by a visual-tester agent with a headless Chrome), the review summary with counts of fixed, refuted and open findings, the decisions taken, and the gate output. I pick Ship, Hold or Send back. When I want more, I open the lane's tab and read the diff, or talk to that lane's agent directly. It still has the full context.
A small read-only board command shows everything across all repos: what's waiting on me, what's in progress, what's stale because its PR already merged, and every worktree's dirty or ahead state, each with the exact command to resume it.
Decision 6: systemd timers, not jobs as markdown
He keeps recurring jobs as .agents/jobs/<job>.md with a cron line and limits on what each job may output. I have about twenty plain systemd user timers: content drafts and their fact and legal checks, a site monitor, changelog generation, release-channel freshness checks, a weekly release train, and a sweeper that cleans up stale build directories on the remote hosts. They're boring and they work. I prefer his approach, though.
How I keep untrusted access out
I know this is the biggest threat so here is how I do this...
No inbound access from the internet. Nothing is port-forwarded. Every dashboard and review page binds to localhost or the Tailscale interface and is published with
tailscale serveas tailnet-only. Production reaches my local Ollama through a reverse SSH tunnel that the desktop opens. The model port is never exposed.Build servers accept SSH keys only, with no passwords and no root login.
sudoneeds a password everywhere, including the desktop, so an agent can't escalate silently.Secrets never enter a repo.
gitleaksruns in the pre-commit hook. Production runtime config lives in achmod 600env file on the server, not in git. The deploy host isn't in the repo either: it comes from an env var or an untracked one-line file, and the deploy scripts refuse to run without one.Agents can't wreck each other. Each lane works in its own worktree. The harness extension blocks pattern kills (
pkill -f) after one worker killed two other lanes' test gates one day. Agents may only kill a PID they started and that I have battle tested so many times.Reviewers can't write code, and the orchestrator can't read it. Both rules are enforced by the extension, not by prompts.
Production changes go through one script, with a database backup first, migrations classified as destructive or not before they run, health checks after, and automatic rollback. Hatamoto already has a inbuilt backup so that is a problem that my software solves for me.
Every PR is checked for traces of how it was made before merge (tool names, session IDs, trailers), so the public history reads like normal commits.
And here's what's not covered yet. Dmitry's post is better on all three points:
Agents run as me. Every agent and every timer runs as my user, which holds my SSH keys and my GitHub token on the machine that deploys to production. His agents never hold a secret: API keys sit behind a proxy and deploy keys live in Semaphore, which only deploys from
main. Worse, some of my timers read RSS feeds and web pages. A paragraph in a scraped article written to hijack an agent would run with my keys. I know but this is a tradeoff I am willing to make for now.His jobs that read the web can't act. They run as a separate Linux user with no repo access and can only ask the harness to open an issue or PR, within declared limits. That's the right design and I'm copying it. My content jobs will run as a keyless user and write the actions they want to a JSON file, and a small trusted wrapper will check those against per-job limits and do them.
My build servers are a flat network. They run whatever
npm installandgo testpull in, and right now they can reach the rest of my tailnet. His CI runner sits in a VLAN with one tiny hole. Tailscale ACL tags give me the same thing in a few lines: the desktop can reach build servers on port 22, and build servers can reach nothing except the ports a job tunnels back.
I'm also giving the deploy key a forced command on the server, so an agent can trigger a ship but can't open a shell with it.
What I'd tell someone starting today
If your problem is heat, RAM and test time, do what I did. Keep the agents local and push commands to old hardware through a wrapper with memory-based admission. A 4-core i5 from 2014 with 24 GB and an SSD is a perfectly good test runner.
If your problem is trusting agents with your keys, do what he did. Agents and scheduled jobs never hold secrets, jobs that read the web can't act, and deploys only happen from
main, run by something agents can't reach.You can do both. Tailscale already does most of the networking he built by hand. The parts worth taking from his post are the separate job user, the secret-free agent, and the isolated runner.
His post ends with how much fun building it was, and I agree. The wrapper alone has twelve dated backup copies in my ~/.local/bin, one for each time I learned something about my own machines.
This has practically made my desktop the data centre and my laptop a remote login terminal or node. Self-hosting is fun again.