mac-ai-dev-setup
Sets up a Mac so an AI coding agent can build, deploy, store data and run compute. The agent installs and checks everything, and the person only logs in. Use on a new Mac. Not for Windows or Linux.
The person only logs in. Install, connect and check everything else, and never ask for or read a password or an API key, because whatever enters the chat is saved on disk and that key then has to be replaced.
Rules for the agent
- Run this on the Mac itself, in Claude Code, the Claude desktop app's Code tab, or the Codex CLI. Cowork and chat windows run commands on another computer, so stop there and name the three.
- Check each tool first, and skip what is already installed and logged in.
- Commands are from November 2026, so read the maker's install page before running one.
- The person runs each command that needs a password, a browser approval or a code in their own terminal, because an agent's shell has no keyboard. Give the exact line, wait, then run the check.
- Never run
gh auth token,wrangler auth token,claude setup-tokenor a--show-tokenflag, because each prints a secret. - If a key appears in the chat, tell the person to delete it at the provider and make a new one.
- Ask before a step that costs money or deletes something.
- Codex's sandbox blocks installs until the person approves them.
- After Part one, show what is installed and logged in, and ask whether to go on.
Questions to ask first
- Which do you pay for, a Claude plan (Pro or higher), a ChatGPT plan, or both?
- Do you have GitHub and Cloudflare accounts, with two-factor sign-in on?
- Do you want the quick setup (Part one), or also sign-in, payments and cloud for apps a team will use (Part two)?
- For Part two, will you take real payments now, and which AI providers do you hold keys for?
- What is the most you accept paying per month in cloud bills?
Part one. Build and deploy
1. Check the Mac before installing anything
- Run
uname -mandsw_vers -productVersion. Homebrew needsarm64(Apple Silicon), macOS 15 or later and an admin account. - Its installer has refused Intel Macs since September 2026, so on Intel use each tool's own installer.
2. The person installs Homebrew, then you install everything else with it
- The person pastes the install line from brew.sh into their own terminal, types the Mac password, then pastes the "Next steps" lines it prints.
- Check with
/opt/homebrew/bin/brew --version. If your shell can't findbrew, runeval "$(/opt/homebrew/bin/brew shellenv)"first. - Run
brew install git node pnpm uv jq gh gitleaks. - From here, install any missing tool with
brew install <name>, because Homebrew needs no password after this.
3. Log in to GitHub through its CLI
- The person runs
gh auth login --hostname github.com --git-protocol https --web. - Run
gh auth setup-git, then check withgh auth status, which masks the token. - Set
git config --global user.nameand a noreplyuser.email, so commits don't publish a private email. - Create repositories private unless told otherwise.
- Use
ghfor GitHub work, because GitHub's MCP server needs a pasted token.
4. Log in to Cloudflare and keep the login in the Keychain
- The person runs
npx -y wrangler@latest login --use-keyringand clicks Allow. Without--use-keyringthe login sits in a plain text file. - Tell the person this login grants every permission, including billing changes, unless
--scopesnarrows it. - Check with
npx wrangler whoami --json >/dev/null && echo ok. - R2 needs a dashboard checkout.
5. Install both agents and the desktop app
- Run
brew install --cask claude claude-code codex. The person signs in to each in the browser. - Check with
claude doctorandcodex login status. - Put a shared skill in
~/.claude/skills/<name>/SKILL.mdand~/.agents/skills/<name>/SKILL.md. Cowork takes a skill as a ZIP under Customize, Skills. - Build in the Code tab or a CLI, because Cowork can't push code or type into a terminal.
6. Connect the agents to Cloudflare and to Chrome
- Run
claude mcp add --transport http --scope user cloudflare https://mcp.cloudflare.com/mcpandcodex mcp add cloudflare --url https://mcp.cloudflare.com/mcp. - The person runs
claude mcp login cloudflareandcodex mcp login cloudflarein their own terminal. Check withclaude mcp list. - The person adds the Claude extension from the Chrome Web Store to Google Chrome and signs in with the same account. Start Claude Code with
claude --chrome. - The browser uses the person's saved logins, so the person approves each site.
7. Prove it by creating and deleting one project
- Create with
npm create -y cloudflare@latest -- hello-test --type=hello-world --lang=ts --git --no-deploy, then runnpx wrangler deployinside it. On a new account the person registers a workers.dev address when asked. - Add a database with
npx wrangler d1 create hello-test-db --binding=DB --update-config. - Commit, run
gh repo create hello-test --private --source=. --remote=origin --push, and open the live address. - Delete with
npx wrangler delete --name hello-test --forceandnpx wrangler d1 delete hello-test-db -y, because deleting a Worker leaves its database. - The person approves
gh auth refresh -h github.com -s delete_repoonce. Then rungh repo delete OWNER/hello-test --yes.
8. Write the setup down for the next session
- Add to
~/.claude/CLAUDE.mdand~/.codex/AGENTS.mdthat missing tools come frombrew install, which CLIs are logged in, and that secrets are never printed.
Part two. Sign-in, payments, cloud and keys
9. Keep API keys in one file outside every project
- Create
~/.secretswith mode 700 and~/.secrets/api-keys.envwith mode 600. Give it one empty line per provider, such asANTHROPIC_API_KEY=,OPENAI_API_KEY=,GEMINI_API_KEY=,ELEVENLABS_API_KEY=,DEEPINFRA_API_KEY=andVIDLAB_API_KEY=. - Open it with
open -e. The person pastes each key after its=and saves. - Check with
awk -F= '{print $1 ": " (length($2) ? "set" : "EMPTY")}' ~/.secrets/api-keys.env, which prints names only. - Read one key without printing it with
$(grep -m1 '^NAME=' ~/.secrets/api-keys.env | cut -d= -f2-). Test it inside acurl -s -o /dev/null -w '%{http_code}'call to the provider's models list, and pipe it intonpx wrangler secret put NAMEfor a deployed app. - Never load this file in
~/.zshrc. AnANTHROPIC_API_KEYin the shell moves Claude Code from the subscription to API billing and switches off its Chrome use. - Give a project only its keys with
grep -E '^(NAME1|NAME2)=' ~/.secrets/api-keys.env > .env, then confirm withgit check-ignore .env. - The person sets a monthly spending limit at each provider.
10. Block keys from reaching Git
- Put
.env,.env.*,!.env.example,.dev.vars*and*.pemin~/.config/git/ignore. - Run
gitleaks git --pre-commit --redact --stagedbefore each commit, because a free GitHub account doesn't block keys pushed to private repositories.
11. Use Stripe in a sandbox first, and go live after the person verifies the business
- Run
brew install stripe. The person turns on CLI access in the Dashboard under Settings, Team and security, then runsstripe loginand approves sandboxes only. - Check with
stripe login list. Runstripe agent setupto add Stripe's MCP server and skills to each agent. - For live payments the person verifies the business and adds a bank account in the Dashboard, then runs
stripe loginagain and adds live mode. - A live login can refund and pay out, so have the person create an agent restricted key with approval rules.
stripe plugin install projectsadds Stripe Projects (a developer preview).stripe projects add <provider>/<service>signs a project up for a service such as Cloudflare, WorkOS or PostHog and writes its keys into the project's.env.
12. Add WorkOS for sign-in and PostHog for analytics
- Run
brew install workos/tap/workos. The person runsworkos auth login. - Check with
workos auth status >/dev/null 2>&1; echo $?, where 0 means logged in. workos mcp installconnects the agents.workos installinside a project adds AuthKit.- Staging is free. Production needs billing details and its own keys.
- For analytics, run
brew install posthog/tap/posthog-cli, have the person runposthog-cli login, then runclaude mcp add --transport http -s user posthog https://mcp.posthog.com/mcp.
13. Add Google Cloud for compute, with a budget alert on day one
- Run
brew install --cask gcloud-cli. The person runsgcloud auth login --update-adc. - Check with
gcloud auth list --filter=status:ACTIVE --format="value(account)". - The person creates a billing account with a card in the Console. Then run
gcloud projects create <id> --set-as-defaultandgcloud billing projects link <id> --billing-account=<account>. - Run
gcloud billing budgets create --billing-account=<account> --display-name=cap --budget-amount=<n>USD --threshold-rule=percent=0.5 --threshold-rule=percent=1.0. A budget only sends email. gcloud run deploy --source .runs an app.gcloud projects delete <id>stops its billing.