Skip to content

Does Claude Code keep running when your Mac is locked?

Claude Code can keep running while your Mac’s screen is locked, as long as the Mac stays awake. Warden blocks keyboard, mouse, and trackpad input while keeping the run visible, with optional sleep prevention.

Download free trial

7-day free trial · $8.99 once · No card to start

Why lock input while an AI coding agent runs?

Because the agent’s terminal is still listening to your keyboard, and one stray keystroke can stop or redirect the run. AI coding agents can work between approval prompts. You give Claude Code a refactor, it works through the codebase for half an hour, and the useful thing to do in the meantime is something else. The catch is that the session lives in a terminal or IDE that is still listening to your keyboard.

A cat on the desk, a toddler at the keyboard, a colleague borrowing your machine for “one second” — any of it can send Ctrl+C, answer a confirmation prompt that should have been yours, or type into a file the agent is editing.

Why not just use the macOS screen lock?

Locking the screen does stop the input — but it also hides the run. You lose the ability to glance over and see whether the agent finished, stalled, or is sitting on a permission prompt waiting for an answer. For a long unattended job, visibility is the whole point of leaving it on screen.

There is a second problem: the built-in lock does nothing about sleep. If your energy settings suspend the machine, local execution pauses and network connections may be interrupted.

How does Warden keep an agent run safe?

Warden blocks keyboard, mouse, and trackpad at the macOS event-tap layer, which means input is discarded before any application — terminal, IDE, or agent — can see it. The screen stays exactly as it was, so the agent’s output keeps streaming in full view, and optional sleep prevention keeps the Mac awake for the duration.

When you come back, Touch ID unlocks the session and the run is wherever it got to.

Can you close the lid while an agent runs?

Normally no: closing a MacBook’s lid puts it to sleep, and the agent stops with it. Warden can keep supported Macs awake with the lid closed after a one-time helper setup. If you want to keep watching the run, leave the lid open. Warden keeps the screen visible while input is blocked.

Why not caffeinate or tmux?

They solve different halves of the problem. caffeinate keeps the Mac awake but leaves the keyboard live. tmux keeps a session alive if the terminal closes, but anything typed into it still lands. Warden blocks the input and can prevent sleep at the same time.

How to set it up

Install with Homebrew, or download the DMG:

brew install --cask ParthJadhav/warden/warden

Start your agent, press ⌘⇧L, and walk away. Warden requires macOS 15.2 or later and comes with a 7-day free trial.

Beyond agents

The same shape of problem shows up anywhere a local job outlives your attention: Xcode release builds, Final Cut exports, local model training, long test suites. Anything you would rather watch than hide.

Related