lidhold holds your Mac awake exactly as long as a task runs, whether that is Claude Code working or a test suite you kicked off, and lets it sleep the moment it is done.
macOS 14 or newer. One purchase, up to 3 of your machines.
$ lidhold status holding via pmset for agent leases since 15:15 lease claude-code:e274cdfc: 29m 52s left lease run:cargo:78357: 29m 59s left [ok] engine pmset: holds with lid closed, on AC or battery power: battery 61%, built-in display only guards: battery floor 20%, thermal nominal, ceiling heavy $ lidhold doctor [ok] privileged helper installed and responding [ok] daemon running (last tick 4s ago) [ok] claude-code hooks installed No blocking problems.
The problem
Closing the lid is an explicit sleep request. macOS honours it over every user-level tool, so a long agent task gets suspended mid-way and you come back to nothing. The override exists, but it is all-or-nothing and it never turns itself off. lidhold applies it only while an agent is actually working, and undoes it the moment that stops.
The lid still wins. It only survives a closed lid in clamshell mode: external display plus AC power.
sudo pmset -a disablesleep 1 works on AC or battery. Forget to revert it and the Mac cooks in a bag or drains to zero.
Good for manual sessions. It has no idea when an agent starts or finishes, so you are back to remembering.
Held while a lease is alive, released two minutes after the agent stops, reverted by a watchdog if lidhold itself dies, cut short by battery and thermal guards.
$ lidhold doctor What will happen if you close the lid: [ok] engine pmset: holds with lid closed, on AC or battery [fail] engine assert: will NOT survive lid close, no external display -> `lidhold on` would use pmset [ok] guards: battery floor 20%, thermal nominal, ceiling heavy [ok] claude-code hooks installed
Run it before you trust anything. It says, for your machine, what will and will not hold.
How it works
Every tool call your agent makes refreshes a lease. While a lease is alive, the Mac stays awake through a closed lid. When the agent finishes, the lease winds down and the Mac sleeps like normal.
brew install, then lidhold setup. One sudo prompt for the helper that overrides lid sleep.
Claude Code, Cursor, or Copilot CLI takes a lease through its hooks the moment it starts working. Anything else, wrap it: lidhold run -- cargo test.
The Mac keeps running, on AC or battery. Walk away, put it in your bag, get coffee.
Two minutes after the last turn, the lease expires and the Mac sleeps. Follow up sooner and it stays awake.
Any job
Not every long task is an agent. Wrap any command and the Mac holds for exactly as long as it runs: the hold starts before the first line of output and ends with the exit code, which passes straight through.
$ lidhold run -- cargo test $ lidhold run -- ./deploy.sh --prod $ lidhold run -- rsync -a ~/big/ backup:/big/
Ctrl-C reaches the command. stdout is untouched. A crashed wrapper cannot pin the Mac: the lease it took expires on its own.
Guards
A closed laptop can drain or overheat. Two guards watch for that and release the hold, then tell you why. They are free on every tier and can never be paywalled.
Ignored on AC power. Set the floor to anything, or 0 to turn it off.
Reads macOS thermal pressure directly. Heat outranks battery: a hot machine releases first.
The root helper undoes the override after 90 seconds without a heartbeat. A crash can never pin your Mac awake.
Pricing
Try the whole thing free for 7 days, no key needed. After that, agent hooks need a license. Manual holds and the guards stay free forever.
Free: lidhold on --for 2h, off, status, doctor, both guards.
Paid: the part that makes it automatic.
lidhold license
lidhold run for any command, and a lease API any tool can calllidhold license deactivateSecure checkout by Dodo Payments. Taxes handled at checkout.
Install
Homebrew installs the binaries. lidhold setup installs the privileged helper (that is the one sudo prompt), starts the per-user daemon, wires Claude Code hooks if it finds Claude Code, and runs doctor so you can see exactly what will and will not hold on your machine.
$ brew install aanjaneykumarverma/tap/lidhold $ lidhold setup [ok] privileged helper installed [ok] per-user daemon running [ok] Claude Code hooks installed (restart any open session)
Connecting an agent: lidhold setup installs hooks for every agent it finds: Claude Code, Cursor, and GitHub Copilot CLI. Installed one later, or want to check? lidhold hooks install claude-code, cursor, or copilot, then restart any open session. lidhold hooks status <agent> shows what is wired. Nothing to do per session after that.
Then enter your key: lidhold license activate <key>. It arrives by email right after purchase.
FAQ
Closing the lid is an explicit sleep request that user-level tools cannot override. lidhold installs a tiny root helper that flips one setting, pmset disablesleep, and reverts it on its own after 90 seconds without a heartbeat. Only admin users can talk to it.
Yes. That is the point. The battery guard releases the hold below 20% (adjustable) so you never come back to a dead machine.
A permission prompt or a question means no tool calls, so the lease runs out and the Mac sleeps. Nothing is working, so nothing is held. Auto mode or pre-approved permissions avoid it.
Only when you activate, and once a week after that to check the key is still valid. If that check cannot reach the server, nothing changes. A closed laptop keeps working offline.
Yes. lidhold run -- <command> holds for exactly as long as that command runs and releases when it exits, whatever the exit code. A test suite, a deploy, a long download.
Cursor and GitHub Copilot CLI are supported the same way: lidhold hooks install cursor (both the cursor-agent CLI and the IDE) or lidhold hooks install copilot. Any other tool that can run a command can take a lease directly: lidhold lease take my-agent --ttl 10m.
Email within 14 days and you get one. The 7-day trial exists so you rarely need to.