# Keep-awake apps for coding agents compared

> Keep-awake apps for coding agents: caffeinate and KeepingYouAwake can't hold a closed MacBook lid; pmset, Amphetamine and Cocaine mode can.

Source: https://shuriken.sh/compare/amphetamine-alternatives-for-coding-agents

For coding agents, keep-awake tools differ in whether they hold with the lid closed and whether they let go when the work ends. On a Mac, Amphetamine and Cocaine mode handle the closed lid and plain caffeinate doesn't; on Linux, systemd-inhibit does both jobs in one command.

By Shuriken Updated 27 October 2026 7 min read

**Contents**

We make Shuriken, and Cocaine mode is ours. We tried to be fair; corrections welcome at office@shuriken.sh.

## Quick answer #

Every tool here stops idle sleep while an agent works. An Amphetamine alternative for AI agents also has to hold with the lid closed and let go when the work ends, so the laptop isn't awake all night for nothing. On a Mac, Amphetamine and Cocaine mode handle the lid; plain caffeinate -i doesn't. On Linux, systemd-inhibit does both jobs in one command.

## At a glance #

Read on 2026-10-22, from each tool's own page or man page (listed under sources).

| | Platform | Idle sleep | Lid closed | Lets go when work ends | Cost |
| --- | --- | --- | --- | --- | --- |
| caffeinate | macOS, built in | Yes ( -i ) | No | Yes, if you wrap the command: caffeinate -i claude | Free |
| pmset disablesleep 1 | macOS, built in | Yes | Yes | No. Stays on until you set it back to 0 | Free, needs admin |
| Amphetamine | macOS (Mac App Store) | Yes | Yes, with Closed-Display Mode (on Apple silicon it asks to install a script, with admin authentication) | Partly: triggers such as a specific app running or CPU use above a threshold | Free |
| KeepingYouAwake | macOS | Yes | No ("only … portable Macs with an open lid") | No, a timer or a switch | Free, MIT |
| PowerToys Awake | Windows | Yes | Not covered; set the lid close action to Do nothing | Yes, with --pid it ends when a process exits | Free |
| systemd-inhibit | Linux | Yes | Yes, with --what=handle-lid-switch | Yes, released when the command finishes | Free, built in |
| Cocaine mode (Shuriken) | macOS, Windows and Linux (Windows and Linux since 5.1) | Yes | Yes on a Mac (one-time admin password) | The lid hold: no, it stays on until you turn it off (from 5.1, quitting Shuriken undoes it too). Idle sleep: yes, with Keep awake's While working | In every Shuriken plan |

The bottom row is Shuriken's Keep awake set to While working, which stops idle sleep. The lid is a different story on a Mac: there, every tool on this page, Cocaine mode included, holds it with one system-wide switch until you turn it off.

## Why agents need more than "stay awake" #

A coding agent works in bursts. A Claude Code turn might run eight minutes, wait for you, and then a queued message starts another twenty. Two things go wrong with an ordinary keep-awake tool.

- You close the laptop to leave and the Mac sleeps, whatever caffeinate says. The agent stops mid-step and nothing happens until you open it again.
- You set "keep awake for 2 hours", the agent is still running at 2:01, and the laptop sleeps on it. Or you set "forever", the agent finishes at 11 p.m., and the laptop stays awake and warm until morning.

The Lid closed and Lets go columns in the table are those two problems.

## What each one does well #

### caffeinate #

It ships with macOS, so there's nothing to install. Its best trick is wrapping a command: caffeinate -i make holds an assertion "as long as that process is running", in the man page's words. Wrap your agent the same way and the hold ends when the agent exits. -w <pid> does it for a process that's already running.

What it doesn't do is the lid. -s prevents system sleep, but only "when system is running on AC power", and closing a MacBook's lid is a separate trigger. Even KeepingYouAwake, which is built on caffeinate, says it "will only prevent sleep on desktop Macs and portable Macs with an open lid".

### pmset disablesleep #

sudo pmset -a disablesleep 1 turns sleep off for the whole system, lid included. It's also what Cocaine mode uses on a Mac. It isn't in pmset's man page, and pmset "must be run as root in order to modify any settings", so by hand it's a sudo command and your admin password.

