How to run Claude Code overnight on a Mac
A practical checklist for leaving Claude Code working while you sleep: power, sleep settings, permissions, prompts and a safe place to work.
By Harsh Soni, maker of Latte · Updated
Claude Code can work through the night if four things hold: the Mac stays awake, Claude has permission for what the task needs, someone can answer the prompts it still raises, and the work happens somewhere you can review and undo.
1. Give it a task that can finish on its own
Overnight runs go best with a clear finish line: “make these tests pass”, “migrate these 40 files to the new API”, “write tests for this module”. Put the plan in a file Claude can re-read, and tell it what done looks like.
2. Work on a branch or a worktree
Keep the overnight work away from your main checkout, so the morning review is one diff:
git worktree add ../myapp-overnight -b overnight/refactor
cd ../myapp-overnight && claudeAsk Claude to commit as it goes. Small commits make it easy to see where a run went wrong.
3. Allow the commands it needs, and nothing more
Every permission prompt is a place the run can stall. Allow the safe, repetitive commands in advance in .claude/settings.json:
{
"permissions": {
"allow": ["Bash(npm run test:*)", "Bash(npm run lint)", "Bash(git commit:*)"]
}
}Avoid --dangerously-skip-permissions on your main machine. It lets the agent run anything without asking. If you want no prompts at all, run it inside a container or VM that holds nothing you'd miss.
4. Keep the Mac awake
- Plug it in. A long run on battery can end with a flat Mac.
- Lid open: Claude Code holds off idle sleep while it works on recent versions. Add
caffeinate -i claudeif you want to be sure. - Lid closed: you need clamshell mode,
pmset disablesleep, or a tool. See keeping Claude Code running with the lid closed. - Updates: make sure macOS won't restart for an update in the middle of the night.
5. Have a way to answer prompts
Even with a good allow list, Claude will sometimes ask a question or want a command you didn't list. If nobody answers, the run waits until morning. Get those prompts to your phone: how to approve Claude Code prompts from your phone.
6. Review in the morning
- Read the commit log and the diff before you merge anything.
- Run the tests yourself. Don't rely on “all tests pass” in the transcript.
- Check what was installed or deleted along the way.
Where Latte fits
Latte (which I make) covers steps 4 and 5 and part of 6: it keeps the Mac awake while Claude works, lid closed included, defers update restarts during the run, sends prompts and questions to your phone, pauses the agent if the Mac gets hot or the battery reaches your floor, and leaves a morning report of what ran. When the work is done, the Mac sleeps.
Common questions
- Can Claude Code run overnight on a Mac?
- Yes, if the Mac stays awake and Claude doesn't stop on a permission prompt. Keep the Mac on power, hold off sleep, allow the commands the task needs in advance, and have a way to answer prompts from your phone.
- Should I use --dangerously-skip-permissions for overnight runs?
- Not on your main machine. It lets the agent run any command without asking. Prefer an allow list of specific commands in your settings, or run it inside a container or VM with nothing important in it.
- How do I know what Claude did overnight?
- Have it work on a separate git branch or worktree and commit as it goes, then read the commits and diff in the morning. Latte also writes a morning report of what ran, finished and paused.
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.