Cursor keeps the Mac awake while an agent runs, but only with the lid open: closing the lid still sleeps the Mac and pauses local agents.
agent command pauses tooClamshell for Mac keeps the Mac awake with the lid closed while armed. No sudo, no monitor. Free for 7 days, then $9.99 once.
Download free trialIt depends on where the agent is running. Agents in the Cursor editor and in the Cursor CLI work on your Mac, so they stop making progress when a closed lid puts the Mac to sleep. Cursor does hold a wake lock while an agent is actively running, but a Cursor team member confirmed on the Cursor forum that it cannot override the sleep macOS enforces when you close the lid. Cloud Agents run remotely and keep working while your Mac sleeps. To keep a local Cursor agent going with the lid closed and no external monitor, use Clamshell for Mac, a menu bar app that keeps an Apple Silicon MacBook awake with the lid shut and restores normal lid sleep when you disarm it.
Quick answer
Agent in the Cursor editor
Runs on your Mac. Cursor's wake lock covers idle sleep while the agent works, not lid sleep. Close the lid and it pauses.
Cursor CLI
The agent command, interactive or in print mode with agent -p, runs in your terminal on your Mac. Lid sleep pauses it.
Cloud Agents
Run on Cursor's side. You can hand a CLI conversation to one by starting a message with & and follow it at cursor.com/agents.
Local agent, lid closed, no monitor
Arm Clamshell before you close the lid, or use sudo pmset -a disablesleep 1 and remember to undo it.
Which Cursor agent are you running?
Cursor agents run in different places. Only the ones that run on your Mac care about the lid.
| Surface | Runs on | Stops on lid sleep? | What to do |
|---|---|---|---|
| Agent in the Cursor editor | Your Mac | Yes, even with Cursor's wake lock | Keep the Mac awake with the lid closed |
Cursor CLI: agent, agent -p |
Your Mac | Yes | Same as the editor |
| Cloud Agents | Cursor's cloud | No | Nothing on the Mac; check results at cursor.com/agents |
If the task can run in the cloud, a Cloud Agent is the simplest fix: nothing on your laptop has to stay awake. Keep reading if the job needs your local files, tools, credentials, simulators or hardware.
Why a local Cursor agent stops at lid close
- You close the lidmacOS starts lid sleep, separate from idle sleep.
- The wake lock does not block itCursor's wake lock and
caffeinateonly hold off idle sleep. - The agent stops making progressTerminals, test runners and connections stop too.
A Cursor agent that is busy editing code or running tests keeps an idle Mac awake, because Cursor holds an Electron wake lock while the agent works. Closing the lid is different: it triggers lid sleep, which macOS enforces regardless of that wake lock or of apps like Caffeine. Once the Mac is asleep, the agent, its terminals, test runners and network connections all stop making progress. A Cursor team member described exactly this on the Cursor forum in May 2026, and recommended Cloud Agents for work that must continue with the lid closed.
Ways to run a Cursor agent locally with the lid closed
- Apple's closed-display mode. Connect an external display, keyboard and mouse, and power. Reliable if you own the hardware and stay at your desk.
sudo pmset -a disablesleep 1. Keeps the Mac awake with the lid closed, but it is a global, admin-level switch with no timer that also applies on battery. See what pmset disablesleep does and how to undo it.- Clamshell. A menu bar app that overrides lid sleep only while armed. No sudo, no admin rights, no kernel extension, no privileged helper. It uses the unprivileged IOKit clamshell sleep control rather than
pmset, and the setting never survives a restart.
Clamshell for Mac keeps an Apple Silicon MacBook awake with the lid closed, no monitor needed. Free for 7 days, then $9.99 once for one Mac.
Download free trialWrap a Cursor CLI run so it arms and disarms Clamshell
Clamshell accepts clamshell://arm, clamshell://disarm and clamshell://toggle URLs. This wrapper requests arming before a non-interactive Cursor CLI run and requests disarming when the shell exits, so normal lid sleep comes back when the job ends.
set -e
open "clamshell://arm"
trap 'open "clamshell://disarm" || true' EXIT
agent -p "run the test suite and fix the failures" --output-format text \
| tee cursor-result.md
Read the caveats before you rely on it:
openonly delivers a request. A successful exit does not prove Clamshell armed. It can refuse, for example under serious thermal pressure, or pause while an external display is connected. Check the menu bar state before closing the lid.- The EXIT trap is best effort. It does not run if the shell is killed or crashes. Disarm from the menu if in doubt.
- Clamshell does not know about Cursor. It has no Cursor integration and does not detect when an agent finishes. The script is what ends the session.
- Permissions still apply. Check which commands and file changes print mode may run without asking, in Cursor's CLI docs, before you leave it alone. Keeping the Mac awake does not approve anything.
- Setapp edition. The Setapp build uses the
clamshell-setapp://scheme instead.
Clamshell also adds Arm, Disarm, Toggle and Status actions to Shortcuts, which you can combine in a shortcut of your own.
Prove that the agent keeps working with the lid closed
Before trusting a long run, spend two minutes on a harmless check.
- In a Cursor agent chat, with the lid open, ask the agent to run this command in its terminal and approve it:
for i in {1..12}; do date -u '+%Y-%m-%dT%H:%M:%SZ' >> lid-check.txt sleep 10 done - Confirm Clamshell is armed and close the lid for the two minutes.
- Open it and run
cat lid-check.txt. Pass: twelve timestamps about ten seconds apart with no gap while the lid was shut.
Fail: a long gap means the run was interrupted; it does not tell you why. Check Clamshell's state, the terminal, and whether the agent was waiting for an approval, fix it with the lid open, and repeat.
What Clamshell does and does not do
Keeps the lid from sleeping
Keeps an Apple Silicon MacBook on macOS 14 or later awake with the lid closed, with the built-in display dark, and locks the Mac when you open the lid.
Watches heat
Watches macOS thermal pressure at all times. At serious or critical pressure it disarms toward normal lid sleep and blocks arming until the Mac cools.
Handles power changes
Works on battery and on power, and re-applies itself when you plug in or unplug. An optional Disarm on low battery threshold is off by default.
Does not manage Cursor
It does not detect Cursor agents, stop when a task finishes, keep the network up, or move work to the cloud.
Arming with Option held while you close the lid needs the lid angle sensor in a MacBook Air M2 (2022) or later or a 14-inch or 16-inch MacBook Pro (2021) or later; other Apple Silicon laptops arm from the menu bar. Option-close sessions end when you open the lid; menu and URL arming stays on until you disarm.
Frequently asked questions
Does a Cursor agent keep running when I close my MacBook lid?
Cloud Agents do, because they run on Cursor's infrastructure. Agents in the Cursor editor and the Cursor CLI run on your Mac, so closing the lid puts the Mac to sleep and pauses them, unless an external display setup, pmset disablesleep, or a lid-sleep tool such as Clamshell keeps the Mac awake.
Doesn't Cursor already keep my Mac awake while an agent runs?
Only with the lid open. A Cursor team member explained on the Cursor forum in May 2026 that Cursor holds an Electron wake lock while an agent is actively running, but that it cannot override the sleep macOS enforces when you close the lid.
Does Caffeine or caffeinate keep a Cursor agent running with the lid closed?
No. They prevent idle sleep only. Lid-close sleep is a separate path they do not block, so a local Cursor agent still pauses when the lid closes.
Do I need to keep my Mac awake for Cursor Cloud Agents?
No. Cloud Agents run remotely, and you can pick their results up on the web or on your phone at cursor.com/agents. From the Cursor CLI you can hand a task to a Cloud Agent by starting a message with an ampersand.
Does Clamshell stop automatically when the Cursor agent finishes?
No. Clamshell does not detect Cursor or any other agent. To end the session when a job ends, wrap the job in a script that opens clamshell://disarm on exit, or disarm from the menu bar.
Can a Cursor agent keep running on battery with the lid closed?
Yes, if the Mac stays awake. Clamshell works on battery, and you can enable Disarm on low battery so the Mac goes back to normal sleep below a charge level you choose. For long runs, plug in and keep the Mac on a ventilated surface.
Related guides
- Run AI coding agents overnight on a MacBook
- Keep Claude Code running with the lid closed
- Keep Codex running when you close your MacBook lid
- Why caffeinate does not work with the lid closed
- Compare Clamshell, Amphetamine, pmset and Apple's setup
Sources checked October 2, 2026: Cursor's CLI documentation and a Cursor team reply on the Cursor forum (May 6, 2026). Clamshell behavior is described from its app source and FAQ. No new hardware testing was done for this page. Clamshell is an independent app, not affiliated with or endorsed by Anysphere. Cursor is a trademark of its owner.