Git Worktrees Alone Don't Isolate AI Coding Agents; Ports and Data Need Per-Worktree IDs
Running two coding agents in separate Git worktrees can still cause conflicts, since both may start the app on the same port or share a database and test queue. Worktrees isolate branches and files but not the running system's resources. The article recommends giving each worktree a deterministic environment identity from which ports, database names, queue prefixes, storage prefixes, and temp directories are derived. It provides a shell script that generates these values from the branch name and a path hash, so the same worktree gets the same names each time. The approach also makes the environment visible in logs and simplifies cleanup, and it should be committed to the repository so human contributors share the same behavior.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in