tmux, clearly explained (multi-agent terminal)
tmux is a terminal multiplexer that lets you run multiple terminal sessions inside a single window — and more importantly, it keeps those sessions alive even when you disconnect. In the age of AI coding agents, tmux becomes essential infrastructure: it lets you run multiple AI agents in parallel on a remote VPS, each in its own pane, persistent across SSH disconnects. This walkthrough covers everything from zero to running Codex and Claude Code side by side on a remote server.
Why tmux
The core problem: when you close your terminal or your SSH connection drops, everything running in that terminal dies. If you're running a long build, a dev server, or an AI agent — it's gone. tmux solves this by decoupling the terminal session from the connection.
With AI agents that can run for minutes or hours autonomously, persistence isn't a nice-to-have — it's critical. tmux lets you start an agent, disconnect, come back later, and find it still working. It's the foundation for a multi-agent development workflow.
"tmux is to terminal sessions what Docker is to processes — it makes them portable and persistent."
Local Setup
Getting tmux installed locally takes one command on most systems:
Once inside a tmux session, you'll notice a status bar at the bottom of the terminal. That's your indicator that you're inside tmux, not a raw terminal. Everything you do from here is persistent.
Core Concepts
tmux has three levels of organization:
- Sessions — top-level containers. Each session is an independent workspace (e.g., "project-a", "project-b").
- Windows — tabs within a session. Each window is a full-screen terminal view.
- Panes — splits within a window. You can divide a window horizontally or vertically to see multiple terminals at once.
The prefix key (default Ctrl+b) activates tmux commands. After pressing the prefix:
VPS Setup
To really unlock tmux's power, you want it on a remote server — a VPS that's always running. This way your sessions persist indefinitely, not just until your laptop sleeps.
Any cheap VPS works. The video demonstrates with a small cloud instance:
- Provider: Any cloud (Hetzner, DigitalOcean, AWS Lightsail — whatever's cheap)
- Size: Even 1 CPU / 1GB RAM works for running AI agents (the heavy compute happens at the API provider)
- OS: Ubuntu is the safest bet for compatibility with AI coding tools
SSH & tmux on VPS
Once your VPS is running, SSH in and install tmux. The workflow becomes: SSH → attach to tmux session → work → detach → disconnect SSH. When you come back, everything is exactly where you left it.
"The magic of tmux on a VPS: you SSH in, start your agents, detach, close your laptop, go to sleep — and they're still coding when you wake up."
Panes & Splitting
Panes are where multi-agent workflows come alive. Split your window into multiple panes and run a different agent or process in each one:
A typical multi-agent layout: left pane runs Codex, right pane runs Claude Code, bottom pane is your manual terminal for git operations and reviewing output. You can watch both agents work simultaneously.
Install Codex CLI
OpenAI's Codex CLI is one of the AI agents you can run in a tmux pane. Installation on the VPS:
Once Codex is running in its pane, you can give it tasks and switch to other panes while it works. tmux keeps it alive regardless of what you do.
Multi-Agent Demo
The real power move: running multiple AI agents in parallel panes, each working on different parts of a project. The demo shows two agents side by side:
- Left pane — Codex: Working on the backend API implementation
- Right pane — Claude Code: Building the frontend components
- Bottom pane — Manual terminal: Running git, reviewing diffs, managing branches
Both agents work simultaneously and independently. You can monitor progress, intervene when needed, and coordinate their output. It's like having a team of developers — each with their own terminal.
"This is the multi-agent dream: two AI coding agents working in parallel on different parts of your project, all persistent in tmux panes on a cheap VPS."
Install Claude Code
Claude Code is Anthropic's AI coding agent. Installing it on the same VPS gives you a second agent to run alongside Codex:
Now you have both agents installed and ready. Create a tmux layout with panes for each, and you're running a multi-agent development environment.
Persistence Proof
The demo proves persistence by disconnecting the SSH session entirely — closing the terminal, waiting, then reconnecting. Upon reattachment with tmux attach -t agents, everything is exactly where it was left: both agents still running, output preserved, work continuing.
This is the killer feature. Your agents don't need you to be connected. They keep working while you sleep, commute, or work on something else.
Live App Preview
When your agents build a web app on the VPS, you can preview it by forwarding the port through SSH:
This lets you see the app your agents are building in real time, right in your local browser, while the actual server runs on the VPS inside a tmux pane.
The Full Vision
The bigger picture: tmux on a VPS is the infrastructure layer for autonomous AI development. The vision is a persistent, always-on development environment where:
- Multiple agents work in parallel on different features or repos
- Sessions persist indefinitely — no more lost work from dropped connections
- You orchestrate by checking in periodically, reviewing output, and redirecting agents
- Cost is minimal — a $5/month VPS is all you need since compute happens at the API layer
"tmux + VPS + AI agents = a 24/7 development team that costs you $5/month in server costs plus API usage. That's the future we're building toward."