If you’re thinking about letting an agent run real infrastructure, most of the advice you’ll find is about the harness: which orchestrator to use, and how to hand work between runs. I spent a week building one of those for my homelab, then retired most of it when Claude Projects did the same job better. How far I trust Claude didn’t change when I did, because that’s set by a working agreement that gives Claude root on every VM and its own name on everything it touches. Below are the five rules in it I’d keep for any agent I let near production.

My version was a long-running Claude Code session on djinn, the VM where Claude lives, handing story stages to headless workers in containers. The hard part was the handoff. Most of my effort went into the prompting and guardrails that let one run pass work cleanly to the next, and moving anything between headless runs was clunky: a worker that stopped with a question needed its answer carried back in by hand, and at first a finished run couldn’t take a reviewer’s findings. Projects, still in beta, gives me a coordinator and a thread per piece of work with a much better experience. The launcher is largely retired, though some of it may come back for the agents that triage incidents.

The agreement is a document in the homelab repo, docs/claude-access.md, and an Ansible role that enforces it. Its opening line sets the terms: I’m the client, Claude is the engineer who owns the infrastructure and is accountable for what it does, including as root.

1. Give it its own identity

Claude never uses my account or the Ansible one. It has its own Linux user on every VM and on the Proxmox host, its own SSH key, its own GitHub machine user, its own 1Password service account, and its own users in Komodo, Grafana, Uptime Kuma and the rest. Home Assistant gets a non-admin user, because calling a service there turns lights off on real people.

So every action shows up under Claude’s name, and I can revoke any of its credentials without touching mine. The SSH key’s private half lives in a vault and in the ssh-agent’s memory, never on disk, and the VMs only accept it from djinn. The GitHub user has write access but isn’t an admin, so branch protection binds it like any other contributor.

Moving to Projects found a gap here within a day. Cloud threads reach GitHub through my claude.ai connector, so their PRs showed up as mine, while sessions on djinn used the machine user. One agent with two identities made the record hard to read, and a PR under my name looks like my work or my approval. The fix was one more clause in the agreement. A thread makes no GitHub write as me, and hands the work to a session on djinn that does it as Claude. My messages in the thread reach that session marked by the server as mine, so an approval I give there still counts.

2. Log everything instead of allowlisting

The first draft of the agreement, written before the hardware arrived, went the other way. Claude got sudo for a handful of root-owned wrapper scripts, hl-status, hl-logs and hl-restart among them, with every argument checked against a list of known stacks and units, and nothing else.

Docker is why that didn’t last. Restarting a stack means running docker compose, and anyone who can run Docker as root can start a container that mounts /. The draft knew that, which is why it kept Claude out of the docker group, but hl-restart still ran Docker as root on Claude’s behalf. Every wrapper I’d need was either too narrow to help or wide enough to be root in all but name. An allowlist would only have looked safe.

So Claude has NOPASSWD:ALL on every VM, and the control is the log of what it ran. Ubuntu 26.04 ships sudo-rs, which logs every command line to the journal, and Alloy ships the journal to Loki. The first draft had also planned on log_output, sudo’s session recording, and visudo on golem rejected it, because sudo-rs has no I/O logging at all.

That gap produced the rule I’d now treat as essential: no root shells. If Claude runs sudo -i and twenty commands inside it, the log shows one line. Twenty separate sudo calls show twenty. Docker goes through sudo too, since Claude still isn’t in the docker group. Deny patterns in Claude Code’s managed settings back the rule up, though a wrapper sidesteps them easily, and part three is about how much prose guardrails like that can carry.

3. Classify changes, not commands

The wrapper draft’s tiers survived as four change classes. They’re summarised in the homelab’s CLAUDE.md, so every session starts with them:

ClassExamplesRule
StandardRead-only checks, restart a crashed container, re-run a failed job, roll back to the last good deploy, renew a certDo it, then report
NormalAnything the repo manages: stacks, Komodo, DNS, VMs, monitors, jobs, AnsiblePR from an issue. Claude merges after CI and a review, then deploys and verifies
SignificantThe router and firewall, NAS shares, the Proxmox host, deleting data, new external exposureSay what and why, wait for my go, one step at a time
EmergencySomething the family uses is downLeast change that restores service, tell me at once, then a PR to make it permanent

When in doubt, it’s the higher class. This scales where a command list can’t, because the same sudo can be Standard on one VM and Significant on the NAS, depending on what the change touches.

A go for a Significant change has to name the host and the operation. I learnt that when Claude’s permission classifier refused a plain “you can make the changes”, which part three covers.

4. Earn autonomy with restores

The question I went back and forth on most was who merges. The first version said Claude could merge its own PRs only once nightly backups existed and a restore of each kind had been tested. The same day I swapped that for “nothing on the servers is irreplaceable yet, so merge everything”, and the backups landed the next day anyway, with goblin restored to a spare VM ID and its network unplugged to prove it.

Where it settled: Claude merges every PR it opens after CI and a review, and tells me what merged. A merge that makes a Significant change still waits for my go, since a merge deploys. Two kinds of change wait for my approval in my own words: sensitive data, and Claude’s own guardrails. The guardrails are a named list (CLAUDE.md, the agent definitions, sudoers, the managed settings and two more). CI is deliberately not on it, because Claude has to be able to fix CI without waiting for me.

Autonomy came after the restore was proven, and the restore is the safety net for everything the classes let through. Reviewing every PR myself would have been the alternative, and in a week with this many merges I’d have become the bottleneck.

5. Make the agreement code, and the off switch real

The sudo rule, the user and its key live in an Ansible role, and the document says that if it and sudoers disagree, sudoers wins, so the two change in the same PR.

That makes switching Claude off short. Set claude_authorized_key to an empty string and run the baseline, and the key, the sudo rule and the login shell are gone from every VM. Revoking the service account removes vault access at once. Going back to the wrapper model is one template change, which is the fallback if an audit ever makes me uneasy.

Writing it down honestly also showed where the switch doesn’t reach. The Proxmox host’s user was made by hand and the Synology’s is a DSM account, so the baseline misses both. The GitHub token has a copy on djinn that revoking 1Password doesn’t touch. Each has its own line in the document.

What’s still trust

Plenty of this isn’t enforced. The sensitive label is only a label, and GitHub won’t stop Claude merging a guardrail change; the permission classifier might, and quoting my approval on the PR makes it visible if it doesn’t. My connector still has write access whatever the agreement says about threads. And Claude has root on the VM it runs on, so it could change its own guardrails if it chose to.

I’m fine with that because the record is complete and the restore works. If I were starting again I’d write the agreement before building any orchestrator.

Part three is about those prose guardrails: the classifier’s rules in a root-owned settings file, what they refused, and why CLAUDE.md ended up holding rules rather than facts.

Assisted by Claude Code (claude-opus-5-5). The experiments, bugs and conclusions are mine. How I work with AI tools is in The AI pair programmer.