A year ago, running my own server looked like this: SSH, a command history I kept in my head, tabs with nginx docs and Stack Overflow, and a small knot in my stomach before every systemctl restart. Today Claude runs on my server, and I do most of the routine work through it. I describe the task in plain language, and the agent reads configs, runs commands, explains what it found, and proposes changes. I still make the decisions, but I type a lot less.
This post covers how my setup works, what I trust the agent with and what I don't, and the safety rules I consider non-negotiable.
My setup
zavada.dev is a Next.js app running on a regular Linux VPS. pm2 manages the process, and nginx sits in front as a reverse proxy with TLS. Deploys go through GitHub Actions: on every push to main, the workflow connects to the server over SSH, pulls the code, builds the project, and restarts the process in pm2.
Claude is wired into this system from three sides:
| Where Claude runs | How it is connected | What it is for |
|---|---|---|
| On the server | Claude Code in the terminal, right on the server over SSH | Logs, configs, diagnostics, maintenance |
| In the repository | Claude Code locally and cloud sessions with GitHub access | Code, CI/CD, pm2 config, pull requests |
| Through MCP | MCP servers for GitHub and other services | Give the agent data and actions without copy-pasting |
The three entry points through which Claude sees and changes the infrastructure.
One important detail: most of my infrastructure is described in the repository. The pm2 config, the deploy workflow, and the scripts live in git. So a large part of the "server admin" work Claude does isn't done by hand on the server at all. It's a regular pull request that I review and merge.
What I do through Claude every day
Deploys and CI/CD. When a deploy fails, I don't scroll through half a screen of Actions logs. I ask Claude to find the cause. It reads the log, compares it with the latest changes, and proposes a fix. A recent example: the nightly pm2 restart was set to 00:01, right after midnight. Claude, working right on the server, moved it to 04:17, when traffic is lowest and the restart doesn't overlap with other jobs, and added a kill_timeout so Next.js has time to finish in-flight requests. It's one tiny commit, but honestly, I wouldn't have gotten to it for a long time.
Logs and diagnostics. "Why did the site return a 502 at 3 a.m.?" Claude checks pm2 logs, the nginx log, and journalctl, lines up the timestamps, and tells me the process restarted because it hit the memory limit. Then we decide together: raise max_memory_restart or hunt for the leak. The real win isn't speed. It's that the agent keeps every source in view at once.
Configs. A new subdomain, a redirect, security headers, static caching, gzip and brotli. I describe what I want, Claude edits the nginx config, always runs nginx -t, and shows me the diff. The reload happens only after I've looked at it.
Monitoring and server health. Once a week I ask for a short report: disk space, memory, load, certificate expiry, pending package updates, anything stuck in pm2. These are all ordinary commands, but the agent turns them into one readable summary and highlights only what needs attention.
Security. Auditing open ports, SSH settings, firewall rules, fail2ban, and checking that secrets aren't lying where they shouldn't. Claude is good at catching the small things people miss for years: a forgotten open port, a key with overly broad permissions, a service listening on every interface.
Automation. Backup scripts, log rotation, cron jobs, health checks. The agent writes a script, tests it with a dry run, and only then do we put it in cron. The most valuable part is that it documents the script as it writes it, so six months later I still understand what's going on.
How I split trust
An agent on a production server is a powerful tool and a real risk. So I put every action into one of three groups.
| Type of action | Examples | What the agent may do |
|---|---|---|
| Read-only | Logs, process status, configs, df, free, ss | No confirmation needed |
| Reversible changes | Editing a config with a backup, a new script, a pull request | After I've seen the diff |
| Irreversible or risky | Deleting data, database migrations, firewall and SSH changes, restarting production | Only with my explicit approval, one command at a time |
The rule is simple: the harder an action is to undo, the closer a human needs to be to it.
Technically, you enforce this in Claude Code's settings. Read-only commands go on an allowlist, while dangerous ones like rm -rf, DROP, or changes to sshd_config or ufw are denied or require confirmation. For the critical stuff, hooks help: a script that inspects a command before it runs and stops it if it touches something off-limits.
Safety rules for an agent on a server
1. A separate user with minimal permissions. Don't run the agent as root. Where sudo is needed, only specific commands are allowed.
2. Secrets stay out of the context. Block .env files and keys from the agent. If a config needs checking, Claude looks at variable names, not values.
3. Plan first, then act. Before any change, the agent writes down what it is about to do and how to roll it back.
4. Back up before editing. Every config is copied before a change, and important changes go through git.
5. Verify after acting. nginx -t, a health check on the site, pm2 status. The agent doesn't consider a task done until it has shown that everything works.
6. Keep production and experiments apart. I try new ideas on a local copy or a test server first.
7. Instructions in CLAUDE.md. A file on the server describes where things live, which services are critical, and what must never be done. The agent reads it at the start of every session, so I don't have to explain everything again.
What doesn't work, or works less well
Claude doesn't replace understanding the system. If I don't know how nginx or pm2 should behave, I can't judge whether its proposed change is right, and sooner or later that ends badly. The agent sometimes confidently suggests an "obvious" fix that treats the symptom rather than the cause, like raising the memory limit instead of finding the leak. And it has no memory of your server between sessions unless you give it one explicitly through CLAUDE.md, notes, or the repository. That's why I keep everything important about my infrastructure written down, not in my head.
Conclusion
Claude didn't turn me into a DevOps engineer in place of myself. It took away the routine: searching logs, recalling syntax, writing the same scripts again, weekly checks. Because of that, I spend my time on decisions instead of typing commands, and I do things with my server that I simply never got around to before: security audits, proper backups, monitoring. The key is to be honest about what the agent does on its own and where a human is needed, and to enforce that in settings rather than relying on caution.
If you want to connect an AI agent to your infrastructure in the same way, or build an agent system for your team with the right permissions, MCP integrations, and guardrails against mistakes, get in touch. I'm a Senior Full-Stack AI Engineer with 11+ years in software development, and I'll help you do it safely. Contact me at https://zavada.dev/contacts.
Need a developer for the long run?
I can start now and work with you for months or years, not hand off after two weeks. Send me a message and we will talk through your project, requirements and next steps.