I noticed and quite like claude-code’s feature where it seems to spawn a caffeinate instance every 5 mins keeping the agent running even when my laptop is locked/closed. I do think they shouldn’t force it to happen like they do and it should be a config option to enable or disable this feature, but I’d love this for cursor cli also rather than having to manually turn caffeinate on myself. Or is there a workaround anyone knows of?
Right now the standalone CLI doesn’t manage system sleep on its own, so on macOS the simplest workaround is to run caffeinate in the same terminal next to the agent:
caffeinate -i keeps the machine awake while the command is running
caffeinate -t 28800 prevents sleep for a fixed window of time, 8 hours in this example
Making this a built-in toggle option in the CLI is a good idea, and your point that it should be opt-in rather than forced also makes sense. I’ll keep the thread open so other users can upvote and share their use cases, it helps with prioritization.
If any of the workarounds don’t work for you, let me know.
Thanks for reading my post! So good to see the staff looks at and responds to pretty much every request.
Yeah, I’ve been activating caffeinate myself in a separate terminal tab which works fine. Though it would be much nicer if it was only active while the agent was running (including waiting for shell commands or monitored things) and then my computer could go to sleep as normal afterwards, saving power. Understood if its not a priority! I suppose we’ll only know if others are keen for it and vote
Your clarification makes total sense, and in my view it’s the most reasonable approach: keep the machine awake only while turn is actually active, including while it’s waiting for shell commands, and then let the computer sleep normally afterward so you don’t drain the battery.
I’ll leave the thread open for now so other users can vote and share their use cases. If caffeinate in a separate tab stops working for you at some point, just reach out and we’ll suggest something else.
Small gotcha here: caffeinate -i handles idle sleep, but closing a MacBook uses a separate lid-sleep path, so it still won’t keep the machine running with the lid actually shut.
If you’re just locking the screen, Dean’s workaround is the simplest option. I kept running into the closed-lid case and ended up building Clamshell for it (https://clamshell.dev). It only changes lid behavior while armed, then restores normal sleep when you open or disarm it.
I’d still vote for the Cursor toggle though. Tying caffeinate to the agent process is much cleaner than leaving it running in another tab.