Full freedom, fenced in: Claude Code on my Mac mini
How I let a coding agent run any command on a home Mac mini by fencing where it can reach, instead of approving each step.
Claude Code runs on my home Mac mini with every shell command auto-approved, and I drive it from my phone. It still cannot read my home folder, my SSH keys or a single .env file, and it holds no secrets unless I start it that way.
Fence the reach, not the steps
There are two ways to keep a coding agent safe. The first is to approve each step: every command waits for a yes. That is safe on paper and weak in practice, because by the fortieth prompt you approve without reading, and you can't approve anything from a phone across town.
The second is to fence where the agent can reach, then let it do whatever it likes inside. The agent never stops to ask, and a bad command still can't touch what sits outside the fence. I chose the fence. Every layer below either narrows what the agent can see or narrows what a breach would cost.
How it is built
iPhone / browser (Claude app, session list)
| outbound connection only
v
Mac mini
|- my own admin account (personal 1Password vault)
'- claude-worker (standard user)
|- Claude Code: sandbox strict, works in ~/dev
'- op CLI -> service account -> one vault (read-only)
- A separate account with no admin rights. Claude Code runs as claude-worker, a standard macOS user. It can't install system software or change system settings, and my own account lives in a different home folder.
- A sandbox with no back door. Every shell command runs inside Claude Code's OS-level sandbox and is approved automatically. Strict mode removes the escape hatch: a command the sandbox blocks fails instead of being retried outside it.
- Reads limited to the work. Other users' home folders, ~/.ssh, ~/.aws and every .env file are unreadable, and reads outside the working directory are blocked.
- Secrets only on request. A 1Password service account sees one dedicated vault, read-only, and that grant is fixed when the account is created. Its token sits in the worker's Keychain and loads only when I start Claude as
claude-op. Plainclaudehas no keys at all. - Remote use without an open port. Remote Control (
claude rc) connects outward, so I pick the session from the Claude app on my phone and nothing on the Mac listens for inbound traffic. - The machine and the sign-in. FileVault encrypts the disk, the firewall runs in stealth mode, and the Claude account signs in through Google with 2-Step Verification and passkeys.
The configuration
The whole fence is one settings file in the worker's home, ~/.claude/settings.json:
{
"permissions": {
"blockReadsOutsideWorkingDirectories": true,
"deny": ["Read(//**/.env)", "Read(//**/.env.*)"]
},
"sandbox": {
"enabled": true,
"autoAllowBashIfSandboxed": true,
"allowUnsandboxedCommands": false,
"filesystem": {
"denyRead": ["/Users/", "~/.ssh", "~/.aws", "~/**/.env", "~/**/.env.*"],
"allowRead": ["~/"]
}
}
}
In sandbox read rules the narrower path wins, so allowRead ~/ reopens the worker's own home inside the /Users/ deny. Everything else under /Users/ stays closed.
Secrets load through one alias in ~/.zshrc:
alias claude-op='OP_SERVICE_ACCOUNT_TOKEN=$(security find-generic-password -a "$USER" -s op-service-account -w) claude'
The token exists in the environment only for that session. Starting plain claude leaves it in the Keychain.
What tripped me up
- Fallback mode is not a fence. The default sandbox mode let Claude retry a blocked command outside the sandbox. Strict mode plus
allowUnsandboxedCommands: falseclosed that. /sandboxsaves per project. Settings picked there land in that project's.claude/settings.local.json. Rules meant for every project belong in~/.claude/settings.json.- The Keychain prompt stops at 128 characters. The interactive
-wprompt silently cut the token, which is longer. Pass it on the command line instead:security add-generic-password -U -a "$USER" -s op-service-account -w "$(pbpaste)". $(pbpaste)reads the clipboard when you press Enter. Paste the command first, then copy the token, then press Enter.- A typo makes
opoffer to add an account. Answer n, or your personal 1Password login lands on the worker account. - The QR code didn't open on the phone. The session list in the Claude app did.
- The Claude account has no password or 2FA of its own. Its protection is whatever guards the Google sign-in, so that is where 2-Step had to be checked.
Day to day
- Switch to the worker account with Ctrl+Cmd+Q, then Switch User. Don't log out: Remote Control needs the account logged in.
- Start a session with
cd ~/dev && caffeinate -i claude rc.caffeinate -ikeeps the Mac awake while it runs. - On the phone, open the Claude app and pick the session from the list.
- When the work needs secrets, start with
claude-opinstead ofclaude. - After a restart, run step 2 again.
How I check the fence still holds
- The sandbox: ask Claude to run
ls /Users/Shared. It should be blocked, with no retry outside the sandbox. - The secrets:
op vault listwith the worker's token should show exactly one vault. - Changing vault access: make a new service account. The grant can't be edited after creation, which is the point.
Built with Claude Code 2.1.332 and the 1Password CLI 2.42.0 on a Mac mini (Apple Silicon), November 2026. Later versions may rename settings.