Original Reddit post

i’ve been running multiple Claude Code sessions simultaneously on the same codebase for a few months now and it took some painful trial and error to get it working smoothly. sharing what i learned in case it helps others. the problem: when you spin up 2+ agents on the same repo, they step on each other. one agent edits a file while another is reading it. build errors from one agent’s incomplete changes confuse the other agent. they fight over the same files and create merge conflicts. what actually works: give each agent a specific scope. i assign agents to different directories or different features. agent A works on the frontend, agent B works on the backend scripts, agent C handles database migrations. if their scopes don’t overlap, most conflicts disappear. use a shared CLAUDE.md with parallel agent rules. mine includes: “Multiple agents may be working simultaneously. If you see build errors in files you did NOT edit, do not try to fix them. Wait 30 seconds and retry the build - the other agent is likely mid-edit.” this single rule eliminated about 80% of the cascading failure loops. don’t share browser automation sessions. if multiple agents need to interact with a browser (testing, scraping, posting), each one needs its own isolated browser instance. i use separate playwright profiles with a lock file system so agents queue up instead of fighting over the same browser. log everything to a database. when you have 5 agents running in parallel, you lose track of what happened fast. i log every action (posts made, files edited, API calls) to postgres with timestamps and agent session IDs. without this i’d have no idea what my agents actually did overnight. git worktrees for risky work. for anything that touches shared code, i spin the agent up in a git worktree so it works on an isolated copy. when it’s done, i review the diff and merge manually. the mental model shift: stop thinking of parallel agents as “multiple developers” and start thinking of them as “CI/CD pipelines that happen to be intelligent.” give them clear inputs, isolated environments, and observable outputs. what’s your setup for running multiple agents? curious if anyone has found better patterns. submitted by /u/Deep_Ad1959

Originally posted by u/Deep_Ad1959 on r/ClaudeCode