Need to Know
Several Claude Code sessions share one git checkout. Their files were safe, but each session kept telling me about the others' work. Three channels caused it. Here is the short rule that now governs what they report, and its limits.
I run several Claude Code sessions at once. Each has one task and its own terminal tab, and all of them work in one shared checkout of a personal monorepo. A small harness of mine keeps their files apart: each session commits only its own paths, and a guard refuses risky git commands and edits to a file another live session holds.
What it didn't keep apart was what they told me. A session would finish, and its report would describe files it had never touched. One left a few files uncommitted and explained that they looked like another session's material. Another warned me about something a different session was about to publish. Each tab existed for one task, and each one kept narrating the others.
My complaint to the harness, typos and all:
> "when there are changes to files and git etc clause show those diffs. So effect is that i se message from other sessions unrelated to current session, so I don't want this to be mixed fix it"
The files were isolated. My attention wasn't. Here is how the other sessions' work got into each reply, and the rule I wrote for it.
TL;DR
- Three channels carried other sessions' work into replies: git over the whole tree, Claude Code's own file-changed notes, and my harness's note about parallel sessions.
- None of them is a bug. Each gives the agent context it should have. Nothing told the agent that the context was for working, not for reporting.
- The fix is a rule, not a filter: report only your own work, scope git to your own paths, and mention another session only when asked or when it blocks or changes your task.
- It is an instruction, not enforcement, and I have no before-and-after measurement yet.
| 🧠| Start here: parallel agents in one checkout 1. Scope git to your own paths. Before a commit or a done report, the agent runs 2. Paste a rule into CLAUDE.md. The one below. It loads in the next session you start. 3. Keep the context, filter the report. Don't hide the other sessions from the agent. It needs to know who holds a file. Tell it what belongs in a reply. 4. Pick a worktree when files overlap. Overlapping edits, long or risky changes and branch work each get their own directory, so another session's uncommitted edits no longer show up in this one's |
The rule, wrapped short so it fits on a phone:
## Parallel sessions
Other sessions work in this
checkout. Report only your
own work. Before a commit or
a done report, scope git to
your paths, files you created
or generated included:
git status --short -- PATH...
git diff -- PATH...
Leave other sessions' changes
untouched and out of replies.
Mention another session only
when I ask, or in one line
when it blocks or changes
your task.A shared checkout can still be the right choice, and for this repository it is mine. My local search index reads that checkout. Claude's memory links into it. Local virtualenvs and ignored files live there, and every finished part lands on main anyway. If your setup looks like that, keep the shared checkout and fix what the agents say. If sessions keep touching the same files, use worktrees; One Task, One Session covers that side.
Three channels
When I read the transcripts, the other sessions' work reached a session in three ways, and I built one of them myself.
1. Git over the whole tree
Before it commits or reports done, Claude tends to run git status, git diff and git log. In a repository with one session, that's a good habit. It checks the work and catches stray changes.
In a shared checkout, those commands return everything: this session's edits, another session's uncommitted changes, a commit that landed a minute ago from a third tab. Then the model does what a careful assistant does. It summarizes what it found, all of it.
No harness code injects diffs. The model reports what it sees, and a whole-tree command shows it the whole tree.
There's also a view the session doesn't ask for. According to the settings reference, Claude Code reads a git status snapshot when a conversation starts: the current branch, the main branch, git status output and recent commits. In a shared checkout, that snapshot includes the other sessions' uncommitted work from the first message on. The same setting, includeGitInstructions, turns it off, but it also removes Claude Code's built-in commit and pull request instructions. I left it on, and I haven't measured how much this snapshot contributes.
2. Claude Code's file-changed notes
Claude Code adds context of its own to the conversation. Its docs list, among other things, "a note that a file Claude edited earlier has since changed on disk". In my transcripts these notes also arrived for files the session had read but never edited.
With one session, the change usually comes from a formatter or from you, and the note is useful. In a shared checkout, the change is sometimes another session's. A session that read a shared file early in its task is later told the file changed. Then it may reason about the change, or mention it, or try to account for it in its report.
3. My own parallel-sessions note
The third channel was mine. A hook in my harness injects a PARALLEL SESSIONS note: who else is working in this checkout, and the git rules that keep files safe. Commit only your own paths. Never stash, reset or clean the whole tree. Don't edit a file another session is editing without coordinating.
The note did what it was built for: protecting files. It also put the other sessions in front of the model, and nothing in it said not to talk about them. So the model talked about them. It had been handed context and tried to be useful with it.
What I counted, and what I didn't
I ran a script once over the 40 most recent sessions in that checkout. Claude Code had attached 43 file-changed notes. Seven were for files the session itself never edited, so they came from another session's edits: a shared memory index, a rulebook and a copy of the global instructions file. The same run counted 165 context attachments added by hooks, my parallel-sessions notes among them.
That's one run over one window of sessions. It shows that the channels were active in real work. It doesn't show how often one of them became an unwanted sentence in a reply, and I have no measurement from before or after the fix. So I don't claim it reduced anything.
The fix
The fix is one commit: about twenty lines of rule text and two test assertions.
The main part is a canonical rule in my harness's sessions procedure, under the heading "Keep sessions apart in what the user sees." In substance:
- A session reports only its own work.
- Other sessions' files, diffs, commits, uncommitted changes and work stay out of its replies, summaries and done reports, whichever channel brought them.
- It leaves that work untouched, without reporting it to the user, and it coordinates with the other session directly when paths overlap.
- For its own commit, it scopes git to its own paths, files it created or generated included.
- Its own leftovers from earlier tasks in the same tab are still its work, to commit or report.
- It mentions another session only when I ask, or in one line when that session blocks or changes its own task: it holds a file this one must edit, it already did the work, or a push conflicts with it.
The rest makes sure the rule reaches every session. The global instructions file that every session loads got a two-line pointer to the rule. The injected parallel-sessions note got one sentence:
> "Keep other sessions' work out of your replies: report only your own work, scope git status/diff to your paths, and mention another session only when asked or when it blocks or changes your task."
Two test assertions check that the injected note carries that sentence. The session tests passed (117), and so did the full suite (3,229 tests).
The rule doesn't try to block what a session receives. I can steer the model away from whole-tree git. I don't want to remove my own note, because it protects files. And the file-changed notes are worth keeping: a session that sees a file change under it can read it again before it overwrites anything. So the rule governs what a session says, not what it knows.
The exception matters as much as the rule. The same day, two sessions had been handed the same task. One noticed, stopped, and left the task to the other. That is exactly the kind of message I want, because it changes what the session is doing. A rule that said "never mention other sessions" would have hidden it.
What the review changed
Before landing, I gave the change to a fresh, isolated Claude reviewer with no tools and no memory of my conversation. It raised no high-severity findings. It still changed the rule, mostly by one word or one missing case:
- "Own task" became "own work". A session can have leftovers from an earlier task in the same tab. Under "own task," they would be nobody's work and would drop out of every report.
- Generated files joined the path-scoped check. Sessions create and generate files as well as edit them. A check that skips those leaves the session's own output uncommitted and unreported.
- An explicit exception for my questions. Read literally, the first version would have stopped a session from answering when I asked what the tab next to it was doing.
- "Silently" became "without reporting to the user". "Silently" could be read as "don't communicate at all," which would forbid the coordination between sessions that the same rule requires.
- Two claims got softer. "Can't be turned off" became "no setting is known to turn it off". "The harness injects no diffs" became "no harness code injects diffs".
The first of those softened claims didn't survive this article. While checking the docs for it, I found the switch in the Agent SDK docs. CLAUDE_CODE_DISABLE_ATTACHMENTS=1 turns off "Task list nudges, file-changed notes, and the skill list", and it also stops @ file mentions from expanding into file content. That trade is too broad for my interactive sessions, but the softer wording was right to hedge, and the rule text needs one more edit.
The lesson is about writing rules for agents. An agent tends to apply a rule's words literally, everywhere. "Task" or "work" decides whether leftovers count. "Silently" decides whether two sessions may coordinate. A missing exception decides whether a direct question gets an answer. People fill those gaps with common sense. An agent fills them with the text. A reviewer who never saw my conversation reads the text the way the agent will.
Files and attention are different problems
This is my view, not a measurement.
Isolating files and isolating attention are separate problems. Worktrees and guards decide what a session can change. They say nothing about what a session tells the person reading it. I had put real work into the first problem and treated the second as solved because nothing was getting overwritten.
What the agent should know is not what it should say. Shared context is a feature for the agent. A session that knows another one holds a file can stay away from it, and a session that sees a file change can read it again. For me, the same context is noise. I opened that tab for one task, and I want its report to be about that task.
The one-line exception keeps that separation honest: when another session blocks the task, holds a file or already did the work, it gets one line.
Limits
Running sessions don't see it at once. A session that's already running picks up the new global text only after a compaction or in a new session. The injected sentence reaches it with the next parallel-sessions note.
Other worktrees get a different note. Sessions in another worktree of the same repository receive a note without the new sentence. The rule still applies to them through the global instructions, just without the reminder.
It's an instruction, not enforcement. My guard can refuse a git command or an edit, because those are actions it can intercept. A sentence in a summary isn't an action. Nothing blocks a reply that breaks the rule.
There's no measurement yet. I counted the channels once. I haven't counted unwanted mentions before or after the change. Until I do, this is a rule I expect to help, not a result I can show.