Free and open source, for macOS 14 or later

MacBook sleep control for AI coding agents

Close the lid while Claude Code, Codex or T3 Code works. The Mac stays awake with the screen at 0%, then may sleep once every agent is waiting for you.

Claude Code and Codex sessions, reported by hooks

The installer adds hooks for Claude Code and Codex, and Settings shows each file that holds them; T3 Code is read directly. The status command prints every session in a terminal, with the decision under it.

See which tools report

The Mac may sleep once the work is done. Four rules decide when.

Follows each agent’s hooks

Claude Code and Codex report every prompt, tool call and stop through hooks. T3 Code’s own database is read every 5 s.

Turns the display off with the lid shut

Brightness goes to 0% and comes back, at least 10%, when you open the lid. With an external display, macOS keeps control.

Settings · General
3 of 3 on
  • Keep the Mac awake while agents workAutomatic Mode
  • Turn the display off when the lid is closedRestored when the lid opens
  • Start at loginThrough launchd

Waits for Claude’s notification

By default a waiting Codex session gets 10 s. When Claude finishes or asks a question, it usually gets 70 to 90 s, so its notification still goes out.

  • Claude is waiting for your inputphoto-app
  • Claude needs your permission to use Bashinfra

Lets go at low battery or serious heat

Low battery or serious heat brings normal sleep back, even during a hold by hand. A silent or exited session stops counting.

What lets the Mac sleep again
5 of 5
  • On battery at 15% or less (the default)
  • Thermal state serious or critical
  • A session silent for 30 min (default)
  • A session whose process has exited
  • You quit the app

Why it exists

Closing a MacBook’s lid puts it to sleep, even with caffeinate running. Agent Lid Closed keeps it awake while an agent has work, or while you ask it to, then gives sleep back.

Wakes the Mac before a usage limit resets

When a live Claude or Codex session stops at a subscription limit whose reset is known, the Mac can sleep, then wakes two minutes before the reset: within 24 hours in a terminal, seven days in T3 Code. A closed-lid wake is best effort.

With its auto-resume on, T3 Code continues the conversation at the reset, and with two accounts of one tool it can move it to the free one at once. Terminal Claude continues when its own setting for that is on.

Read what wakes it

Works with Claude Code, Codex and T3 Code

The installer adds hooks only for the tools it finds. One tool is enough; a second Claude Code account can be added later in Settings.

  • Claude Code in a terminalHooks

    Wakes before resets with version 2.1.234 or later.

  • Codex CLIHooks

    Once you trust its hooks under /hooks. A wake does not start a new Codex turn.

  • T3 CodeRead directly

    No hooks needed. T3 continues the conversation at the reset and can switch accounts.

  • Claude desktop, Code tabNot yet confirmed

    Loads the same settings, so it should appear like a terminal session.

  • Cloud sessionsNot tracked

    Claude Code on the web, Chat and Cowork run off your Mac.

  • UserPromptSubmit
  • PreToolUse
  • PostToolUse
  • Stop
  • StopFailure
  • SubagentStart
  • SubagentStop
  • Notification
  • PermissionRequest
  • SessionEnd

Install the app from the terminal. Free under the MIT licence.

macOS 14 or later

Needs Swift 6.2 or later from the Command Line Tools and your administrator password once. Then restart open sessions, and trust the hooks in Codex under /hooks.

Terminal
$ git clone https://github.com/Jin-hiroo/agent-lid-closed.git && cd agent-lid-closed && ./scripts/install.sh

Windows 10 or 11

Needs Node.js 22.16 or later and no administrator rights. Then restart open sessions, and trust the hooks in Codex under /hooks. The menus are in Japanese.

PowerShell
> git clone https://github.com/Jin-hiroo/agent-lid-closed.git; cd agent-lid-closed > powershell -ExecutionPolicy Bypass -File .\windows\install.ps1

Questions

Something else, or a result from the Claude desktop app? Open an issue on GitHub.

Open an issue

What does it change on my Mac?

It sets pmset disablesleep while an agent works and clears it once all of them wait, after a short grace period. Quitting restores normal sleep and brightness.

Can I keep the Mac awake without an agent?

Yes. Keep Mac Awake holds sleep off until you turn it off, or for 30 min, 1, 2 or 4 h, or a time you type, up to 7 days. Low battery and heat still let it sleep.

What does the app read from my sessions?

Only on your Mac: hook events, Claude’s status-line usage and reset times, the usage-limit fields of Codex’s event log, a Claude transcript to spot an interrupted turn, and T3 Code’s database, read-only. No conversation text or account tokens are kept or sent.

What wakes the Mac before a reset?

A root-owned helper that can only schedule this app’s wake alarms, within the next seven days. A closed-lid wake is best effort, so test it plugged in.

How do I remove the app?

From the clone, run ./scripts/uninstall.sh on a Mac, or powershell -ExecutionPolicy Bypass -File .\windows\uninstall.ps1 on Windows. Each removes the app and every hook it added; T3 Code’s auto-resume setting stays as you left it.