For agents · Cline

Keep your Mac awake
while Cline works.

Cline runs inside VS Code on your Mac, so its long tasks stop when the Mac sleeps. Midnight Oil keeps the Mac awake while Cline works, and lets it sleep once the task is done.

The short answer

Add an App Running trigger for Visual Studio Code in Midnight Oil, so the Mac stays awake whenever the editor is open. Or ask Cline “keep my Mac awake until you're done,” or put one line in .clinerules.

Cline at a glance

Runs whereInside VS Code, on your Mac
InteractiveThe Cline panel in VS Code
UnattendedAuto-approve settings let it run commands without asking
Instructions file.clinerules at the project root, a file or a folder of rules
Needs your Mac awake?Yes, and so does a local model server if you use one

What happens when your Mac sleeps mid-run

Cline lives in VS Code, which sleeps with the Mac. Its request to the model drops, the command it ran in the terminal freezes, and the task waits at that step until you wake the Mac.

With auto-approve turned on, Cline can work for a long time without you, which is when the idle timer and a closed lid catch it.

Just ask Cline

With Midnight Oil installed, Cline can run the midnightoil command for you. Say it in your own words:

You sayCline runs
“Keep my Mac awake until this task is finished.”midnightoil start
“Run the migrations and keep the Mac awake for them.”midnightoil run -- npm run migrate
“Keep it awake till 6am, lid closed.”midnightoil start --until 6am --lid-closed

The session shows up in the menu bar like one you started yourself, so you can see it, extend it, or end it with a click.

Make it automatic

Add this line to .clinerules and Cline keeps the Mac awake for every long command without being asked:

For .clinerulesCline reads midnightoil --help for the rest.
For commands that take more than a few minutes, run them through `midnightoil run -- <command>` so the Mac stays awake until they finish.

Running Cline unattended

Cline runs commands through VS Code's terminal, so it can run midnightoil like anything else. Ask it, or add the line to .clinerules and it wraps its own long commands.

To cover the whole task, not just one command, use a trigger: Midnight Oil's Settings › Triggers › Add Trigger › App Running › Visual Studio Code. Turn on closed-lid mode in the trigger if the laptop will be shut.

Lid closed, battery safe

Add --lid-closed and Cline keeps working with the laptop shut. It needs a one-time approval in Midnight Oil's Settings › Closed Lid, and normal sleep comes back the moment the session ends, even if the app quits or crashes.

On battery, sessions can end when you unplug or drop below a level you pick, and an alarm sounds if the lid closes during a closed-lid session. Add --allow-display-sleep to let the screen go dark while the Mac keeps working. The full setup is in how to run AI agents overnight.

Questions

Does Cline keep working while my Mac sleeps?

No. VS Code and Cline pause with the Mac, so a long auto-approved task stops at the step it was on.

What goes in .clinerules?

One line: For commands that take more than a few minutes, run them through `midnightoil run -- <command>` so the Mac stays awake until they finish.

Can I use Cline with the lid closed?

Yes, with Midnight Oil's closed-lid mode, approved once in Settings › Closed Lid. Sessions can end on their own when you unplug or the battery gets low.

Let Cline work the night shift.

Free. No account, no subscription.

macOS 14 or later · Apple Silicon and Intel · brew install --cask coreyhaines31/tap/midnightoil