Run parallel coding agents without melting your machine
Your coding agent works great on small tasks. But try to run multiple agents on parallel features and your laptop becomes a space heater while your terminal fills with memory warnings.
The problem isn't your hardware — it's that most people run agents like they're running a single massive IDE session. Every agent spawns its own language servers, loads the entire project into memory, and fights for the same resources.
Here's the pattern that fixes it: worktree isolation with shared language servers.
Git worktrees let you check out multiple branches simultaneously without duplicating the entire repository. Each agent gets its own isolated workspace, but they share the underlying Git history and can share language server processes.
Set it up like this:
# Main repo stays clean cd /your-project # Agent 1 gets feature-auth branch git worktree add ../project-auth feature-auth # Agent 2 gets feature-payments branch git worktree add ../project-payments feature-payments # Agent 3 gets bugfix-login branch git worktree add ../project-bugfix bugfix-login
Now each agent operates in its own directory with its own branch checked out. No conflicts, no accidentally committing to the wrong branch, no "wait, which agent changed this file?"
But here's the memory optimization most people miss: configure your language servers to share processes across worktrees.
For Rust projects, set this in each worktree's .vscode/settings.json:
{
"rust-analyzer.server.path": "/shared/rust-analyzer",
"rust-analyzer.cargo.buildScripts.enable": false,
"rust-analyzer.checkOnSave.command": "check",
"rust-analyzer.cargo.allFeatures": false
}The key is buildScripts.enable: false and allFeatures: false. This prevents each agent from triggering expensive build processes that eat memory and CPU.
For the terminal setup, give each agent its own tmux session but limit resource usage:
# Start agent sessions with resource limits tmux new-session -d -s agent-auth -c /project-auth tmux new-session -d -s agent-payments -c /project-payments tmux new-session -d -s agent-bugfix -c /project-bugfix # Set memory limits per session tmux send-keys -t agent-auth 'ulimit -v 2097152' Enter # 2GB virtual memory tmux send-keys -t agent-payments 'ulimit -v 2097152' Enter tmux send-keys -t agent-bugfix 'ulimit -v 2097152' Enter
The magic happens when you configure your agents to coordinate through a shared state file:
# /shared/agent-state.json
{
"active_agents": {
"auth": {"status": "coding", "eta": "2024-01-15T14:30:00Z"},
"payments": {"status": "testing", "eta": "2024-01-15T15:00:00Z"},
"bugfix": {"status": "blocked", "waiting_for": "auth"}
},
"shared_resources": {
"database": "locked_by_payments",
"test_server": "available"
}
}Each agent checks this file before starting expensive operations like running tests or migrations. No more agents stepping on each other or running conflicting database operations.
Warning: Don't share cargo target directories between worktrees. Rust's incremental compilation will get confused and you'll get weird build errors.
The result: I regularly run 3-4 coding agents on a MacBook Pro without thermal throttling. Each agent thinks it has the project to itself, but they're actually sharing resources intelligently.
Your agents work faster because they're not fighting for resources. Your laptop stays cool because you're not running redundant processes. And you never have to play "which agent broke the build" again.
This pattern works for any language, but it's especially powerful for Rust projects where compilation is expensive and memory usage can spike quickly. Once you set it up, parallel agent development actually becomes faster than sequential.