Run a 24/7 Agent Farm on a Mac Mini with Claude Code
Run a 24/7 Agent Farm on a Mac Mini with Claude Code
What you'll build
A multi-agent setup running 24/7 on a Mac with auto-restart, cost tracking, and Telegram notifications.
The Problem
Your agent only works when your MacBook is open. Close the lid, the gateway dies. Messages go unanswered. File automation stops. The morning briefing you scheduled? Silent. Your agent is powerful but fragile — it only lives as long as your terminal session.
What You're Building
An agent farm. Three agents running 24/7 as macOS daemons, each with a different role, all monitored, all auto-restarting. You go to sleep, they keep working.
Milestone 1: Configure Background Operation
Right now OpenClaw runs in your terminal. Close the terminal, kill the agent.
Set up OpenClaw to run as a background daemon using macOS launchd. Create a plist file that starts the OpenClaw gateway automatically at boot, keeps it running in the background, and redirects logs to ~/Library/Logs/openclaw/. The daemon should start even without a user logged in. Walk me through loading the plist and verifying it's running.
What Claude Code does: It creates a macOS launch daemon (plist file) that registers OpenClaw as a system service. launchd is macOS's process manager — it starts your agent at boot, runs it in the background, and survives logouts, reboots, and sleep/wake cycles.
Try it: Reboot your Mac. Don't open Terminal. Send a message to your bot on Telegram. If it responds, the daemon is working.
Milestone 2: Set Up Auto-Restart on Crash
Daemons can crash. Your agent farm needs self-healing.
Update my OpenClaw launchd plist to auto-restart if the process crashes. Set KeepAlive to true so launchd immediately respawns it. Add a ThrottleInterval of 10 seconds to prevent restart loops. Also add a health check — a cron job every 5 minutes that pings the gateway and restarts it if unresponsive.
What Claude Code does: It configures two reliability layers. launchd's KeepAlive restarts the process immediately if it dies. The health check cron is the second safety net — ping every 5 minutes, force restart if no response. Two layers because production needs redundancy.
Try it: Kill the process: killall openclaw. Wait 10 seconds. Check status — running again. launchd brought it back.
Milestone 3: Run Multiple Agent Instances
One agent is useful. Three agents in parallel is a farm.
Set up three separate OpenClaw agent instances on my Mac, each with a different role: 1) "Atlas" — personal assistant on Telegram (Sonnet), 2) "Researcher" — research queries on Discord (Gemini), 3) "Watcher" — file automation and background tasks (Haiku, no messaging). Each with its own workspace, logs, and model. Update launchd to manage all three.
What Claude Code does: It creates three independent agent configurations with separate workspaces. OpenClaw's multi-agent architecture runs separate instances — each with its own identity, model, channels, and memory. launchd manages all three as separate daemons.
Try it: openclaw gateway status shows three agents. Message Atlas on Telegram, check Researcher on Discord, verify Watcher processes files.
Milestone 4: Build a Cost Tracker
Three agents running 24/7 means costs add up.
Create a cost tracking skill that monitors API usage across all three agents. Daily at midnight: 1) Query each agent's token consumption, 2) Calculate cost per model, 3) Log to cost-tracker.json, 4) Send Telegram summary: "💰 Daily Cost: Atlas $X.XX, Researcher $X.XX, Watcher $X.XX, Total: $X.XX". Alert if daily spend exceeds $5.
What Claude Code does: It creates automated cost monitoring. OpenClaw tracks token usage per agent — the skill queries, prices, and reports. You wake up knowing yesterday's cost.
Try it: Check cost-tracker.json for today's entry. First full report arrives tomorrow at midnight.
Milestone 5: Set Up Telegram Notifications
If something breaks at 3 AM, the agent should come to you.
Create a notification skill that alerts me on Telegram when: 1) Any agent crashes and restarts, 2) API errors occur, 3) Daily cost exceeds threshold, 4) Tasks complete. Format: 🔴 errors, 🟡 warnings, 🟢 completions. One line, key info only.
What Claude Code does: It creates a notification pipeline from your farm to your phone. Monitor logs and events, route alerts through Telegram. Red = broken. Yellow = attention. Green = done. Triage at a glance.
Try it: Send a test notification. Then kill an agent to trigger a red alert — verify it arrives.
Milestone 6: Test Overnight
The real test. Give your agents work and go to sleep.
Set up an overnight test. Queue: 1) Atlas delivers morning briefing at 9 AM, 2) Researcher runs hype checks on 3 tools, 3) Watcher processes any files in Downloads. Show me how to verify everything ran in the morning.
What Claude Code does: It queues tasks across all agents. Morning check: Telegram for notifications and cost report, dashboard for task history, organized folders for processed files. Green notifications = everything worked.
Try it: Go to sleep. Check Telegram in the morning. Cost report, briefing, task completions — all there. That's your agent farm.
What You Built
Remember that agent that died when you closed your laptop? You now have:
- Three agents running 24/7 as macOS daemons
- Auto-restart on crash with health checks
- Dedicated roles: assistant, researcher, background worker
- Daily cost tracking with spend alerts
- Telegram notifications for errors and completions
- An overnight test proving it all works
You woke up and the work was done. That's an agent farm.
Take It Further
- Add more agents — writer, monitor, social media manager
- Remote access — Tailscale to reach your farm from anywhere
- Scale to a team — let others use specific agents via their accounts
Ready to build your first AI agent?
Live Zoom workshop + 1 month WhatsApp follow-up with Yuval Keshtcher (Hebrew)
Learn about the Workshop