<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Worktrees on Nick Liu - Software Engineer</title><link>https://nick-liu.com/tags/worktrees/</link><description>Recent content in Worktrees on Nick Liu - Software Engineer</description><generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>nickboy@users.noreply.github.com (Nick Liu)</managingEditor><webMaster>nickboy@users.noreply.github.com (Nick Liu)</webMaster><copyright>2026 Nick Liu</copyright><lastBuildDate>Sat, 11 Jul 2026 15:08:00 -0700</lastBuildDate><atom:link href="https://nick-liu.com/tags/worktrees/index.xml" rel="self" type="application/rss+xml"/><item><title>Git worktrees gave each Claude agent its own sandbox. And scattered my sessions.</title><link>https://nick-liu.com/posts/parallel-agents-git-worktrees/</link><pubDate>Mon, 13 Jul 2026 00:00:00 +0000</pubDate><author>nickboy@users.noreply.github.com (Nick Liu)</author><guid>https://nick-liu.com/posts/parallel-agents-git-worktrees/</guid><description>&lt;div class="lead text-neutral-500 dark:text-neutral-400 !mb-9 text-xl"&gt;
 
I run four or more Claude Code agents at once, and until recently they all shared one working tree. Two agents editing the same repo means one of them eventually builds against the other's half-finished changes. Git worktrees fix that cleanly. What nobody warned me about is that the fix multiplies a different problem I already had: forgetting which folder a session lives in.

&lt;/div&gt;

&lt;nav class="series-progress" aria-label="Series progress"&gt;
 &lt;span class="series-progress-label"&gt;Taming Claude Code Sessions · Part 5 of 5&lt;/span&gt;
 &lt;ol class="series-progress-dots"&gt;&lt;li class="series-progress-dot is-done"&gt;
 &lt;a href="https://nick-liu.com/posts/find-claude-code-sessions/" title="Stop Losing Your Claude Code Conversations"&gt;1&lt;/a&gt;
 &lt;/li&gt;&lt;li class="series-progress-dot is-done"&gt;
 &lt;a href="https://nick-liu.com/posts/first-claude-code-hook/" title="Your First Claude Code Hook: Auto-Name Every Session"&gt;2&lt;/a&gt;
 &lt;/li&gt;&lt;li class="series-progress-dot is-done"&gt;
 &lt;a href="https://nick-liu.com/posts/tmux-window-titles/" title="Make tmux Show What Each Window Is Doing"&gt;3&lt;/a&gt;
 &lt;/li&gt;&lt;li class="series-progress-dot is-done"&gt;
 &lt;a href="https://nick-liu.com/posts/managing-many-ai-agents/" title="Running Several AI Coding Agents Without Losing Track"&gt;4&lt;/a&gt;
 &lt;/li&gt;&lt;li class="series-progress-dot is-current"&gt;
 &lt;a href="https://nick-liu.com/posts/parallel-agents-git-worktrees/" title="Git worktrees gave each Claude agent its own sandbox. And scattered my sessions." aria-current="step"&gt;5&lt;/a&gt;
 &lt;/li&gt;&lt;/ol&gt;
 &lt;/nav&gt;
&lt;div class="tested-with" role="note"&gt;
 &lt;span class="tested-with-icon" aria-hidden="true"&gt;🧪&lt;/span&gt;
 &lt;span&gt;Tested with &lt;strong&gt;Claude Code&lt;/strong&gt; &lt;code&gt;2.1.x&lt;/code&gt; · macOS&lt;/span&gt;
&lt;/div&gt;


&lt;h2 class="relative group"&gt;The symptom
 &lt;div id="the-symptom" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#the-symptom" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;With several agents in one directory, the working tree is shared mutable state. Agent A refactors a partial, agent B runs the build, and B&amp;rsquo;s &amp;ldquo;failure&amp;rdquo; is really A&amp;rsquo;s work in flight. I had been dodging this by scoping agents to different subdirectories, which works until it does not.&lt;/p&gt;</description></item></channel></rss>