I have a little mini PC living in my office. It’s a humble box with an Intel N100 and 16 GB of RAM, running Ubuntu Server. I bought it years ago, so I don’t want to know how much it sells for today. It runs a handful of apps for the house: some media tooling, Home Assistant, a document archive, network-wide ad blocking, and a few things I’ve built myself.

I’m not going to go through the apps. They come and go. What I wanted to write down is the boring part underneath: how an app gets deployed, how I find out when something breaks, and how I’ve started letting Claude Code deal with problems before I even look at my phone.

The rules

A few constraints shaped everything else:

  • Nothing is public. The box is only reachable over Tailscale. There’s no port forwarding and no tunnels. If I’m not on the tailnet, it doesn’t exist.
  • It’s a small machine. An N100 is great for the power draw but slow at building images. Containers need to be lean, and I’d rather pull an image than build one.
  • Every app gets the same shape. One folder, one compose file.
  • No passwordless sudo. Scheduled jobs live in my user crontab, not in systemd units. That matters later, because it limits what an automated process can actually do.

Deploying an app

Every app lives in its own directory under /srv/stacks/<name>/:

/srv/stacks/
├── caddy/
│   ├── compose.yml
│   ├── Caddyfile
│   └── .env
├── some-app/
│   ├── compose.yml
│   ├── .env
│   └── data/
├── notify.sh
├── healthcheck.py
└── update-images.sh

The compose file sits beside its config and data, using bind mounts rather than named volumes. That way the whole directory is the app. Backing up /srv/stacks backs up everything, and there’s no hunting around Docker’s internals for where something put its state.

The compose files share a few habits:

services:
  app:
    image: someone/app:latest
    restart: unless-stopped
    ports:
      - 100.x.y.z:3300:8080   # Tailscale IP only, never 0.0.0.0
    volumes:
      - ./data:/data
    healthcheck:
      test: ["CMD", "/app", "healthcheck"]
      interval: 60s
    mem_limit: 256m

Ports bind to the Tailscale IP or 127.0.0.1, never to every interface. Every service gets a memory limit, so one misbehaving container can’t starve the others. Anything that needs the Docker socket gets it through a read-only socket proxy instead of the raw socket.

Names instead of ports

For a while everything was http://homelab:3300, :3400 and so on. That works, but my password manager treated every app as the same site, because to it they’re all one host.

Now Caddy sits in front of everything and gives each app its own name, like app.home.<my-domain>. The trick is that none of those names exist in public DNS:

  • Caddy gets a wildcard Let’s Encrypt certificate using the Cloudflare DNS-01 challenge, so it never needs to be reachable from the internet.
  • AdGuard Home, which is already the DNS server for the network and the tailnet, has a single rewrite: *.home.<my-domain> points to the box’s Tailscale IP.

So I get real HTTPS with valid certificates, on names that only resolve inside my network. Adding an app means one more handle block in the Caddyfile.

A front door

There’s also a small homepage that lists every app, grouped by category, with a live up/down dot next to each one. It reads its list from an apps.json file:

{
  "name": "Some App",
  "category": "Media",
  "url": "https://app.home.<my-domain>",
  "check": "http://127.0.0.1:4242/"
}

That file turned out to be more useful than I expected. It’s the closest thing I have to a source of truth for “what’s running here”, and the health checks (more on those below) read from it too. If an app is on the homepage, it’s monitored. I don’t have to remember a second step.

Keeping things updated

I don’t want to log in every week to run docker compose pull, so a script runs in the early hours on Sunday morning. Each stack gets one line:

update some-app   pull
update other-app  pull
update my-thing   build   # my own apps: rebuild with --pull to get base image updates

For each stack it records the image IDs, pulls or rebuilds, runs up -d, and compares the IDs again. If nothing changed, nothing gets recreated. If something did change, it waits 30 seconds and checks that every service is actually running. Any error or warning ends up in an alert.

A couple of things are deliberately kept out of it. Home Assistant has its own update script that rolls itself back if the new version doesn’t come up healthy. The DNS server updates separately, and earlier in the morning, because if DNS goes down everything else goes with it. Ubuntu security patches come from unattended-upgrades, and the box reboots at 03:30 on Sunday, but only if a package has asked for it.

Backups

Every night at 02:30, restic backs up all of /srv/stacks to Backblaze B2. Live SQLite databases are skipped and replaced with sqlite3 .backup copies, because copying a database file while an app is writing to it is a good way to end up with a backup you can’t restore.

Because of the one-folder-per-app layout, a new stack is backed up the night after it’s created, without me doing anything.

Watching the containers

There are three layers here, each one cheap.

Logs: Dozzle. It shows live logs for every container in the browser, behind a login, talking to Docker through the read-only socket proxy. I’ve turned off its shell and container actions. It’s for reading, not for doing things. It uses about 15 MB of RAM.

Metrics: Beszel. It tracks CPU, memory, disk and temperature for the host and per container, with history. The agent talks to the hub over a Unix socket, so it doesn’t need an open port. It also sends alerts if CPU or memory stays above 90% for ten minutes, if the temperature goes over 85°C, or if the agent disappears.

Health checks: a hundred-line Python script, run from cron every five minutes. It:

  • probes every app in apps.json (any HTTP response counts as up), and alerts after two failures in a row, so a container restarting doesn’t wake me;
  • sends a second alert when the app comes back;
  • alerts when the disk is over 85% full;
  • alerts when there hasn’t been a successful backup in 36 hours.

