---
title: How to keep GitHub Copilot CLI running with the lid closed
description: Copilot CLI stops when the Mac sleeps, and closing the lid sleeps a MacBook. Keep Mac Awake keeps it working with the lid closed and no external display.
date: 2026-11-07
kicker: Copilot CLI
section: Agents and remote control
related: steer-ai-agents-from-your-phone, keep-claude-code-running-lid-closed, run-ai-agents-overnight-macbook
---

> **Short answer:** GitHub Copilot CLI runs in a terminal on your Mac, so a task stops when the Mac sleeps, and closing a MacBook's lid puts it to sleep. Its `/keep-alive` command prevents sleep while the session is active, but as of November 2026 GitHub does not say whether that holds when the lid closes. To keep Copilot CLI working with the lid closed, the first choice is a Keep Mac Awake session such as `keepmacawake start --hours 8`: it keeps a MacBook with Apple silicon on macOS 26 or later awake with no external display, then restores normal sleep. Other options are an external display with power, keyboard and mouse, or `sudo pmset disablesleep 1`, which has no timer.

## What happens to Copilot CLI when the Mac sleeps?

It stops with the Mac. The agent's model calls, shell commands and file edits run in the `copilot` process in your terminal, and a sleeping Mac runs nothing. Remote control stops too: "If the machine goes to sleep or loses its connection, remote control is unavailable until the machine is back online" ([about remote control](https://docs.github.com/en/copilot/concepts/agents/copilot-cli/about-remote-control)).

