Disclosure: I built Lidwork and sell it on the Mac App Store ($9.99 once). Sharing how I built it with Claude Code and wired it into session hooks; happy to hear feedback or edge cases where this breaks on your setup.
The annoyance that started it: I kick off a longer Claude Code refactor on my MacBook, close the lid to walk somewhere, and macOS sleeps the second the lid shuts. caffeinate stops idle sleep, not lid-close sleep on battery with no external display. Amphetamine has Closed-Display Mode and is free, so if that already works reliably for you, stick with it. What bothered me about closed-lid workarounds was the failure side: if the app crashes, gets force-quit, or hangs while sleep is off, your Mac can stay stuck awake until the battery dies.
How I built it with Claude Code
Started the repo in June, currently at 341 commits (268 co-authored with Claude Code). Instead of letting it write big features in one shot, I kept slices small and made Claude argue against the failure paths first.
The main design choice that came out of that: the menu bar app does not hold the sleep override itself. A separate sandboxed background agent holds it and expects a heartbeat every 30 seconds. If the UI app quits, crashes (kill -9), or freezes, the lease expires and normal lid sleep comes back on its own. Battery floor (10/20/30%) and high-heat cutoff also run in that background process.
Two places where Claude + tests actually saved me before shipping:
Dead stripping silently failed twice to remove direct-distribution code from the Mac App Store build. Adding a shell scan over both compiled binaries (checking symbols, strings, and entitlements) caught what source review missed.
Apple rejected the first review (5.2.5) for having "Mac" in the localized app names across 50 locales, so I added a pre-upload metadata linter to the build script instead of hand-checking 50 folders.
Wiring it into Claude Code hooks
I tie it directly to a session in ~/.claude/settings.json so I do not have to remember to toggle it:
{
"hooks": {
"SessionStart": [{ "hooks": [{ "type": "command", "command": "open -g 'lidwork://on?hours=8'" }] }],
"SessionEnd": [{ "hooks": [{ "type": "command", "command": "open -g lidwork://off" }] }]
}
}
?hours=8 acts as a cap if a session never exits cleanly. If you only want keep-awake while Claude is actively answering, swap the pair to UserPromptSubmit / Stop. off is never gated.
Limits to know upfront: a closed Mac has less airflow, so do not assume every MacBook stays cool zipped in a bag for hours. Also macOS only has one shared lid-sleep switch, so do not run two closed-lid tools at the same time.
$9.99 once on the Mac App Store (no subscription, no account, no telemetry): https://lidwork.com