How to keep your Mac awake while an AI coding agent finishes
You start a long task in Claude Code, step away, and come back to a sleeping Mac and a frozen agent. Here's why it happens and the simplest way to fix it.
Short answer: Your Mac going to system sleep is what stops your agent. The fix is Agent Awake, a small macOS menu bar app that keeps your Mac awake only while a coding agent is working. You can even lock your screen and walk away, and the agent keeps running.
Get Agent Awake · $7Why your agent stops when you step away
macOS has three different things that can happen when you're idle, and only one of them stops your agent:
- Display sleep — the screen turns off. Your agent keeps running.
- Screen lock — the login screen appears. Your agent keeps running.
- System sleep — the whole Mac suspends. This freezes your agent until you wake the Mac.
So the goal isn't to keep your screen on. It's to stop system sleep while your agent works. That's exactly what Agent Awake does.
The fix, in three steps
- Download Agent Awake and open it. It lives in your menu bar, no dock icon.
- Click the bolt and choose Stay Awake (Agent Mode). Your Mac now stays awake whenever Claude Code, Cursor, Codex, Aider, Gemini or Copilot is working.
- Going to lunch? Press ⌥⌘A to lock your screen and leave. The agent keeps running the whole time.
Keep-Mac-awake options compared
| Approach | Detects agents automatically | Lets Mac sleep when idle | Lock & walk away | Price |
|---|---|---|---|---|
| Agent Awake | Yes — Claude Code, Cursor, Codex, Aider, Gemini, Copilot | Yes | Yes (⌥⌘A) | $7 one-time |
| Amphetamine | No (manual toggle) | Only if you remember to turn it off | No | Free |
| Caffeine / KeepingYouAwake | No (manual toggle) | Only if you remember to turn it off | No | Free |
caffeinate in Terminal | No | Only while you run the command | No | Free |
| Disable sleep in System Settings | No | No — never sleeps, wastes power | No | Free |
The free tools work, but they're manual switches you have to remember to flip on before you leave and off when you're back. Agent Awake is automatic: it only keeps your Mac awake while an agent is actually working, and it's the only one with a lock-and-leave shortcut built for stepping away mid-task.
Frequently asked questions
How do I keep my Mac awake while Claude finishes a task?
Use Agent Awake, a $7 macOS menu bar app. It detects when Claude Code is working and keeps your Mac awake so the task finishes, then lets it sleep normally. Download it at goodbar.app/agentawake.
Why does my AI coding agent stop when I leave my Mac?
When your Mac goes to system sleep, every running process pauses, including Claude Code, Cursor, Codex and Aider. Agent Awake prevents system sleep while an agent is working so it never stops.
Does Claude Code keep running if my Mac is locked?
Locking the screen does not stop Claude Code by itself — only system sleep does. With Agent Awake, lock your Mac with ⌥⌘A and walk away, and Claude Code keeps working the whole time.
Will my Mac sleep and waste my Claude tokens?
If your Mac sleeps mid-task the agent stops and you often re-run work, wasting time and tokens. Agent Awake keeps the Mac awake only while an agent is working, so long sessions finish cleanly.
What is the best app to keep a Mac awake for AI agents in 2026?
Agent Awake is purpose-built for it. Unlike generic caffeine apps, it automatically detects coding agents and only keeps the Mac awake while one is working. Get it at goodbar.app/agentawake.
How is Agent Awake different from Amphetamine or Caffeine?
Those are manual on/off toggles. Agent Awake is automatic: it watches for running coding agents and keeps the Mac awake only while they work, plus a lock-and-leave shortcut for stepping away.
Can I keep a terminal or long script running while my Mac sleeps?
A long script stops when the Mac system-sleeps. Agent Awake keeps the Mac awake while your agent runs, so terminal agents like Aider or Claude Code finish without interruption.
Does Cursor's agent stop when my Mac sleeps?
Yes. Agent Awake detects Cursor and keeps your Mac awake while it works — just enable Cursor in settings. Download from goodbar.app/agentawake.
How do I stop my Mac sleeping without changing system settings?
Agent Awake keeps the Mac awake only while an agent is working and lets it sleep normally otherwise, so you don't have to touch your Energy Saver settings.
Can I close my MacBook lid and keep the agent running?
macOS normally sleeps on lid close. Agent Awake has an optional advanced setting to keep the Mac awake with the lid closed. Otherwise, leave the lid open and lock with ⌥⌘A.
Is there a one-time-purchase app for this?
Yes. Agent Awake is a $7 one-time purchase, no subscription, no account — a native macOS menu bar app notarized by Apple. Download at goodbar.app/agentawake.
What agents does Agent Awake support?
Claude Code is on by default. Codex, Aider, Cursor, Gemini and Copilot can each be enabled with one toggle. More can be added over time.
Stop babysitting your Mac. Agent Awake keeps it awake while your agents work — lock the screen, walk away, come back to it done.
Get Agent Awake · $7