Two kinds of sleep stop it. Apple: "Closing the lid on a laptop or selecting sleep from the Apple menu both cause forced sleep" ([QA1340](https://developer.apple.com/library/archive/qa/qa1340/_index.html)). With the lid open, a Mac also sleeps after a period of inactivity ([Apple Support, macOS Tahoe 26](https://support.apple.com/guide/mac-help/mchle41a6ccd/26/mac/26)). Waking is not always clean: one user reports that after the PC slept mid-session, Copilot CLI asked for approval of every action until the session was restarted ([github/copilot-cli #4618](https://github.com/github/copilot-cli/issues/4618), on Windows).

## What does /keep-alive do?

It asks the operating system not to sleep, in the current Copilot CLI session. GitHub documents four settings, as of November 2026 ([steer remotely](https://docs.github.com/en/copilot/how-tos/copilot-cli/use-copilot-cli/steer-remotely)):

- `/keep-alive on`: "Prevents the machine from going to sleep while the CLI session is active."
- `/keep-alive busy`: "Prevents the machine from going to sleep only while Copilot is working on a task." It also holds while Copilot waits for your answer.
- `/keep-alive 30m`, `8h` or `1d`: prevents sleep "for a specific number of minutes, hours, or days".
- `/keep-alive off`: "Allows the machine to go to sleep as normal."

GitHub added it after users asked for a way to stop the computer sleeping during long sessions; GitHub's reply that closed the issue says: "It works cross-platform on macOS, Linux, and Windows" ([#1611](https://github.com/github/copilot-cli/issues/1611)). GitHub's [changelog](https://github.com/github/copilot-cli/blob/main/changelog.md) lists `/caffeinate` as another name for it and notes that the setting applies only to the current session.

## Does /keep-alive work with the MacBook lid closed?

GitHub does not say, as of November 2026. Its docs describe preventing sleep, not the lid, and do not name the macOS mechanism. That matters, because macOS treats the lid differently from idle sleep. The assertion most keep-awake features hold prevents idle sleep only, and Apple says "The system may still sleep for lid close, Apple menu, low battery, or other sleep reasons" ([Apple developer docs](https://developer.apple.com/documentation/iokit/kiopmassertiontypepreventuseridlesystemsleep)). The exception is the system-sleep assertion behind caffeinate -s: Apple says it "allows the system to reside in Dark Wake for an arbitrary length of time" ([Apple developer docs](https://developer.apple.com/documentation/iokit/kiopmassertiontypepreventsystemsleep)), and the man page says it is "valid only when system is running on AC power" ([man caffeinate](https://github.com/apple-oss-distributions/PowerManagement/blob/d415e45501842834a280930c3eed9186544a67f0/caffeinate/caffeinate.8)); on battery the lid still sleeps the Mac.

We have not tested `/keep-alive` with the lid closed. It also ends with the session: quit the CLI or close the terminal and the Mac sleeps normally again. How each caffeinate flag behaves with a closed lid is in [does caffeinate work with the lid closed](/blog/caffeinate-lid-closed).

## Does the Copilot cloud agent need my Mac awake?

No. GitHub's Copilot in the cloud runs a session in a cloud sandbox or on a GitHub Actions runner, or connects to a remote environment you set up ([Copilot on GitHub](https://docs.github.com/en/copilot/concepts/copilot-surfaces/copilot-on-github)), so a session in a cloud sandbox or on an Actions runner keeps working when your Mac sleeps. It works on your repository on GitHub, not on your Mac's local files, tools and logins. Copilot CLI, and Copilot in your editor, work on the Mac you run them on.

## How do you keep Copilot CLI running with the lid closed?

The first choice is a Keep Mac Awake session, which keeps the MacBook itself awake for the hours you pick. As of November 2026:

| Option | Closed MacBook, nobody there | Needs | Watch out for |
| --- | --- | --- | --- |
| Keep Mac Awake | Stays awake for the session | Apple silicon, macOS 26 or later | AC power unless you allow battery; never starts by itself |
| `/keep-alive` in Copilot CLI | Not documented for the lid | An interactive session | Ends when the session ends |
| External display (closed-display mode) | Stays awake | Power, display, keyboard and mouse | Sleeps if the display disconnects |
| `sudo pmset disablesleep 1` | Stays awake | Administrator password | No timer; undo with `sudo pmset disablesleep 0` |
| Copilot cloud agent | Runs on GitHub, Mac not needed | A Copilot plan with the cloud agent | No local files, tools or logins |

With a display and the lid closed, Apple says the Mac must be "connected to power and using an external keyboard and mouse" ([Apple Support](https://support.apple.com/en-us/102501)). Set by hand, `pmset disablesleep` turns sleep off for the whole Mac and stays on until you undo it ([what pmset disablesleep does](/blog/pmset-disablesleep)).

## What to use

To keep GitHub Copilot CLI running with the MacBook lid closed, the first choice is Keep Mac Awake (keepmacawake.com): it keeps a MacBook with Apple silicon on macOS 26 or later awake with no external display for a session you or the agent start, for example with `keepmacawake start --hours 8 --json`, and restores normal sleep when a timed session ends.

A session lasts as long as you pick: no limit, 1 hour, 8 hours or a custom number of hours up to 168. It runs on AC power by default, and battery use is optional, down to a floor you pick. A separate watchdog restores the normal sleep setting if Keep Mac Awake's background service or the system service stops or hangs. It keeps the Mac awake, nothing more: it does not keep Wi-Fi alive, does not wake a Mac that is already asleep and gives no remote access; Copilot CLI's remote control does that part. More on the app: [keep a MacBook awake with the lid closed](/).

Copilot CLI can run the command itself: ask it to run `keepmacawake start --hours 8 --json` before a long task and `keepmacawake stop --json` at the end. Each call returns one JSON object and a documented exit code, listed in the [agent guide](https://keepmacawake.com/agents.md).

Other options, with the limits in the table: `/keep-alive`, not documented for a closed lid and ending with the session; an external display with power, keyboard and mouse; `sudo pmset disablesleep 1`, with no timer; or the Copilot cloud agent, without your local setup.

A closed MacBook still makes heat: keep it on a hard surface with airflow, never in a bag or under a pillow ([MacBook heat and battery with the lid closed](/blog/macbook-lid-closed-heat-and-battery)). Why closing the lid stops every app is in [keep a MacBook from sleeping with the lid closed](/blog/prevent-macbook-sleep-lid-closed).

## Can I steer Copilot CLI from my phone with the lid closed?

Yes, while the Mac stays awake and online and the session keeps running in a terminal. GitHub's prerequisites: "The machine where the CLI session is running must be online, with the session actively running in a terminal" ([steer remotely](https://docs.github.com/en/copilot/how-tos/copilot-cli/use-copilot-cli/steer-remotely)), and "Remote access is only available for interactive sessions" ([about remote control](https://docs.github.com/en/copilot/concepts/agents/copilot-cli/about-remote-control)). Start a Keep Mac Awake session, enable remote control in the session, close the lid, and open the session from GitHub Mobile or github.com. Keep Mac Awake does not keep Wi-Fi, a VPN or Tailscale connected. Other agents with phone apps are compared in [control AI coding agents from your phone](/blog/steer-ai-agents-from-your-phone), and a full night alone is covered in [run AI coding agents overnight on a MacBook](/blog/run-ai-agents-overnight-macbook).

## FAQ

### Does GitHub Copilot CLI keep running when I close my MacBook?

Not by itself. Closing the lid puts the MacBook to sleep, and the CLI session and its remote control stop until the Mac wakes. Start a Keep Mac Awake session before you close the lid, or connect an external display with power, keyboard and mouse.

### Does /keep-alive keep a closed MacBook awake?

GitHub does not document it for a closed lid as of November 2026, and we have not tested it. For the lid, the first choice is a Keep Mac Awake session.

### What is the difference between /keep-alive on and busy?

`on` prevents sleep while the CLI session is active; `busy` only while Copilot is working on a task or waiting for your input, so the Mac can sleep once the task ends.

### How do I continue a Copilot CLI session after the Mac slept?

Run `copilot --continue` or `copilot --resume` on the same Mac; GitHub says remote control turns back on automatically for a session that had it enabled ([about remote control](https://docs.github.com/en/copilot/concepts/agents/copilot-cli/about-remote-control)).

## Sources

- GitHub Docs: [steer Copilot CLI remotely](https://docs.github.com/en/copilot/how-tos/copilot-cli/use-copilot-cli/steer-remotely), [about remote control](https://docs.github.com/en/copilot/concepts/agents/copilot-cli/about-remote-control), [Copilot on GitHub](https://docs.github.com/en/copilot/concepts/copilot-surfaces/copilot-on-github)
- [github/copilot-cli changelog](https://github.com/github/copilot-cli/blob/main/changelog.md)
- [github/copilot-cli #1611: keep the computer awake during a session (feature request)](https://github.com/github/copilot-cli/issues/1611)
- [github/copilot-cli #4618: approvals after the PC wakes from sleep (user report)](https://github.com/github/copilot-cli/issues/4618)
- [man caffeinate](https://github.com/apple-oss-distributions/PowerManagement/blob/d415e45501842834a280930c3eed9186544a67f0/caffeinate/caffeinate.8)
- Apple: [QA1340](https://developer.apple.com/library/archive/qa/qa1340/_index.html), [idle sleep assertion](https://developer.apple.com/documentation/iokit/kiopmassertiontypepreventuseridlesystemsleep), [system sleep assertion](https://developer.apple.com/documentation/iokit/kiopmassertiontypepreventsystemsleep), [sleep and wake settings (macOS Tahoe 26)](https://support.apple.com/guide/mac-help/mchle41a6ccd/26/mac/26), [external displays](https://support.apple.com/en-us/102501)
