Two Claude Code sessions can’t see each other: they run in separate context windows, working directories, and memory. That’s fine until the work in one depends on the work in the other, and you end up hand-carrying messages between two terminal windows.
I was building a real-time collaboration tool between two separately hosted WordPress sites, each talking to the other over an authenticated server-to-server connection. I ran one Claude Code session per site to build both ends at once.
The two ends had to line up exactly, so the sessions couldn’t work blind. I gave them a shared file to coordinate through.
The trick
The channel is a markdown file in /tmp. One agent writes requests and the other appends answers, with the first agent watching the file for changes. There’s no server, queue, or API between them, and both agents already have file tools, so there’s nothing to set up.
I wrapped it in a slash command, /collab. Run it in the first session with a task and it creates the file:
/tmp/collab-1719096000.md
It seeds the file with the task, some context, and a numbered list of requests for the other agent. Then it gives me a short message to paste into the second session: read the file, append your answers under ## Answers, don’t edit anything above that line, add a ## Questions section if you need to ask back.
Answers are appended, never edited, each one numbered and timestamped:
### Answer 1 (2026-06-22T14:02Z)
Plugin X is active. Version 2.1.0. Matches mine.
Nothing gets overwritten, so the file becomes the full log of the exchange.
Here’s the loop running:
Why it works
The first agent runs a watch loop: check the file’s modified time every five seconds, and when it changes, read the new content and show me what the other agent added. I see both halves of the conversation in one window.
Append-only is the load-bearing rule. Neither agent rewrites history, so there’s no race to overwrite a section. They just keep adding to the bottom, and I stay in the loop because every message passes through a file I can read.
The limits are the obvious ones: /tmp doesn’t survive a reboot and there’s no real locking. The handoff is manual too: I paste the file path into the second session myself. For two sessions on one machine in one sitting, none of that has gotten in the way.
It’s one command file. Here’s the whole thing: collab.md. It’s no code, just a markdown template, a join message, and the watch-loop instructions.
Update: I’ve since rewritten this command so it no longer assumes Claude or a single operating system, and I traded the endless watch loop for a turn-based one. The linked file above is that newer version, so it reads a little differently from the walkthrough here. The full story, including a real build with Claude and Codex on opposite ends, is in Claude and Codex, Coordinating Through One Shared File.








