Three things have to stay alive, and most guides only cover one. Start the work with
claude --bg so a supervisor process owns it instead of your terminal. Stop the
Mac sleeping with caffeinate -s on mains power. Then give the work itself a
folder and a schedule, because a session is not a home.
The three layers, in order
- The session. Run
claude --bg "your task", or press/bginside a session you have already started. Anthropic's own documentation is flat about what that buys: "Background sessions don't need any terminal open to keep working. A separate supervisor process runs them, so you can close agent view, close your shell, or start a new interactive session and your dispatched work keeps going." - The machine. A backgrounded session still stops when the Mac sleeps.
caffeinate -sholds a system-sleep assertion for as long as it runs, andcaffeinate -s claude --bg "…"holds it only for the life of that command. - The work. This is the step the other guides skip. A session that stays up is not a tool that keeps running. If the job has to happen again next Tuesday, something outside the session has to own it: a folder it lives in, a place its output accumulates, and a schedule that starts it.
caffeinate, flag by flag
From man caffeinate on macOS, not from a blog. With no flags at all it
prevents idle sleep and nothing else.
| Flag | What it asserts |
|---|---|
-i | Prevents the system idle-sleeping. |
-s | Prevents the system sleeping. Valid only while the Mac is on AC power. |
-d | Prevents the display sleeping. |
-m | Prevents the disk idle-sleeping. |
-t n | Drops the assertion after n seconds. |
-w pid | Holds the assertion until that process exits. |
Two consequences worth knowing before you rely on it. -s does nothing on
battery, so an unplugged laptop sleeps whatever you typed. And the lid is a separate case
from idle sleep — if your plan is to shut the laptop and walk away, test that exact thing
once rather than assuming the flag covers it.
If it has to run on a schedule, pick the right one
Claude Code now ships three schedulers, and they differ in the one way that matters: which of them can see the files on your Mac.
| Option | Runs on | Needs the Mac on | Sees your local files | Shortest interval |
|---|---|---|---|---|
/loop | Your machine | Yes, with the session open | Yes | 1 minute |
| Desktop scheduled tasks | Your machine | Yes | Yes | 1 minute |
| Routines, in the cloud | Anthropic's machines | No | No — a fresh clone | 1 hour |
So the tempting answer — put it in the cloud and stop worrying about sleep — is the one answer that cannot touch your receipts folder, your camera roll or your bank exports. For anything reading your own files, the Mac has to be awake, and that is not a limitation anyone can engineer away.
One more thing to know about /loop: tasks are scoped to the session, and
recurring ones expire seven days after you create them. They fire a last time, then delete
themselves. A forgotten loop is bounded on purpose, which is good design and also means
/loop is not where a monthly job belongs.
What actually breaks it
- Battery.
caffeinate -sis void off mains. - Reboot. Nothing above survives a restart. A macOS
LaunchAgentdoes, and it has one property cron lacks: perman launchd.plist, "Unlike cron which skips job invocations when the computer is asleep, launchd will start the job the next time the computer wakes up." - The seven-day expiry on recurring
/looptasks. - Nothing to come back to. A session that ran all night and wrote its output into the conversation has produced nothing you can open tomorrow.
That last one is the one Nico exists for. Each tool it builds gets a folder of its own outside any session, a data folder that survives every run, and ten kept versions — so the thing that ran at 3am has somewhere to have put the answer.
← All notes