Why two agents in one directory collide
Two agents editing the same files and the same Git index overwrite each other and mix their commits. A git worktree gives each task its own checkout and branch while sharing history and remotes, so each agent only touches its own directory.
Claude Code has this built in:
claude --worktree feature-auth
claude -w fix-login # in a second terminalThe repository needs at least one commit. The first time you use Claude in a directory, run claude there once to accept the trust prompt, or --worktree exits with an error. A new worktree is a fresh checkout, so install dependencies in it; list gitignored files such as .env in a .worktreeinclude file to copy them in automatically. Add .claude/worktrees/ to .gitignore.
Codex and other tools: plain git worktree
git worktree add ../myapp-feature-a -b feature-a
git worktree add ../myapp-fix-login -b fix-login
git worktree list
git worktree remove ../myapp-feature-aStart Codex inside each directory. Project instruction files such as CLAUDE.md and AGENTS.md travel with the branch, so every worktree gets the same rules.
Keep sessions alive with tmux
When a remote desktop or SSH connection drops, processes in a plain terminal can stop with it. Put each agent in its own tmux session and it keeps running:
tmux new -s feature-a # run claude or codex inside
# press Ctrl-b, then d, to detach
tmux attach -t feature-a # come back later
tmux ls # list sessionsFor Claude Code, Remote Control server mode can also host several sessions from one process, each in its own worktree with claude remote-control --spawn worktree, and you can follow them from your phone.
Limits and clean-up
- The agents are light: Claude Code needs 4GB+ RAM and the model runs in the cloud.
- Your project is heavy: several npm installs, xcodebuild runs, Docker containers or simulators at once strain memory and disk. Start with two sessions and check Activity Monitor before adding more.
- Usage: Claude and ChatGPT plans have usage limits, and parallel sessions use them up faster; API keys are billed per use.
When you exit a worktree session, Claude Code removes a clean worktree (it asks first for a named session) and asks whether to keep or remove one that has changes. Merge each branch through a reviewed pull request after the full test suite passes; do not let agents push to the main branch.
Many teams give each developer a dedicated Mac so tasks, accounts and permissions stay apart. A WodeMac M6 Mac mini comes with Claude Code and Codex installed, admin rights and 24/7 uptime.
| Plan | Paid upfront | Term |
|---|---|---|
| Monthly | $169 | 1 month |
| Quarterly | $481.65 | 3 months |
| Half-yearly | $912.60 | 6 months |
| Yearly | $1,723.80 | 12 months |
FAQ
Can two Claude Code sessions work on the same repository at once?
Yes, if each runs in its own git worktree. claude --worktree name creates one and starts the session in it; two sessions in the same directory overwrite each other.
How many agents can one Mac mini run?
There is no fixed number. The agents are light; the limits are the memory used by builds, tests and simulators running together, and your account's usage limits. Start with two and watch Activity Monitor.
Does --worktree work with Codex?
No, it is a Claude Code flag. For Codex, create the worktrees yourself with git worktree add and start Codex in each directory.
Do tasks stop when the remote desktop disconnects?
Not if they run inside tmux. Reconnect and run tmux attach to pick them up.
Sources
Compiled from information published on the review date. Configuration, stock, prices and rules may change; the current order page, confirmed quotes and terms take precedence. This is a setup guide, not a customer case study.