An AI agent on my own server, controlled from my phone

I put Claude Code on a dedicated server and message it from the app. What I set up, the safety rules I added and what it costs.

Agents & models · · 2 min read

The idea is simple: rent a small server, put an AI agent on it and give it tasks from my phone. It writes code, builds the site, runs tools and reports back. I review the result and say yes or no where a decision is needed.

What I ended up with

  • A dedicated server in the EU running Ubuntu. Not a work machine and nothing with other people’s data.
  • Claude Code lives there in a persistent session, and I can message it from the Claude app.
  • Next to it sit Codex for image generation and another AI tool that works through a proxy because of regional limits.
  • The site you are reading was built by this agent in Astro.

The rules that make this safe

An agent with server access can do real damage, so I wrote the rules into a file it reads before every job:

  1. Anything irreversible or external only after my yes: opening a port, deleting data, paying, publishing, acting on my behalf in an outside service.
  2. Secrets live only in files readable by one user and never reach the chat, logs or git.
  3. Only a human types passwords and payment details.
  4. A new permanent service is created through systemd, and the agent says what it started and why.
  5. Before installing someone else’s package, the agent reads the install script instead of running it blind.

Hardening the server

SSH keys only, a firewall with a single open port, fail2ban and automatic security updates. I open a preview port separately and temporarily, on explicit request.

What surprised me

  • The agent loses context in long sessions. So it keeps a log in STATE.md: what is done, what we are waiting for, the next step.
  • Subscriptions do not always connect to a server. ChatGPT worked through a device code login, while the Kling video service has its own official CLI and a browser sign-in.
  • It is tempting to trust too fast. The “external actions only after confirmation” rule protects against needless spending and accidental publishing.

What it costs

The costs are a small server rental plus AI subscriptions I already used. I will add exact figures once I have a full month to report.

Takeaway

An agent like this shines when tasks are clear and limits are written down. For one-off experiments a regular chat is simpler. Next I want to plug a content pipeline into it: idea, draft, images, Telegram review and publishing.