The catch: it never lets go. Nothing turns it back off but sudo pmset -a disablesleep 0. Forget that, and your MacBook will happily cook itself in your bag. Our guide to [keeping Claude Code running with the lid closed](https://shuriken.sh/guides/keep-claude-code-running-lid-closed) shows the commands step by step.

### Amphetamine #

The best-known Mac keep-awake app, free on the Mac App Store with no in-app purchases. It has a simple on/off switch and a deep set of triggers: an external display connected, a specific app running, a USB or Bluetooth device, battery level, CPU use above a threshold and more. You can also start a session that lasts while a file downloads. Its Closed-Display Mode keeps a MacBook awake with the lid closed; since version 5.3, on Apple silicon, it asks to install a small script and to confirm with admin authentication.

Point the "specific app running" trigger at Terminal or iTerm and it holds while that app is open, which is usually longer than the agent is working. The CPU trigger gets closer to "while the agent works", if you're happy to tune a threshold. For a Mac that only has to stay awake, from a menu-bar switch, Amphetamine is excellent.

### KeepingYouAwake #

A small, open-source (MIT) menu-bar app built on caffeinate, installed with brew install --cask keepingyouawake. One click turns it on, with a timer if you want one. Its README is plain about the lid: open lid only. It suits a long test run that you're sitting in front of.

### PowerToys Awake (Windows) #

Part of Microsoft PowerToys. It keeps Windows awake "without modifying power and sleep settings": indefinitely, for an interval, or until a set time. Its --pid flag ties it to a process, so it ends when that process exits. That's the same "let go when the work ends" idea as caffeinate -i.

For the lid, Windows has a separate setting: the lid close action, which can be Do nothing, Sleep, Hibernate or Shut down. Set it to Do nothing (for plugged in, on battery, or both) and closing the lid stops putting the laptop to sleep, until you change it back.

### systemd-inhibit (Linux) #

systemd-logind suspends on lid close by default (HandleLidSwitch=suspend). Run your agent under systemd-inhibit --what=handle-lid-switch:sleep:idle … and logind leaves the lid alone; the lock is "released afterwards", when the command exits. For a permanent change, set HandleLidSwitch=ignore in logind.conf.

Shuriken's Cocaine mode keeps the computers you pick awake while your agents run.

[Download](https://shuriken.sh/download)

## Cocaine mode: built for agents #

We built Cocaine mode because we kept closing the lid on our own agents. It lives inside Shuriken, which runs those agents, so it's one switch next to the work instead of another menu-bar app.

- Turn it on and your MacBook keeps running with the lid closed. On a Mac that's pmset -a disablesleep 1, as above. The one-time admin password installs a sudoers rule (/etc/sudoers.d/shuriken-closed-lid) for exactly that line and its disablesleep 0 twin, and Revoke permission takes it back any time.
- Turn it off and it puts back the power setting it changed. Since Shuriken 5.1, quitting Shuriken does the same, and if Shuriken crashes, a small guard process undoes it: it checks every 2 seconds whether Shuriken is still running. No forgotten disablesleep 1.
- It's a switch, not a timer. Cocaine mode stays on until you turn it off, so with the lid shut the laptop stays up after the agents finish. Turn it off when you open the lid again.
- For the lid-open case, each device's page in Shuriken has a Keep awake setting with two choices: While working (held only while an agent, the queue or a workflow runs) and Always. A computer signed in to Shuriken starts on Always, so it stays reachable (the screen can still turn off). Switch it to While working and it stops idle sleep exactly as long as there's work, then lets the computer sleep normally.
- The syringe button in the top bar lists your devices, so you turn it on for each computer that should stay up. A pill in the sidebar shows when it's on.
- Since Shuriken 5.1 it also runs on Windows and Linux, with the same built-in tools as above. On Windows it sets the power plan's lid close action to Do nothing with powercfg and puts the old values back when it's off. On Linux it holds a systemd-inhibit --what=sleep:idle:handle-lid-switch lock, which needs systemd-logind. Laptops differ, so each device says what it can do: keep running with the lid closed, stay awake with the lid open only, or need a one-time permission first.

And yes, it's called Cocaine mode, as a joke about your laptop: no sleep, a lot of work, slightly warm (the [story behind the name](https://shuriken.sh/blog/cocaine-mode-yes-really); While working is in [Keep awake only while agents work](https://shuriken.sh/blog/keep-awake-while-working)).

It isn't a general keep-awake app: it keeps a computer up for Shuriken's agents. If you want your Mac awake for a download or a presentation, Amphetamine or KeepingYouAwake is the better tool.

## Heat, battery and the honest bits #

Whichever tool holds it, a MacBook running an agent with the lid shut does the same work as with the lid open, and has less room to breathe. On a desk that's fine; zipped in a backpack for an afternoon it isn't. The battery drains about as fast as with the lid open, so plug in for overnight runs, and set up the rest from [running Claude Code overnight](https://shuriken.sh/guides/run-claude-code-overnight).

A machine that should be on all the time is better as a [server](https://shuriken.sh/server). Shuriken runs headless on Linux, macOS or Windows, and a server has no lid to close.

## Pricing #

Every tool on this page is free. Cocaine mode comes with Shuriken, including the Free plan (two sources, two linked devices, no card). Pro is €49 a month and isn't needed for keep awake.

If you want your agents to keep working after you close the lid, [download Shuriken](https://shuriken.sh/download), turn on Cocaine mode for that laptop, and close it.

Share

[X](https://x.com/intent/post?url=https%3A%2F%2Fshuriken.sh%2Fcompare%2Famphetamine-alternatives-for-coding-agents&text=Keep-awake%20apps%20for%20coding%20agents%20compared)[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fshuriken.sh%2Fcompare%2Famphetamine-alternatives-for-coding-agents)[Hacker News](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Fshuriken.sh%2Fcompare%2Famphetamine-alternatives-for-coding-agents&t=Keep-awake%20apps%20for%20coding%20agents%20compared)[Reddit](https://www.reddit.com/submit?url=https%3A%2F%2Fshuriken.sh%2Fcompare%2Famphetamine-alternatives-for-coding-agents&title=Keep-awake%20apps%20for%20coding%20agents%20compared)[E-mail](mailto:?subject=Keep-awake%20apps%20for%20coding%20agents%20compared&body=https%3A%2F%2Fshuriken.sh%2Fcompare%2Famphetamine-alternatives-for-coding-agents)

## Sources

- [caffeinate(8) man page (ss64 mirror)](https://ss64.com/mac/caffeinate.html) (accessed 22 October 2026)
- [pmset man page (ss64 mirror)](https://ss64.com/mac/pmset.html) (accessed 22 October 2026)
- [Amphetamine on the Mac App Store](https://apps.apple.com/us/app/amphetamine/id937984704?mt=12) (accessed 22 October 2026)
- [KeepingYouAwake on GitHub](https://github.com/newmarcel/KeepingYouAwake) (accessed 22 October 2026)
- [Microsoft Learn: PowerToys Awake](https://learn.microsoft.com/en-us/windows/powertoys/awake) (accessed 22 October 2026)
- [Microsoft Learn: Lid switch close action](https://learn.microsoft.com/en-us/windows-hardware/customize/power-settings/power-button-and-lid-settings-lid-switch-close-action) (accessed 22 October 2026)
- [systemd: logind.conf](https://www.freedesktop.org/software/systemd/man/latest/logind.conf.html) (accessed 22 October 2026)
- [systemd: systemd-inhibit](https://www.freedesktop.org/software/systemd/man/latest/systemd-inhibit.html) (accessed 22 October 2026)

## Frequently asked questions

**Can a MacBook keep running with the lid closed?**

Yes, but caffeinate alone won't do it. You need sleep disabled at the system level (pmset disablesleep, which needs admin rights), an app that does that for you such as Amphetamine's Closed-Display Mode or Shuriken's Cocaine mode, or Apple's closed-display setup with an external display.

**Is it safe for the battery to keep a laptop awake with the lid shut?**

The battery drains about as fast as with the lid open, and a closed laptop has less room to breathe, so it runs warm. Plug it in for long runs and leave it on a desk, not zipped in a bag.

**What's the Windows equivalent of Amphetamine?**

Microsoft's PowerToys Awake keeps Windows awake for a time, until a set time, or until a process exits. For the lid, Windows has a lid close action you can set to Do nothing.

**How do I keep Linux awake with the lid closed?**

systemd-logind suspends on lid close by default (HandleLidSwitch=suspend). Run the agent under systemd-inhibit --what=handle-lid-switch, which holds until the command exits, or set HandleLidSwitch=ignore in logind.conf.

**Does Cocaine mode cost extra?**

No. Cocaine mode is in every Shuriken plan, Free included. It works on the computer it runs on: a Mac, and since Shuriken 5.1 Windows and Linux too.

Cocaine mode

Close the lid. Your agents keep working.

Pick which of your computers stay awake while agents work. On a Mac that holds with the lid closed, and on Windows and Linux where the laptop allows it.

[Download](https://shuriken.sh/download)

[Other platforms](https://shuriken.sh/download#main)

## Keep reading

- [Shuriken on Windows 10 and 11: Update 27 Oct 2026 3 min read Run Claude Code, Codex and 65 more coding agents in parallel on Windows 10 and 11. Installer or .zip, x64, with signed updates.](https://shuriken.sh/blog/shuriken-on-windows)
- [What's new in Shuriken 5.1: Update 27 Oct 2026 16 min read Shuriken 5.1 adds sign-in with Google, Apple or an email code, passkeys, Allow and Always allow at a MacBook's notch, and billing and fuel in Sources.](https://shuriken.sh/blog/shuriken-5-1)
- [Claude Code on its own vs Claude Code in Shuriken: Comparison 27 Oct 2026 3 min read Shuriken runs the real Claude Code CLI, so this isn't either-or. What the CLI does well alone, what Shuriken adds around it, and when you don't need it.](https://shuriken.sh/compare/claude-code-vs-shuriken)

## Free tools

- [Claude limit reset tracker](https://shuriken.sh/tools/limit-resets/claude)
- [Codex limit reset tracker](https://shuriken.sh/tools/limit-resets/codex)
