AI coding agents like Claude Code and Codex are at their best on long tasks: "add offline mode, write the tests, make the build pass". You give them a goal, they work for an hour, you review the result.

But where should that hour of work happen? Most of us start by running agents on our main laptop. After a while, a few problems show up:

  • You can't close the lid. The agent stops when your laptop sleeps, so you either keep it open all night or babysit it.
  • It's your real machine. The agent runs shell commands with your user's permissions, next to your SSH keys, browser sessions, and every other project on your disk.
  • Your laptop is busy. Builds, test runs, and simulators eat CPU and battery while you're trying to do something else.
  • Environments drift. The agent installs packages, changes global configs, and leaves things behind.

The fix is simple: give the agent its own computer.

Disclosure: I build JustMac, a service that rents dedicated Macs by the day. I mention it below, but I've tried to cover every option fairly, including the cheaper ones.

Option 1: A Linux VPS (if you don't need macOS)

If your project is a web app, a backend, or anything that doesn't need Apple tools, a cheap Linux server is the most cost-effective choice. Hetzner, DigitalOcean, and similar providers give you a machine for a few dollars a month. SSH in, install your agent, done.

Good for: web, backend, scripts, data work.
Not good for: anything that needs Xcode, the iOS Simulator, Safari, or other macOS-only tools.

Option 2: A container or sandbox on your own machine

Dev containers, Docker, or the sandboxing built into some agents limit what the agent can touch. It's free and fast to set up.

Good for: reducing risk while you're at the computer anyway.
Not good for: long unattended runs. Your laptop still has to stay on, and it's still your machine doing the work.

Option 3: A spare Mac at home

An old Mac mini on a shelf, with SSH or Screen Sharing enabled, is a great agent box if you already have one.

Good for: people who own a second Mac.
Not good for: everyone else. You also need to deal with remote access from outside your home network.

Option 4: A rented, dedicated Mac

You rent a physical Mac in a data center and connect to it remotely. Providers include MacinCloud, MacStadium, AWS EC2 Mac instances, and smaller services like JustMac. This is the option for when the agent needs macOS itself: building iOS apps, running tests in the Simulator, checking Safari, or using macOS-only tooling.

Good for: iOS/macOS projects, people without a Mac, short bursts of heavy agent work.
Not good for: 24/7 use for months, where buying hardware becomes cheaper.

Apple's macOS licence requires a minimum lease of 24 hours, so rented Macs are usually billed by the day, week, or month.

Setting up an agent Mac, step by step

I'll use a rented Mac in the examples, but the steps are the same on any Mac you control.

1. Install the basics

Open Terminal and install Homebrew, Git, and Node.js:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" brew install git node tmux 

If you're building for Apple platforms, install Xcode from the App Store with your own Apple Account and open it once so it finishes installing its components.

Terminal on a rented Mac after installing git, node and tmux with Homebrew

2. Install your agent

Both major agents install with a single command. Check the official docs for the latest instructions, but at the time of writing:

# Claude Code npm install -g @anthropic-ai/claude-code # Codex npm install -g @openai/codex 

Sign in with your own subscription or API key when the agent asks.

3. Give the agent its own credentials

This is the most important step, and the one people skip. Don't reuse your personal credentials on the agent machine.

  • Create a separate Git token limited to the repositories the agent needs. On GitHub, a fine-grained personal access token scoped to one or two repos is ideal.
  • If you use an API key, create a dedicated key for this machine and set a spending limit on it.
  • Don't sign in to your personal email, password manager, or browser profile on this machine.

If something goes wrong, you revoke one token and one key, and your main accounts are untouched.

4. Clone the project

git clone https://github.com/you/your-project.git cd your-project 

Install the project's dependencies and make sure the build and tests run before you hand the task to the agent. An agent fixing a broken environment burns a lot of tokens on the wrong problem.

5. Run the agent inside tmux

tmux keeps a terminal session alive after you disconnect, so the agent continues even if you close the browser tab or lose your connection:

tmux new -s agent claude # or: codex 

Give it the task. To leave it running, detach with Ctrl+B, then D.

Later, from any computer, reconnect and pick up where it left off:

tmux attach -t agent 

Claude Code running the test suite inside a tmux session on the remote Mac

6. Make the agent work on a branch

Ask the agent to work on a separate branch and to commit as it goes. Then you review the result as a normal pull request:

Create a branch called offline-mode. Add an offline mode with tests. Run the full test suite and the build. Commit when everything passes. 

When you come back, you get a branch and a test report instead of "it's still running on my laptop, don't close it".

Here's what that looks like in practice. I asked the agent to run an existing test suite without changing files. It ran each suite separately, reported which passed and which couldn't run, and asked before installing anything:

Claude Code reporting test results for each suite

7. Clean up

When the job is done:

  • push the branch;
  • revoke the Git token and the API key you created for this machine, if you won't use them again;
  • sign out of your Apple Account in Xcode if you used one.

On JustMac the whole Mac is erased to factory settings an hour after the rental ends anyway. On your own hardware, you'll want to do this cleanup yourself.

Which option should you choose?

Your situation Best option
Web/backend project, no macOS needed Linux VPS
You stay at the computer while the agent works Container or sandbox
You already own a spare Mac Use it as the agent box
iOS/macOS project, Xcode or Simulator needed Rent a dedicated Mac
Agent work every day, for months Buy a Mac mini

My rule of thumb: the agent gets its own machine and its own credentials. It costs very little, and it turns "I hope it doesn't break anything" into "worst case, I revoke one token".

If you need macOS for your agents, JustMac rents dedicated Mac minis and MacBook Airs by the day, week, or month. The desktop opens in a browser tab, and the Mac stays awake while your rental lasts. Questions or a different setup that works for you? Share it in the comments.