How to Run Claude Code on a VPS with Mobile Access: T-Max and Telegram Setup
Claude Code sessions die when you disconnect. Run it on a $15/month VPS with T-Max to keep sessions alive and dispatch tasks from your phone via Telegram.
The Problem With Running Claude Code Locally
Claude Code is powerful. You spin it up, give it a complex task, and it starts working through your codebase autonomously — running tests, editing files, debugging errors. The problem is that the moment you close your laptop or lose your internet connection, everything stops. Your session is gone. The task you kicked off two hours ago? Dead.
This is a real limitation for anyone trying to use Claude as a persistent coding agent. Local sessions are fragile. They depend on your machine staying on, your connection staying stable, and your terminal staying open. That’s a lot of conditions to maintain for long-running tasks.
The fix is straightforward: move Claude Code to a VPS, use a terminal multiplexer to keep sessions alive, and wire up a Telegram bot so you can dispatch tasks from anywhere on your phone. This guide walks through exactly how to do that — including how T-Max (a tmux-based session approach) keeps your Claude Code sessions running between connections.
Why a VPS Makes Sense for Claude Code
A VPS is a virtual server that runs 24/7 regardless of what you do on your local machine. You connect to it via SSH, do your work, disconnect, and the server keeps running. When you reconnect later, everything is exactly where you left it.
For Claude Code specifically, this matters because:
- Long tasks finish uninterrupted. Claude can work through a refactor or a multi-file feature without you babysitting a terminal.
- You stay in control without being present. You can kick off a task, go do something else, and check back when it’s done.
- Your phone becomes a valid interface. With a Telegram bot in the mix, you can assign tasks to Claude from anywhere — not just your desk.
Remy doesn't write the code. It manages the agents who do.
Remy runs the project. The specialists do the work. You work with the PM, not the implementers.
The cost is low. A basic VPS with 2 vCPUs, 4GB RAM, and 80GB SSD from providers like DigitalOcean, Vultr, or Hetzner runs around $12–$20/month. Hetzner in particular is aggressively priced — you can get a capable machine for under $10/month.
What You Need Before Starting
This guide assumes a few things are already in place. If any of these are missing, get them sorted first:
- A VPS running Ubuntu 22.04 or 24.04. Most providers offer this as a one-click option.
- SSH access to your VPS. You should be able to run
ssh user@your-server-ipfrom your terminal. - An Anthropic account with Claude Code access. Claude Code requires an API key or Pro/Max subscription.
- A Telegram account. You’ll need this to create a bot.
- Basic comfort with the command line. You don’t need to be a sysadmin, but you should know how to SSH in and run commands.
Node.js will also need to be installed on the VPS, since Claude Code runs on it. We’ll cover that in the setup steps.
Set Up Your VPS
Provision and Secure the Server
Once your VPS is live and you have the root password or SSH key:
- SSH into the server:
ssh root@your-server-ip - Update the system:
apt update && apt upgrade -y - Create a non-root user (optional but recommended):
adduser yourname usermod -aG sudo yourname - Set up a basic firewall:
ufw allow OpenSSH ufw enable
Install Node.js and Claude Code
Claude Code runs on Node.js. Install it using the NodeSource repository to get a current version:
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
Verify it installed correctly:
node --version
npm --version
Then install Claude Code globally:
npm install -g @anthropic-ai/claude-code
Authenticate Claude Code with your Anthropic credentials. Run claude and follow the login flow — it’ll open a browser link or prompt for your API key depending on your account type.
Test that it works:
claude --version
Configure Persistent Sessions With T-Max
Understanding the Persistence Problem
When you SSH into a server and run Claude Code, that process is tied to your SSH session. Close the SSH connection (or lose it), and the process dies. This is the core problem T-Max solves.
T-Max is a tmux-based session management setup optimized for running AI coding agents. tmux (terminal multiplexer) is a well-established Linux tool that lets you create terminal sessions that persist independently of your SSH connection. T-Max builds on this with a structured approach to naming, attaching, and monitoring Claude Code sessions specifically.
Install tmux
tmux is usually pre-installed on Ubuntu. Check:
tmux -V
If it’s not there:
sudo apt install tmux
The T-Max Session Pattern
The core idea is simple: you create a named tmux session for your Claude Code work, detach from it, and it keeps running. When you come back — from any device — you reattach.
Create a new persistent session:
tmux new-session -d -s claude-main
This creates a session named claude-main that runs in the background (-d flag means detached).
To attach to it:
tmux attach -t claude-main
To detach without killing it: press Ctrl+B, then D.
To see all running sessions:
tmux ls
Running Claude Code Inside a tmux Session
The workflow is:
- Attach to your tmux session
- Navigate to your project directory
- Start Claude Code
- Detach — Claude keeps working
tmux attach -t claude-main
cd /path/to/your/project
claude
Now you can give Claude a task, detach, close your laptop, and Claude Code keeps running on the server.
Setting Up Multiple Windows
For more complex workflows, tmux windows let you run multiple things in the same session:
# Inside tmux, create a new window
Ctrl+B, then C
# Switch between windows
Ctrl+B, then 0 (or 1, 2, etc.)
# Name a window
Ctrl+B, then ,
A typical T-Max pattern is one window for Claude Code, one for monitoring logs, and one for general shell work.
Creating a Startup Script
To make this reproducible, create a startup script that sets up your Claude Code environment:
nano ~/start-claude.sh
Paste:
#!/bin/bash
SESSION="claude-main"
# Kill existing session if it exists
tmux kill-session -t $SESSION 2>/dev/null
# Create new session
tmux new-session -d -s $SESSION -x 220 -y 50
# Send commands to the session
tmux send-keys -t $SESSION "cd ~/projects" Enter
tmux send-keys -t $SESSION "claude" Enter
echo "Claude Code session started. Run: tmux attach -t $SESSION"
Make it executable:
chmod +x ~/start-claude.sh
Now whenever you want to spin up a fresh Claude session, just run ./start-claude.sh.
Set Up Telegram Bot Access
Why Telegram?
Telegram has a solid bot API that’s easy to work with. You can create a bot in about two minutes, and the API is well-documented. More importantly, Telegram works reliably on mobile — so you can send tasks to your VPS Claude session from your phone on the go.
Create Your Bot
- Open Telegram and search for
@BotFather. - Send
/newbot. - Follow the prompts — give your bot a name and username.
- BotFather will send you a token like
110201543:AAHdqTcvCH1vGWJxfSeofSTs4CNPX9grlAEg. Save this.
Get Your Chat ID
You need your personal chat ID so the bot only responds to you (not anyone who finds it).
Start a conversation with your new bot (send it any message). Then visit this URL in your browser, replacing YOUR_TOKEN:
https://api.telegram.org/botYOUR_TOKEN/getUpdates
Find the "chat" object in the response. The "id" field is your chat ID.
Build the Telegram-to-tmux Bridge
This is the part that connects everything. You’ll write a small Python script that listens for Telegram messages and forwards them to your Claude Code tmux session.
Install Python dependencies:
pip3 install python-telegram-bot
Create the script:
nano ~/telegram-claude-bridge.py
import asyncio
import subprocess
from telegram import Update
from telegram.ext import Application, MessageHandler, filters, ContextTypes
BOT_TOKEN = "YOUR_BOT_TOKEN_HERE"
ALLOWED_CHAT_ID = YOUR_CHAT_ID_HERE # integer, no quotes
TMUX_SESSION = "claude-main"
async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE):
if update.effective_chat.id != ALLOWED_CHAT_ID:
await update.message.reply_text("Unauthorized.")
return
user_message = update.message.text
# Send message to tmux session
cmd = f'tmux send-keys -t {TMUX_SESSION} "{user_message}" Enter'
subprocess.run(cmd, shell=True)
await update.message.reply_text(f"Sent to Claude: {user_message}")
def main():
app = Application.builder().token(BOT_TOKEN).build()
app.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, handle_message))
print("Bot is running...")
app.run_polling()
if __name__ == "__main__":
main()
Replace YOUR_BOT_TOKEN_HERE and YOUR_CHAT_ID_HERE with your actual values.
Run it:
python3 ~/telegram-claude-bridge.py
Keep the Bridge Running With tmux
Open a second tmux window for the Telegram bridge so it also stays alive:
tmux new-window -t claude-main
tmux send-keys -t claude-main:1 "python3 ~/telegram-claude-bridge.py" Enter
Now you have window 0 running Claude Code and window 1 running the Telegram bridge — both persistent.
Make It Start on Boot
To ensure everything comes back up if the VPS restarts, add a systemd service for the bridge:
sudo nano /etc/systemd/system/telegram-claude.service
[Unit]
Description=Telegram Claude Bridge
After=network.target
[Service]
User=yourname
ExecStart=/usr/bin/python3 /home/yourname/telegram-claude-bridge.py
Restart=always
[Install]
WantedBy=multi-user.target
Enable and start it:
sudo systemctl enable telegram-claude
sudo systemctl start telegram-claude
Connect Everything: The Full Workflow
Here’s what the complete system looks like in practice:
- You SSH in once to set up the tmux session and start Claude Code.
- Claude Code runs persistently inside that session, working on whatever you’ve assigned.
- You open Telegram on your phone and message your bot with a new task or follow-up instruction.
- The bridge script receives your message and sends it directly into the Claude Code session via tmux.
- Claude processes the instruction and continues working.
- You SSH back in whenever you want to see the full session output, review changes, or push code.
The flow for daily use looks like this:
- Morning: SSH in, review what Claude worked on overnight, run tests.
- During the day: Send quick instructions via Telegram (“refactor the auth module to use JWT” or “add error handling to the API routes”).
- Evening: Check in via SSH, review PRs, commit work.
For reviewing Claude’s output on mobile without a full SSH client, you can extend the bridge script to capture tmux output and send it back to Telegram — though this gets into more advanced territory and depends on how you prefer to monitor progress.
Where MindStudio Fits Into This Stack
The VPS + T-Max + Telegram setup described above is powerful, but it has a ceiling. You’re essentially passing raw text to Claude and relying on it to figure out everything from there. When Claude needs to do things beyond coding — send a notification when a task finishes, look up documentation, write to a database, or trigger a deployment pipeline — you’re back to writing custom glue code.
This is where the MindStudio Agent Skills Plugin fills a genuine gap. It’s an npm SDK (@mindstudio-ai/agent) that gives any AI agent — including Claude Code — access to 120+ typed capabilities as simple method calls. Instead of building custom integrations, you call methods like:
agent.sendEmail({ to: "you@example.com", subject: "Task complete", body: result })
agent.searchGoogle({ query: "Next.js 14 breaking changes" })
agent.runWorkflow({ workflowId: "deploy-staging" })
The SDK handles authentication, rate limiting, and retries. Claude Code handles the reasoning. You get a much more capable agent without cobbling together a dozen different APIs.
If you’re running Claude Code on a VPS for serious work, adding MindStudio’s Agent Skills as a tool layer means Claude can complete full workflows — not just edit files. You can try MindStudio free at mindstudio.ai.
Common Issues and Fixes
Claude Code exits unexpectedly
Check if the process ran into a context limit or hit an error. Attach to the tmux session and review the output. You may need to restart Claude Code and provide context about where it left off.
- ✕a coding agent
- ✕no-code
- ✕vibe coding
- ✕a faster Cursor
The one that tells the coding agents what to build.
Telegram messages aren’t reaching Claude
Verify the bridge script is running: systemctl status telegram-claude. Check that the tmux session name in the script matches your actual session name (tmux ls to confirm).
SSH connection drops mid-session
This is exactly why tmux matters. Reattach with tmux attach -t claude-main and you’ll find everything exactly as you left it. To prevent frequent disconnects, add this to your SSH client config (~/.ssh/config):
Host your-server-ip
ServerAliveInterval 60
ServerAliveCountMax 3
Claude Code loses context on long tasks
Claude has a context window limit. For very long tasks, break them into discrete chunks and restart Claude between them. Provide a brief summary of what was completed before starting the next chunk.
The Telegram bot responds but Claude doesn’t act on it
The bridge is likely sending to the wrong tmux window. Check that TMUX_SESSION in your script points to the window where Claude is running. You can target a specific window with claude-main:0 (session:window notation).
Frequently Asked Questions
Is Claude Code free to run on a VPS?
Claude Code itself is free to install, but you need an Anthropic account with access. Usage is billed based on your plan — if you’re on a Pro or Max subscription, Claude Code usage is included within those limits. API key access bills per token. The VPS itself costs $10–$20/month depending on the provider and specs.
What VPS specs do I actually need for Claude Code?
Claude Code itself is lightweight — it’s a CLI tool that makes API calls. The compute happens on Anthropic’s servers, not yours. A 1–2 vCPU, 2–4GB RAM instance is plenty for most workloads. If you’re running tests, building Docker images, or doing other heavy work alongside Claude Code, scale up accordingly.
Can multiple people use the same Claude Code VPS?
Yes, but it gets complicated fast. tmux sessions are per-user, so if multiple engineers SSH into the same server, they can have separate sessions. The bigger issue is API billing — all usage runs through one account. For team setups, it’s cleaner to give each person their own VPS or use a more formal shared infrastructure.
Is it safe to run Claude Code on a remote server?
The main risks are around what Claude Code can access. Claude Code can read, write, and execute files on the server it’s running on. Run it in a project directory, not as root. Consider using a separate user account with limited permissions. Keep sensitive credentials out of the project directory or use environment variable management tools.
Can I access my VPS without a Telegram bot?
Yes — SSH is always available. Telegram is just a convenience layer for mobile access. You can use any SSH client on iOS or Android (Termius is a popular option) to connect directly to your server and attach to your tmux session.
Does this work with other AI coding agents besides Claude Code?
Other agents ship a demo. Remy ships an app.
Real backend. Real database. Real auth. Real plumbing. Remy has it all.
The tmux + VPS pattern works with any terminal-based AI agent — Aider, Continue, Goose, or custom agents built on LangChain or CrewAI. The Telegram bridge is generic enough to forward messages to any running terminal session. The setup described here is Claude Code-specific only in the installation steps.
Key Takeaways
- Claude Code sessions die when your local machine disconnects — a VPS solves this by keeping your environment running continuously.
- tmux (via the T-Max session pattern) keeps terminal sessions alive between SSH connections, so long-running Claude tasks complete without interruption.
- A Telegram bot + Python bridge lets you dispatch new tasks to Claude Code from your phone, without needing a full SSH session.
- The whole stack — VPS, tmux, Telegram bridge — runs for around $15/month and takes a few hours to set up.
- For teams or more complex workflows, extending Claude Code with a tool layer like MindStudio’s Agent Skills Plugin gives it access to email, search, external APIs, and custom workflows without custom integration work.
If you want to extend what your Claude Code agent can do beyond file editing, MindStudio’s Agent Skills Plugin is worth a look — it’s a clean way to give your agent real-world capabilities without plumbing work.

