Running Claude Code Overnight: tmux, Permission Modes, and a Cloud VM That Does the Setup
Running AI coding agents unattended overnight turns a prompt-by-prompt session into a batch job, but only if you handle process persistence, permission guardrails, and task framing. The permission and prompt-hygiene patterns here transfer to any CLI-based agent, not just Claude Code, and the decision to move to a preconfigured cloud VM reflects a real shift in how developers are buying compute for AI workloads.
Long Claude Code tasks die when your terminal session drops or your laptop sleeps. The fix is a two-part setup: tmux keeps the process alive outside the session, and the machine stays powered on. tmux lets you detach with `Ctrl+B D` and reattach later, and `tmux capture-pane` gives a quick progress read from a phone. For overnight runs, the default permission prompts will stall the job; starting with `--permission-mode auto` lets a classifier pass normal operations while blocking dangerous ones like force-pushes or piping downloaded scripts to bash. Project-level deny rules in `.claude/settings.json` ban `git push`, `rm -rf`, and reading `.env` as a final guard.
The quality of the output depends almost entirely on the task description written before bed. The article recommends creating a dedicated branch, writing project conventions into `CLAUDE.md` (test commands, commit-per-step, "don't ask, decide and record"), and phrasing the task as goal plus acceptance criteria. Two advanced moves: `claude -p` for fully unattended non-interactive runs with `--max-turns`, and a Stop hook that pings a webhook when the job finishes. On machine choice, the author switched from self-managed VPS to ApexOne, a cloud development VM that comes with Claude Code, Docker, and toolchains preinstalled, boots in two minutes, and auto-sleeps when idle. The guide closes with a checklist of failure modes (usage caps, context compression, clueless loops) and a morning acceptance sequence: `git log`, `npm test`, `git diff`, and reading `NOTES.md`.
The 80% rule for task description is plausible because overnight AI delegation removes the feedback loop; whatever you write is the only correction mechanism available.
Permission modes and deny rules are what make unattended AI coding safe enough to try; without them, the default ask-on-every-action behavior stalls the job, and the all-access mode gives the model your whole machine.
The move to a preconfigured cloud VM with auto-sleep reflects a growing pattern: developers are paying for short-lived, disposable environments rather than maintaining always-on VPSes, because most overnight tasks are bursty, not continuous.
The article's advice to let the agent decide and record rather than ask is a direct acknowledgement that a human-in-the-loop model doesn't scale to unattended runs; you trade perfect decisions for a reviewable audit trail.
tmux keep-alive plus clear acceptance criteria is indeed key. If the permission whitelist is not tightened, running overnight is risky. Thanks for sharing the pitfalls. I usually browse practical articles on this kind of AI programming tools on ai345 by category, and the updates are quite fast.
❤️