It keeps a small JSON state file, so each problem is reported once rather than every five minutes.

Getting alerts to my phone

Everything that can fail calls one script:

/srv/stacks/notify.sh "Backups are stale" "Last successful backup: Mon 16 Nov 02:30"

notify.sh sends the title and message to a Home Assistant webhook. An automation forwards it as a push notification to the HA app on my phone. I didn’t need another notification service, because Home Assistant was already on the phone. If HA itself is down, the alert goes to syslog instead. That’s a known gap, and I can live with it for now.

Having one entry point for alerts turned out to be the most important decision in the whole setup, because of what came next.

Dispatching Claude

Most of the alerts I get have a boring fix. A container exited and needs up -d. An image update broke something and needs rolling back. A backup failed because the network dropped at 5am. What I actually do is pick up my phone, SSH in, read some logs and run one command. That’s the part I wanted to hand off.

So notify.sh now does one more thing before it sends the notification. It passes the alert to autofix.sh, which starts a headless Claude Code session:

timeout 30m claude -p "$prompt" \
  --permission-mode auto \
  --settings /srv/stacks/autofix/settings.json \
  --output-format json \
  -n "autofix: $title"

The prompt is a markdown file with the alert’s title and message added to the end. Claude’s final message goes back through notify.sh to my phone, starting with FIXED:, NOT FIXED: or NO ACTION NEEDED:. So shortly after “X is down” I get either “fixed, here’s what it was” or “here’s what you need to do”.

Guardrails

Handing an AI agent a shell on a machine at 3am is a decision you should make carefully. Here’s what keeps it in check.

Deciding when to run. autofix.sh filters alerts before Claude ever starts:

  • Recoveries (“X is back up”) and its own reports are ignored, and anything raised during an autofix run is tagged so it can’t trigger another one. Without that, it could alert on itself in a loop.
  • Each kind of alert has a 6-hour cooldown, there’s a cap of 6 runs a day, and only one run happens at a time.
  • If the weekly update, the Home Assistant update or the backup is still running, it waits for that job’s lock first. The last thing I want is Claude “fixing” a container that an update script is halfway through replacing.
  • It detaches with setsid, so the cron job that raised the alert is never left waiting.
  • There’s a kill switch: touch /srv/stacks/autofix/DISABLED.

Telling it what it may do. The prompt describes the job in four steps: check the problem is still real, diagnose with read-only commands, apply a fix only if it’s on the safe list, then report. The safe list is short:

  • restart or up -d the affected stack, and only that stack;
  • roll back to the previous image tag if an update clearly broke something;
  • restart the reverse proxy;
  • clear dangling images, build cache and oversized logs if the disk is filling up;
  • re-run a failed backup once.

The “never” list is longer. It covers the DNS server, the firewall, Tailscale, systemd, cron, reboots, deleting volumes, editing secrets or app config, and pushing code. If the real fix is on that list, Claude’s job is to stop and tell me exactly what to run.

Enforcing it. A prompt is a request, not a restriction, so the settings file adds a deny list that Claude Code enforces no matter what the model decides:

{
  "permissions": {
    "deny": [
      "Bash(sudo *)",
      "Bash(systemctl *)",
      "Bash(reboot*)",
      "Bash(tailscale up*)",
      "Bash(docker system prune*)",
      "Bash(docker volume rm*)",
      "Bash(rm -rf *)",
      "Bash(git push*)",
      "Read(//srv/stacks/**/.env)",
      "Edit(//srv/stacks/autofix/**)",
      "Edit(//srv/stacks/notify.sh)"
    ]
  }
}

It can’t read the secrets, and it can’t edit its own prompt, its settings or the script that starts it. On top of that, the user account has no passwordless sudo, so anything outside my own permissions is off the table anyway.

Leaving a paper trail. Every run writes a short markdown report to reports/: what was wrong, the evidence, the exact commands it ran, and anything left for me. The raw JSON output, including the session ID, goes to runs/. If I want to know why it did something, I can run claude --resume <session_id> and ask it.

Giving it context

The part that makes this work better than a generic “restart it if it’s down” script is the context Claude starts with. It runs from my home directory, so it picks up the same CLAUDE.md and memory files I use when I’m working on the box myself. Those cover which ports are in use, which stacks do what, and quirks I’ve already debugged, like the WAN connection dropping for a minute around 5am most mornings.

That means when an alert fires at 05:02, the first thing it checks is whether it’s that network blip again, instead of spending twenty minutes working that out from scratch.

So far

Honestly, it’s early. So far the only run has been the test alert I fired while setting it up. It checked the container, the health endpoint and the route through Caddy, then told me everything was fine and that it hadn’t changed anything. That’s the right answer, and it took about 20 seconds.

I’ll find out how it does on a real problem the next time something breaks. I’m comfortable with that, because the worst it can do is restart a container I’d have restarted myself, and it tells me either way.

Things I’d do again

  • One folder per app. Backups, updates and cleanup all fall out of that single convention.
  • One list of apps. The homepage, the health checks and the monitoring all read the same file.
  • One alert script. Everything goes through notify.sh, so adding autofix meant changing one file instead of every job.
  • Write things down for the agent. The notes I keep for my own sessions turned out to be the most useful thing I could give an unattended one.

None of it is clever, and that’s the point. It’s a small box doing small jobs, and I’d like to think about it as little as possible.