Leaving Claude Code or Codex Running While You Step Away? 11 Mac Tips for 2026 (caffeinate, tmux, ntfy and More)
You start a long agent task, grab lunch, and come back to a sleeping Mac or a prompt that has been asking "Allow this command?" for 40 minutes. Neither one is the agent's fault. These are the small Mac settings and tool
You start a long agent task, grab lunch, and come back to a sleeping Mac or a prompt that has been asking "Allow this command?" for 40 minutes. Neither one is the agent's fault.
These are the small Mac settings and tools I'd set up before walking away from a running Claude Code or Codex session. Most are free, and a few are already on your Mac.
Keep the Mac awake
1. Prefix the run with caffeinate
macOS ships a caffeinate command that holds off sleep for as long as the command it wraps is running. Start the agent through it and the Mac stays awake exactly until the agent exits, with nothing to remember to turn off.
caffeinate -i claude
2. Use Amphetamine when you want a switch instead
Amphetamine is a free keep-awake app on the Mac App Store with no ads or in-app purchases. It can keep the Mac awake for a set time, until a specific app quits, or while the lid is closed, and its Triggers can start a session automatically when a given app is running.
3. Check the plugged-in sleep setting on a MacBook
In System Settings > Battery > Options, there's a setting to prevent automatic sleeping on power adapter when the display is off. If you leave the laptop plugged in with the screen dimmed, this is the difference between "still working" and "paused since 12:05".
4. Lock the screen, don't close the lid
Control-Command-Q locks the Mac and leaves every process running. Closing a MacBook lid without an external display puts it to sleep, and the agent sleeps with it unless something like Amphetamine is holding it awake.
Keep the session alive
5. Run the agent inside tmux
tmux is a terminal multiplexer: you can detach from a session, the programs keep running in the background, and you reattach later from a different terminal. An accidental Command-Q on the terminal app no longer takes the agent down with it.
brew install tmux
tmux new -s agent
6. Reach that tmux session from your phone with Tailscale
Tailscale puts your devices on one private network, and the Personal plan is free with unlimited user devices. Turn on Remote Login on the Mac, SSH in from your phone over the tailnet, run tmux attach -t agent, and you can answer one question without going back to the desk.
Don't let a prompt block the run
7. Pre-approve the boring commands
Most stalls are permission prompts for things you'd always say yes to, like running the test suite. Claude Code's permission rules let you allow specific commands ahead of time with /permissions, and "Yes, and don't ask again" saves a Bash rule for that repository. Keep the allowlist narrow: tests, linters and builds, not rm.
8. Get a Mac notification when the agent is waiting
Claude Code hooks run shell commands at points in its lifecycle, and the Notification event fires when Claude is waiting for input or permission. The docs give a macOS example using osascript that pops a native notification. If nothing shows up, Script Editor needs notification permission in System Settings > Notifications.
9. Send that same alert to your phone with ntfy
ntfy is free, open source push notifications over plain HTTP: subscribe to a topic in the phone app and curl to it from anywhere. Swap the osascript line in the hook for this and the alert reaches you away from the desk:
curl -d "Claude Code needs you" ntfy.sh/pick-a-long-random-topic
Without an account the topic name works like a password, so make it hard to guess.
Before you walk away
10. Put the agent on its own branch
git switch -c agent/lunch-task before you start means whatever the agent does while you're gone is one git diff main away from review, and one git switch main away from gone. If you want to keep coding in parallel, git worktree add gives the agent a separate folder on that branch.
11. Check the limit and reset time with TokenBar
A long unattended task that hits a usage limit 20 minutes in just sits there until you get back. TokenBar is a macOS 14+ menu bar app that shows usage and reset times for Claude, Codex, Cursor, Gemini and Copilot, so I'd glance at it before choosing which agent gets the long job. It's $5/month for Basic or $15 lifetime for Pro, doesn't add any quota, and is built on Peter Steinberger's MIT-licensed CodexBar, with credit to Pixel Agents.
The checklist
| # | Tip | Cost |
|---|---|---|
| 1 |
caffeinate -i around the agent |
Built in |
| 2 | Amphetamine keep-awake switch | Free |
| 3 | Battery: no sleep on power adapter | Built in |
| 4 | Ctrl-Cmd-Q instead of closing the lid | Built in |
| 5 | Run inside tmux | Free |
| 6 | Tailscale + SSH from your phone | Free Personal plan |
| 7 | Claude Code permission allowlist | Included |
| 8 |
Notification hook with osascript
|
Included |
| 9 | ntfy push to your phone | Free |
| 10 | Agent on its own branch or worktree | Built in |
| 11 | TokenBar for limits and resets | $5/mo or $15 lifetime |
What's the longest you've left an agent running unattended, and what did you set up first?
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.