Does tmux keep Claude Code running when your Mac sleeps?
No. tmux survives a closed terminal window, not a sleeping Mac. What tmux does protect you from, and what to pair it with.
By Harsh Soni, maker of Latte · Updated
No. tmux keeps your session alive when you close the terminal window or drop an SSH connection. It can't keep the Mac awake, so when the Mac sleeps, Claude Code inside tmux is frozen with everything else.
What tmux protects you from
- Closing the terminal window or quitting the terminal app by accident.
- An SSH connection dropping while you're working on the Mac remotely.
- Losing your place: you can detach, then re-attach later from another window or device.
What it doesn't
Sleep happens below tmux. When macOS sleeps, it suspends every process, including the tmux server and whatever is running in it. On wake they carry on, but any network request that was in flight may have failed, and the hours in between were lost.
| What happens | Without tmux | With tmux |
|---|---|---|
| You close the terminal window | Agent is killed | Keeps running |
| SSH disconnects | Agent is killed | Keeps running |
| Mac goes to idle sleep | Frozen | Frozen |
| You close the lid | Frozen | Frozen |
Pair tmux with a keep-awake
Run your agent through caffeinate inside tmux, so the Mac stays awake for exactly as long as it runs:
tmux new -s agent 'caffeinate -i claude'
# detach with Ctrl-b d, re-attach with:
tmux attach -t agentThat covers idle sleep with the lid open. For a closed lid you still need clamshell mode, pmset disablesleep, or a tool that manages it. All the options are in keeping Claude Code running with the lid closed.
With Latte
Latte (which I make) works alongside tmux. It watches Claude Code, Codex and Grok through their hooks whether they run in tmux or a plain terminal, keeps the Mac awake while they work with the lid open or closed, and lets it sleep when they're done.
Common questions
- Does tmux prevent a Mac from sleeping?
- No. tmux keeps a terminal session alive when you close the window or disconnect from SSH. When the Mac sleeps, everything inside tmux is frozen along with the rest of the system.
- How do I keep a tmux session running with the Mac awake?
- Run the command through caffeinate inside tmux, for example tmux new -s agent 'caffeinate -i claude'. The Mac stays awake until the command exits, as long as the lid stays open.
- Does tmux help with the lid closed?
- Not by itself. Closing the lid sleeps the Mac whatever is running in tmux. You need clamshell mode, pmset disablesleep, or a tool like Latte.
Latte keeps Claude Code, Codex and Grok working with your MacBook closed, sends approvals to your phone, and lets the Mac sleep the moment the work is done.