Claude Code und Codex in tmux: KI-Agenten laufen lassen, auch wenn der Laptop zu ist
Mit tmux und SSH lassen sich Coding-Agenten wie Claude Code weiterlaufen, nachdem man die Sitzung geschlossen hat. Der Artikel zeigt die notwendigen Befehle für tmux 3.5a und vergleicht, wann tmux allein nicht mehr ausreicht.

Von Nora, Podium-Team. Hinweis zur Transparenz: Wir entwickeln Podium, eines der Tools in der Tabelle am Ende. Alles vor dieser Tabelle funktioniert mit gewöhnlichem tmux und SSH. Wir haben die tmux-Befehle weiter unten mit tmux 3.5a ausgeführt. Die Flags von Claude Code und Codex stammen aus deren offizieller Dokumentation, die Fakten zu den Tools von der jeweiligen eigenen Website, Dokumentation oder dem Repository, jeweils geprüft am 3. Dezember 2026. Einige Tool-Fakten stammen zusätzlich von adecomparison.com, einem Katalog, den Podium betreibt (Daten auf GitHub unter madeinorbit/ade-comparison ).
Kurze Antwort: Das Zuklappen des Laptops versetzt ihn in den Ruhezustand, und ein Agent auf einer schlafenden Maschine arbeitet nicht weiter, egal ob er in tmux läuft oder nicht. Führe Claude Code oder Codex also innerhalb von tmux auf einer Maschine aus, die durchlaufen bleibt (ein Server, ein VPS, ein Desktop zu Hause), eine tmux-Session oder ein Fenster pro Aufgabe, jeweils im eigenen git worktree. Mit Ctrl-b d abtrennen, den Laptop zuklappen und später mit tmux attach -t <name> wieder verbinden.
Das funktioniert gut für zwei oder drei Agenten. Darüber hinaus beginnt man, den Überblick zu verlieren, denn tmux kann dir nicht sagen, welcher Agent auf eine Antwort wartet, und auf dem Telefon ist es unhandlich. Ab dann lohnen sich die Background-Modi der Agenten selbst oder ein Agent-Manager (Tabelle unten).
Wenn du die vollständige Server-Einrichtung mit mosh, systemd und Telefonzugriff suchst, haben wir dafür eine separate Anleitung zum Betrieb von Agenten auf einem VPS geschrieben. Dieser Artikel handelt vom tmux-Teil und davon, was passiert, wenn du mehr Agenten hast, als du verfolgen kannst.
tmux hält ein Programm am Laufen, wenn das Terminal, das es gestartet hat, verschwindet. Es hält die Maschine nicht wach. Auf einem Laptop wird bei geschlossenem Deckel die Maschine in den Schlaf versetzt, und jeder Prozess stoppt, bis sie wieder aufwacht.
Die Dokumentation der Agenten selbst sagt dasselbe. Die Dokumentation von Claude Code zu Hintergrund-Sessions besagt, dass Sessions "auch erhalten bleiben, wenn deine Maschine schläft", dass ihre Prozesse "beim Aufwachen fortgesetzt werden" und dass ein Herunterfahren sie stoppt. Die Remote-Control-Dokumentation besagt, dass dein Computer "eingeschaltet bleiben muss und der claude-Prozess weiterlaufen muss". Für den Telefonzugriff von Codex schreiben die Dokumente von OpenAI, dass der Fernzugriff stoppt, wenn der Host-Computer schläft.
Die Einrichtung ist also: tmux auf einer Maschine, die nicht schläft, und dein Laptop als einer der Wege, darauf zuzugreifen.
Per SSH auf die Maschine verbinden und dann im Verzeichnis, in dem der Agent arbeiten soll, eine benannte Session starten:
ssh you@your-server cd ~/code/myapp tmux new -s fix-tests # danach claude oder codex darin ausführen Enter fullscreen mode Exit fullscreen mode Abtrennen mit Ctrl-b und dann d. Der Agent läuft weiter. Von jeder Maschine aus auflisten und wieder verbinden:
tmux ls tmux attach -t fix-tests Enter fullscreen mode Exit fullscreen mode Ein nützlicher shortcut: tmux new -A -s fix-tests verbindet dich mit der Session, wenn sie existiert, und erstellt sie andernfalls. Du kannst das in den SSH-Befehl einbauen, sodass eine Zeile dich zurück zum Agenten bringt:
ssh -t you@your-server tmux new -A -s fix-tests Enter fullscreen mode Exit fullscreen mode Die Remote-Control-Dokumentation von Claude Code empfiehlt für entfernte Maschinen dasselbe: "Starte es innerhalb von tmux oder screen, damit die Session nach dem Trennen der SSH-Verbindung weiterläuft."
Zwei Agenten in einem Checkout überschreiben einander die Dateien. Ein git worktree gibt jedem Agenten aus demselben Repository ein eigenes Verzeichnis und einen eigenen Branch. Du kannst die tmux-Session in diesem Verzeichnis starten, ohne dich zu verbinden:
cd ~/code/myapp git worktree add../myapp-fix-tests -b agent/fix-tests tmux new -d -s fix-tests -c ~/code/myapp-fix-tests claude Enter fullscreen mode Exit fullscreen mode -d startet die Session abgetrennt und -c legt ihr Arbeitsverzeichnis fest. Wenn die Aufgabe gemerged ist, räumst du auf mit tmux kill-session -t fix-tests und git worktree remove../myapp-fix-tests.
Beide CLIs können den worktree auch selbst anlegen. Claude Code kennt claude -w feature-auth, und die Dokumentation führt ein --tmux-Flag auf, das für diesen worktree eine tmux-Session erstellt ( claude -w feature-auth --tmux ). Codex hat ein --worktree-Flag, das eine Session in einem neuen verwalteten Git worktree startet.
Sich mit jeder Session zu verbinden, um zu sehen, was sie tut, wird langsam. tmux kann stattdessen den aktuellen Bildschirm eines Panes ausgeben:
tmux capture-pane -p -t fix-tests | tail -20 Enter fullscreen mode Exit fullscreen mode Und es kann ohne deine Verbindung in eine Session Eingaben senden, was ausreicht, um eine Ja/Nein-Frage zu beantworten:
tmux send-keys -t fix-tests "y" Enter Enter fullscreen mode Exit fullscreen mode Lies den Bildschirm, bevor du etwas sendest, denn die Tasten gehen an das Prompt, das gerade offen ist.
Wenn du mehrere Agenten als Fenster in einer Session hältst, markiert monitor-silence ein Fenster in der Statusleiste, nachdem es eine bestimmte Anzahl Sekunden nichts mehr ausgegeben hat. Ein stiller Agent wartet oft auf dich:
tmux set-option -w -t agents:claude monitor-silence 60 Enter fullscreen mode Exit fullscreen mode Das ist nur ein grober Hinweis. Ein stilles Fenster kann auch ein Agent sein, der über einen langen Schritt nachdenkt, oder einer, der fertig ist.
Wenn die tmux-Session weg ist, etwa nach einem Reboot, ist das Gespräch es meist nicht. Beide CLIs speichern Transkripte auf der Festplatte und können dort weitermachen, wo sie aufgehört haben:
claude -c # das jüngste Gespräch in diesem Verzeichnis fortsetzen claude -r "fix-tests" # eine Session per ID oder Name fortsetzen (benenne sie mit: claude -n fix-tests) codex resume --last # die jüngste Codex-Session in diesem Verzeichnis fortsetzen Enter fullscreen mode Exit fullscreen mode Für Aufgaben, die nicht anhalten sollten, um dich etwas zu fragen, haben beide einen nicht-interaktiven Modus: claude -p "..." und codex exec "...". Diese laufen ebenfalls problemlos innerhalb von tmux, und codex exec resume --last setzt die jüngste exec-Session fort.
Mit zwei oder drei Agenten reichen die Schritte oben vollständig aus. Wenn die Zahl wächst, tauchen dieselben Probleme auf:
tmux erfüllt seinen Teil weiterhin gut. Du erledigst nur die Arbeit eines Managers von Hand obendrauf.
Die Agenten selbst haben einiges davon ergänzt, und ein paar Open-Source-Tools bündeln viele Agenten gleichzeitig. Geprüft am 3. Dezember 2026 anhand der jeweils eigenen Dokumentation, Website oder Repository der Tools, plus der Daten von adecomparison.com ( madeinorbit/ade-comparison, von Podium veröffentlicht).
Alle diese verwenden deine eigenen Agent-Abonnements oder API-Schlüssel, die Agenten-Kosten kommen also obendrauf, ebenso der Server, wenn die Agenten mit geschlossenem Laptop laufen sollen.
Ein kurzer Weg zur Auswahl: Wenn alle deine Agenten Claude sind, probiere zuerst agent view und Remote Control, denn sie werden mit Claude Code mitgeliefert. Dasselbe gilt für Codex, wenn du bereits die ChatGPT-Desktop-App nutzt. Wenn du Agenten mischst, brauchst du einen der Open-Source-Manager auf einer Maschine, die durchläuft.
Da wir es entwickeln: Podium führt die Agent-CLIs, die du ohnehin nutzt, in persistenten Terminals auf einer Maschine aus, die dir gehört. Jede Aufgabe erhält ihren eigenen Branch und worktree, sodass die Schritte 1 und 2 oben beim Starten einer Aufgabe automatisch geschehen. Das Schließen eines Browser-Tabs oder des Laptops stoppt den Agenten auf dem Server nicht. Aus einem Terminal sehen die Überwachungsschritte so aus ( docs ):
podium session status your_session_id # Zustand, Phase, geänderte Dateien podium session read your_session_id --turns 8 # jüngstes Transkript podium session send your_session_id \ --text "Run the focused test and attach the result." Enter fullscreen mode Exit fullscreen mode Wo es heute noch Schwächen hat:
Die VPS-Anleitung behandelt die Installation auf einem Server, und der Quellcode liegt auf GitHub.
Zuletzt geprüft am 3. Dezember 2026. Diese Tools ändern sich wöchentlich; wenn hier etwas veraltet ist, sag es uns in den Kommentaren und wir korrigieren es.
Mit KI-Unterstützung geschrieben und vom Podium-Team geprüft.
Automatisch übersetzt. Das Original auf Englisch ist unten aufklappbar.
Original (Englisch) anzeigen
By Nora, Podium team. Disclosure: we build Podium, one of the tools in the table at the end. Everything before that table works with plain tmux and SSH. We ran the tmux commands below on tmux 3.5a. Claude Code and Codex flags come from their official docs, and tool facts from each tool's own site, docs or repository, all checked on 3 Dec 2026. Some tool facts also come from adecomparison.com, a catalog Podium publishes (data on GitHub at madeinorbit/ade-comparison ).
Short answer: closing the laptop puts it to sleep, and an agent on a sleeping machine stops working, whether it runs in tmux or not. So run Claude Code or Codex inside tmux on a machine that stays on (a server, a VPS, a desktop at home), one tmux session or window per task, each in its own git worktree. Detach with Ctrl-b d, close the laptop, and reattach later with tmux attach -t <name>. That covers two or three agents well. Past that you start missing things, because tmux can't tell you which agent is waiting for an answer and it's awkward on a phone. That's when the agents' own background modes or an agent manager start to pay off (table below).
If you want the full server setup, with mosh, systemd and phone access, we wrote a separate guide for running agents on a VPS. This post is about the tmux part, and about what happens when you have more agents than you can track.
tmux keeps a program running when the terminal that started it goes away. It does not keep the machine awake. On a laptop, the lid closes, the machine sleeps, and every process stops until it wakes up.
The agents' own docs say the same. Claude Code's docs on background sessions say sessions "are also preserved when your machine sleeps" and that their processes "resume on wake", and that shutting down stops them. Its Remote Control docs say your computer "has to stay on and the claude process has to keep running". For Codex's phone access, OpenAI's docs say remote access stops when the host computer sleeps.
So the setup is: tmux on a machine that doesn't sleep, and your laptop as one way of reaching it.
SSH into the machine, then start a named session in the directory the agent should work in:
ssh you@your-server cd ~/code/myapp tmux new -s fix-tests # then run claude or codex inside it Enter fullscreen mode Exit fullscreen mode Detach with Ctrl-b then d. The agent keeps running. List and reattach from any machine:
tmux ls tmux attach -t fix-tests Enter fullscreen mode Exit fullscreen mode A useful shortcut: tmux new -A -s fix-tests attaches if the session exists and creates it if it doesn't. You can put it in the SSH command, so one line gets you back to the agent:
ssh -t you@your-server tmux new -A -s fix-tests Enter fullscreen mode Exit fullscreen mode Claude Code's Remote Control docs recommend the same thing for remote machines: "start it inside tmux or screen to keep the session running after you disconnect from SSH."
Two agents in one checkout overwrite each other's files. A git worktree gives each one its own directory and branch from the same repository. You can start the tmux session in that directory without attaching:
cd ~/code/myapp git worktree add../myapp-fix-tests -b agent/fix-tests tmux new -d -s fix-tests -c ~/code/myapp-fix-tests claude Enter fullscreen mode Exit fullscreen mode -d starts the session detached and -c sets its working directory. When the task is merged, clean up with tmux kill-session -t fix-tests and git worktree remove../myapp-fix-tests.
Both CLIs can also create the worktree for you. Claude Code has claude -w feature-auth, and its docs list a --tmux flag that creates a tmux session for that worktree ( claude -w feature-auth --tmux ). Codex has a --worktree flag that starts a session in a new managed Git worktree.
Attaching to each session to see what it's doing gets slow. tmux can print a pane's current screen instead:
tmux capture-pane -p -t fix-tests | tail -20 Enter fullscreen mode Exit fullscreen mode And it can type into a session without you attaching, which is enough to answer a yes/no question:
tmux send-keys -t fix-tests "y" Enter Enter fullscreen mode Exit fullscreen mode Read the screen before you send anything, because the keys go to whatever prompt is open at that moment.
If you keep several agents as windows in one session, monitor-silence marks a window in the status bar after it has printed nothing for a number of seconds. A quiet agent is often one waiting for you:
tmux set-option -w -t agents:claude monitor-silence 60 Enter fullscreen mode Exit fullscreen mode It is a rough hint. A quiet window might also be an agent thinking through a long step, or one that's finished.
If the tmux session is gone, for example after a reboot, the conversation usually isn't. Both CLIs keep transcripts on disk and can pick up where they left off:
claude -c # continue the most recent conversation in this directory claude -r "fix-tests" # resume a session by ID or name (name it with: claude -n fix-tests) codex resume --last # resume the most recent Codex session in this directory Enter fullscreen mode Exit fullscreen mode For jobs that shouldn't stop to ask you anything, both have a non-interactive mode: claude -p "..." and codex exec "...". These also run fine inside tmux, and codex exec resume --last continues the most recent exec session.
With two or three agents, the steps above are all you need. As the number grows, the same problems come up:
tmux still does its part fine. You're just doing a manager's job by hand on top of it.
The agents themselves have added some of this, and a few open-source tools wrap many agents at once. Checked on 3 Dec 2026 against each tool's own docs, site or repository, plus the adecomparison.com data ( madeinorbit/ade-comparison, published by Podium).
All of these use your own agent subscriptions or API keys, so the agent cost comes on top, and so does the server if you want agents running with the laptop closed.
A short way to pick: if all your agents are Claude, try agent view and Remote Control first, since they ship with Claude Code. Same for Codex if you already use the ChatGPT desktop app. If you mix agents, you want one of the open-source managers on a machine that stays on.
Since we build it: Podium runs the agent CLIs you already use in persistent terminals on a machine you own. Each task gets its own branch and worktree, so steps 1 and 2 above happen when you start a task. Closing a browser tab or the laptop doesn't stop the agent on the server. From a terminal, the supervision steps look like this ( docs ):
podium session status your_session_id # state, phase, changed files podium session read your_session_id --turns 8 # recent transcript podium session send your_session_id \ --text "Run the focused test and attach the result." Enter fullscreen mode Exit fullscreen mode Where it falls short today:
The VPS guide covers installing it on a server, and the source is on GitHub.
Last verified 3 Dec 2026. These tools change weekly; if something here is out of date, tell us in the comments and we will fix it.
Written with AI assistance and reviewed by the Podium team.