One thing worth adding is that keeping the machine awake solves only the infrastructure side of the problem. It doesn’t guarantee the agent task survives a dropped API connection, terminal crash, or unexpected reboot.
For longer coding tasks, I’d treat caffeinate and tmux as convenience measures, but make the workflow resumable as well: persist task state, keep important outputs in files or commits, and make tool operations safe to retry. That way, even if the Mac does sleep, the work doesn’t have to start from zero. An always-on machine improves availability; recoverability is what makes the setup reliable.
Good point, and I agree. Staying awake only keeps the Mac alive. It does not save the work.
A few things that help with Claude Code in particular:
claude --continue picks up the last session in that folder, and claude --resume lets you choose an older one. A crashed terminal does not have to end the task.
Ask the agent to commit after each working step, on its own branch. A bad reboot then costs one step, not the whole run.
Keep a short progress file in the repo with what is done and what is next. After a restart, the agent reads it and carries on.
On a Mac that runs unattended, set sudo pmset -a autorestart 1 so it comes back on by itself after a power cut.
Thanks for adding this. Recoverability is the part most setups skip.
Mateo Ruiz
One thing worth adding is that keeping the machine awake solves only the infrastructure side of the problem. It doesn’t guarantee the agent task survives a dropped API connection, terminal crash, or unexpected reboot.
For longer coding tasks, I’d treat
caffeinateandtmuxas convenience measures, but make the workflow resumable as well: persist task state, keep important outputs in files or commits, and make tool operations safe to retry. That way, even if the Mac does sleep, the work doesn’t have to start from zero. An always-on machine improves availability; recoverability is what makes the setup reliable.