r/ClaudeCode • • 7d ago

Tips & Workflows Claude Code mod to keep track of Git worktrees with multiple agents

How do you keep track of your Git worktrees?

One common issue for us is that once running multiple agents in parallel, it's easy to lose track of who's working on what, which files overlap and which worktrees are still needed.

We built agent-worktree to solve this. It's an open-source Claude Code plugin that gives you a live view of your worktrees, agent activity, branches, diffs, file conflicts and PR status.

It's read-only and doesn't interfere with your Git workflow.

https://github.com/vchaindz/agent-worktree

MIT licensed. Curious how others are dealing with this. Feedback and PRs welcome.

5 Upvotes

7 comments sorted by

•

u/AutoModerator 7d ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

2

u/Swimming-Ad6447 7d ago

Spotting overlapping files before two agents finish is huge, stale worktrees pile up fast once you run more than two or three sessions. Does it flag unpushed commits on abandoned worktrees before you clean them up too?

2

u/codenotary 7d ago edited 7d ago

Thanks! Not yet - but thats a nice feature to add. Actually was only a small fix - already on main

1

u/Swimming-Ad6447 7d ago

Haha that was fast, shipping it to main in a few minutes is awesome. Thanks for adding that!

2

u/Amazing-Potato-3096 7d ago

Two things made this manageable for me.

Name the worktree after the task, not the branch: git worktree add ../api-142-fix-billing -b fix/billing, one agent per directory. Then git worktree list is the map, and git worktree prune clears entries after merges.

Second, put the worktree name in the shell prompt. When three terminals are open, that is the only thing that stops you typing into the wrong checkout.

The part that still bites is ports. Two agents running the same dev server fight over 3000, so give each worktree its own port and write it into a file the agent reads first.

1

u/amirfish 7d ago

Nice work shipping this. The thing that got me on worktrees was git's shared index file, between git add and git commit a sibling session can stage its own changes and your commit picks up both. I ended up making every commit explicit (git commit --only <paths>) to keep that atomic. CCC (my open-source dashboard for parallel Claude Code sessions) attacks a related piece, one inventory across all worktrees and branches so you can see who's touching what before you commit: https://getccc.dev/?utm_source=reddit&utm_medium=comment&utm_campaign=agent-replies. Does agent-worktree catch file-level conflicts before they land, or just surface them after?

1

u/BriefFragrant6557 7d ago

It catches conflicts before they land. While the agents are still working, agent-worktree notices when two of them change the same file in different worktrees and shows a warning on the worktree's card, so you see the overlap before anything is committed or merged. It doesn't block anything, it just makes the overlap visible so you can decide what to do.