No built-in agent setting or open-lid utility keeps your AI coding agent running when you close your laptop: without an external monitor, macOS puts a closed MacBook to sleep and stops local runs until you open it again. To keep AI agents running with the lid closed and no monitor, you need a lid-closed app, and Clamshell for Mac keeps an Apple Silicon MacBook awake on power or battery with no admin password, no sudo and nothing to undo, for $9.99 once after a 7-day free trial.
Written by Matyas Rathonyi, the maker of Clamshell for Mac.
The free fixes, and where they stop
If you can leave the laptop open, macOS already gives you a free command. On macOS 27.2.1, man caffeinate documents -i to prevent idle sleep while a command runs:
caffeinate -i <command>
caffeinate -i -t <seconds>
caffeinate -i -w <pid>
pmset -g assertions
At a desk with an external monitor, power, keyboard and mouse connected, Apple's own setup (Apple Support 102501) also keeps a closed MacBook awake at no cost.
Both free routes stop the moment you close your laptop without a monitor:
- Built-in agent settings do not cover a closed lid. Anthropic's Claude desktop docs say its Keep computer awake setting prevents idle sleep and "Closing the laptop lid still puts it to sleep." OpenAI documents "Prevent sleep while running" for local chats with no lid wording (and lists
features.prevent_idle_sleepas experimental and off by default). OpenClaw's docs say closing a Mac laptop lid forces the host to sleep. VS Code 1.148's preview settingsessions.keepAwakeWhileWorking(unreleased as of November 23, 2026) says in its test plan that it prevents "idle system sleep, not the screen turning off, closing the lid, or explicitly choosing Sleep." - Popular open-lid menu bar apps stop at the lid. KeepingYouAwake's README states it "will only prevent sleep on desktop Macs and portable Macs with an open lid." Lungo's maker states it is "only able to keep your Mac awake if it's connected to a charger and an external display."
caffeinatedoes not promise closed-lid runs. The macOS 27.2.1caffeinatemanual lists-sfor AC power only and says nothing about closing the lid.sudo pmset -a disablesleep 1asks for admin access and manual cleanup. You need an admin password to turn sleep off and you must remember to runsudo pmset -a disablesleep 0afterward to restore normal sleep.
Why choose Clamshell for closed-lid agent runs
If you want to close your laptop, walk away and come back to finished work without handing over an admin password or managing terminal flags, Clamshell is built for that job:
- No admin rights, no sudo, nothing to undo. Clamshell keeps a closed Apple Silicon MacBook running on power or battery with no admin password, no
sudoersfile and no privileged helper to stay awake. Normal lid sleep returns when you disarm or quit. - Built-in agent modules plus URL automation. Optional modules (Finish Work, Then Sleep, Agent Status and Agent Notifications) follow Claude Code, Codex, Grok, OpenCode and Kiro so your Mac can sleep once your agents finish. Any other agent or script can arm and disarm with
open "clamshell://arm"andopen "clamshell://disarm". - Always-on heat protection and a 20% battery floor. Thermal safety stays on and disarms toward normal sleep on serious or critical thermal pressure. Low-battery disarm at 20% on battery is on by default.
- Notarized and ready to install. Clamshell is notarized by Apple for Apple Silicon Macs on macOS 14 or later, available by direct download, Homebrew (
brew install --cask clamshell) or Setapp.
Try it on your next agent run before paying anything: Download free trial (free for 7 days, no card required; $9.99 once for 1 Mac or $19.99 for up to 3 Macs, with a 14-day money-back guarantee).
Closed-lid apps for AI agents side by side
Here is how Clamshell compares with three closed-lid apps that readers meet most often when running coding agents on a Mac, from each maker's own page as checked on November 23, 2026:
| Clamshell | Amphetamine | Keepresso | LidRun Pro | |
|---|---|---|---|---|
| Closed lid, no monitor | Yes, power or battery | Yes; plug/unplug ends it without Power Protect | Yes, power or battery | Yes, Pro tier only |
| Admin step | None to stay awake | None, or admin for Power Protect | Admin password or helper | Needs admin authorization |
| Price | $9.99 once (1 Mac) | Free | Free (GPL-3.0) | $9.90 launch (1 Mac) |
| Agents followed | 5 agents plus URL scheme | None (app triggers only) | 19 named agents plus hooks | Claude Code, Codex, Cursor, Ollama |
| Mac and macOS | Apple Silicon, macOS 14+ | macOS 10.13+ | macOS 14+ | Apple Silicon and Intel, macOS 13+ |
| Free trial | 7 days, no card | Free app | Free, open source | Free tier (lid open only) |
Verdict: Choose Clamshell if you want closed-lid agent runs on an Apple Silicon MacBook with no admin password or helper; choose Keepresso or LidRun Pro if you have admin rights and want wider agent detection, open-source code or Intel support.
What the free closed-lid apps ask of you
Free apps can keep a closed MacBook running an agent, but each asks for an admin step or drops the run when the power changes:
- Amphetamine: Its 5.3 release notes say Closed-Display Mode works without its script, but on Apple Silicon laptops plugging in or unplugging power ends the session. To survive that, its Power Protect add-on installs
/private/etc/sudoers.d/amphetamine_powerProtectafter Touch ID or an admin password once. Its last App Store update was November 2023. - Keepresso: Its site says closed-display mode asks for an administrator password, or you approve an optional privileged helper once so it stops asking when the app restarts.
- Adrafinil: A free MIT-licensed agent tool that requires macOS 26.4 or later and "administrator approval for the privileged helper."
Why pay $9.99 once for Clamshell? You skip admin passwords, sudoers files, privileged helpers and macOS 26 version floors while getting always-on heat protection, a 20% battery stop and normal lid sleep back when you disarm or quit.
When another app is the better pick
- You run an Intel Mac or macOS 13. Clamshell requires Apple Silicon and macOS 14 or later. LidRun Pro supports Intel Macs and macOS 13 or later.
- You require open-source code or built-in hooks for more than five agents. Clamshell is closed source, and its native agent modules follow Claude Code, Codex, Grok, OpenCode and Kiro (other tools can still use
clamshell://arm). If you have admin access and want free open-source code with built-in hooks for tools like Cursor, Gemini CLI or Aider, Keepresso (GPL-3.0) or Adrafinil (MIT, macOS 26.4+) cover more agents out of the box.
Frequently asked questions
Do AI coding agents' own keep-awake settings keep running when I close my laptop?
No. Anthropic's Claude desktop docs say closing the laptop lid still puts it to sleep, OpenAI's Prevent sleep while running setting has no lid wording, OpenClaw's docs say closing a Mac laptop lid forces sleep, and VS Code 1.148's preview setting explicitly excludes closing the lid. To keep local runs going with the lid closed, use a lid-closed app like Clamshell.
Does caffeinate keep an AI agent running with the lid closed?
Not by its manual. Apple's macOS 27.2.1 caffeinate manual documents -i for idle sleep and -s for system sleep on AC power only, and says nothing about closing the lid. For unattended overnight runs with the lid closed, use a dedicated lid-closed app instead.
Why pay $9.99 for Clamshell when free lid-closed apps exist?
Each free lid-closed app above asks for an admin step before it holds a run through power changes: Amphetamine's Power Protect sudoers file, Keepresso's administrator password or helper, or Adrafinil's privileged helper. Clamshell costs $9.99 once with no subscription so you can keep a closed Apple Silicon laptop running with no admin password, always-on thermal safety and a 20% battery floor. Start the 7-day free trial to test it on your own workflow first.
Do I need admin rights to keep a closed Mac running AI agents?
Not with Clamshell: it keeps a closed Apple Silicon MacBook awake with no sudo or admin password. sudo pmset -a disablesleep 1, Keepresso and Adrafinil need admin rights, and Amphetamine needs them to keep a session through plugging in or unplugging. If you are on a work laptop, see how to keep a work MacBook awake without admin rights.
What if I run OpenClaw or GitHub Copilot in VS Code, or want an overnight checklist?
For tool-specific behavior, read will OpenClaw keep running if you close your MacBook and will GitHub Copilot in VS Code keep running if you close your laptop. For heat, power and network checks before leaving agents overnight, read how to run AI agents overnight on a MacBook, or compare MacBook vs Mac mini for AI agents.
Try Clamshell free for 7 days
Close your laptop and let your AI agents finish their work, with no admin password, an always-on heat cut-off and a 20% battery floor. Normal lid sleep returns when you disarm or quit.
$9.99 for 1 Mac, $19.99 for up to 3 Macs. 7-day free trial with no card required and a 14-day money-back guarantee. Apple Silicon, macOS 14 or later, notarized by Apple. Also available via Homebrew or Setapp.
Sources checked November 23, 2026: Apple Support article 102501, the macOS 27.2.1 caffeinate(8) manual, Anthropic's Claude desktop and Claude Code documentation, OpenAI's ChatGPT desktop settings and Codex config reference, OpenClaw documentation, the VS Code 1.148 test plan (microsoft/vscode#349545), and the product pages, GitHub repositories and App Store listings of Amphetamine (and Power Protect), Keepresso, Adrafinil, LidRun, KeepingYouAwake and Lungo. Every detail about rival apps comes from their own pages on that date. Clamshell details come from version 2.0.5. Product names belong to their respective owners.