Mac · AI coding agents
Keep your Mac awake while Cursor runs.
A long local agent run stops when the Mac goes to sleep, not when the screen locks. Here are the quickest ways to prevent that, and the limits of each.
Pick a duration and hit start.
Duration
- Stealth screen
- — covers the page with black (or your own wallpaper) so it looks like nothing is open.
- Fullscreen
- — the same cover, edge to edge. Press Esc to leave.
- Float window
- — a tiny always-on-top timer you can park in a corner while you work in other windows (Chrome, Edge, Brave, Opera only).
Ambient sound
Starts only when you press Play. It fades out on its own, when you stop the tool, and when you enter stealth screen (unless you tick the box above).
Two kinds of sleep, only one stops your agent
A Mac can dim and lock its display while the machine itself keeps working, or it can put the whole system to sleep. A locked screen doesn't pause a local Cursor or Claude Code run. Full system sleep does, and the run stays frozen until the Mac wakes.
That's why a screen-on tool alone won't save a long run. Fix system sleep in macOS (below), and use a screen tool only if you want to watch the output without unlocking. The background is on our AI agent page, and Cursor's local-versus-cloud split is on the Cursor page.
Fastest fix: caffeinate in a spare terminal tab
macOS ships a command called caffeinate that holds off sleep for as long as it runs. Open a second terminal tab, start it, and leave it running alongside your agent.
caffeinate -ikeeps the system from idle-sleeping until you press Ctrl+C.caffeinate -i -t 7200does the same for 7,200 seconds (two hours), then stops by itself.caffeinate -i some-commandruns a command and keeps the Mac awake only while it runs.caffeinate -w 12345stays awake until the process with that ID exits. Find the ID withpgrep -f cursoror Activity Monitor.caffeinate -dalso keeps the display on, if you want the screen to stay lit too.caffeinate -sprevents system sleep, but only while the Mac is on AC power.
Run man caffeinate for every flag. Closing the terminal tab, or pressing Ctrl+C, ends it and normal sleep returns.
No terminal: use macOS settings
On a MacBook, open System Settings → Battery → Options and turn on the option to prevent automatic sleeping on the power adapter when the display is off. On a desktop Mac the same switch is under Energy. Under Lock Screen you can also lengthen how long the display stays on when inactive. The wording differs between macOS versions, so search Settings for "sleep" if you can't find it.
The settings route is permanent until you undo it, which is why many people prefer a timed caffeinate command for a single long run.
The closed lid is a separate case
Closing a MacBook lid puts it to sleep, and caffeinate doesn't reliably change that on its own. The supported way to keep working with the lid closed is clamshell mode: power connected, an external display attached, and usually an external keyboard or mouse. For a long agent run with no external display, leave the lid open and let the screen lock instead.
For work that must survive a closed laptop, Cursor's own cloud agents run on Cursor's servers, so your Mac sleeping doesn't interrupt them.
Where this site fits
The tool above keeps the screen on while its tab stays visible. It can't stop system sleep, because browsers don't offer that. If you want a toolbar button for the whole-computer case, the free Keep Screen Unlocked Chrome extension has a "Computer awake" mode alongside screen-on, with a timer from 15 minutes to 4 hours. A closed lid still puts the Mac to sleep with either.
Questions
- Doesn't Cursor keep my Mac awake by itself?
- Cursor staff have said the app keeps the machine awake while an agent runs, but that it can't override what the operating system does when you close the lid. If a long run still stalls, add a
caffeinatecommand as a backstop. - Will caffeinate drain my battery?
- Yes, a Mac that never sleeps uses more power. Plug in for long runs, and use the
-tflag so it ends on its own. - Does this work for Claude Code and other terminal agents too?
- Yes. The sleep behavior belongs to macOS, not to any one app, so the same commands help any local agent. See Claude Code for its specifics.