{
  "id": 5035402,
  "title": "Two Claude Code sessions can message each other. That does not stop them overwriting your files.",
  "url": "https://urgent.news/2026/09/02/two-claude-code-sessions-can-message-each-other-that-does-not-stop",
  "topic": "ai",
  "section": "AI",
  "published": "2026-09-02T07:00:39.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/khasky/two-claude-code-sessions-can-message-each-other-that-does-not-stop-them-overwriting-your-files-5f2p"
  },
  "original_language": "en",
  "account": "Two separate Claude Code sessions can communicate with each other, but this does not prevent them from potentially overwriting your files. The Claude system allows for cross-session messaging, where one session can notify another about changes that affect its work, or answer questions the other is blocked on. This is achieved using two tools: ListAgents to see who is reachable and SendMessage to communicate with another session by name. However, the messaging system is not designed to lock files or coordinate changes made by different sessions.\n\nWhen two sessions attempt to edit the same file in a shared working directory, they can unintentionally overwrite each other's changes. Claude Code does not have any automatic source-file locking or merge layer to reconcile differences. Instead, each session operates within its own worktree, which is a separate directory with its own branch and copy of the tracked files. This isolation ensures that edits made in one session do not affect files in another session. Claude Code also refuses to make edits from within a worktree back at the main checkout, enforcing this isolation through the worktree system.\n\nTo avoid unexpected overwrites, it is recommended to use worktrees for each session, with each worktree having its own directory, branch, and copy of the tracked files. This way, edits in one session do not impact the files in another session. Additionally, it's advised to add .claude/worktrees/ to your .gitignore to prevent worktree contents from appearing as untracked noise in your main checkout.\n\nMessaging becomes more valuable when used to coordinate changes between sessions. For instance, if Session A makes changes to an API and commits them, it can then send the commit hash and a list of affected files to Session B. Session B can then rebase or cherry-pick the changes, re-read the affected files, and resolve any conflicts that may arise. This approach helps maintain a clear record of changes and allows for smooth coordination between sessions.\n\nHowever, Claude Code does not handle ownership of files such as package.json. The system does not inherently decide which session should be responsible for making changes to specific files. To avoid conflicts, it's essential to establish a protocol where only one session can own a file at a time. If multiple sessions need to modify the same file, they should coordinate through a message before touching the file and require a commit before claiming ownership. This ensures that only one session is actively working on a given file at any given time, minimizing the risk of overwriting each other's changes.\n\nAlternative approaches, such as Agent Teams or MCP Agent Mail, provide additional features and coordination mechanisms, but they still do not fully prevent conflicts when two sessions attempt to modify the same file. Agent Teams offers a shared task list, mailbox, and direct messages between agents, with a file lock to protect the task record. However, it does not prevent two writers from landing on the same file, emphasizing the need for file-level ownership and coordination. MCP Agent Mail provides persistent agent identities, an inbox and outbox with threads, file reservations, and TTL on stale reservations, but these reservations are advisory and do not enforce file-level locking.\n\nIn conclusion, isolation through worktrees is crucial for preventing unintended overwrites, while ownership and clear communication between sessions are key to maintaining data integrity. By using worktrees, establishing protocols for file ownership, and coordinating changes through messaging, you can effectively manage multiple Claude Code sessions working on the same project without risking file corruption.",
  "summary": "I ran two Claude Code sessions against one repository and assumed the hard part was coordination. It is not. The hard part is that coordination looks like it solves a problem it never touches. What is actually built in 🧐 Two sessions can find each other and talk. Anthropic's docs on cross-session messaging describe it: one session warns another that a change broke what it was building on, or…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 4,
    "also_reported_by": [
      {
        "outlet": "The New Stack",
        "title": "Meta’s Claude Code rival exits beta with three new subscription tiers — and it’s pushing hard on price",
        "url": "https://urgent.news/2026/09/01/metas-claude-code-rival-exits-beta-with-three-new-subscription-tiers",
        "published": "2026-09-01T14:55:30.000Z"
      },
      {
        "outlet": "XDA Developers",
        "title": "I gave Claude Code a deny list, and stopped watching every command it tried to run",
        "url": "https://urgent.news/2026/09/01/i-gave-claude-code-a-deny-list-and-stopped-watching-every-command-it",
        "published": "2026-09-01T18:00:16.000Z"
      },
      {
        "outlet": "Dev.to",
        "title": "I tested Claude Code's memory against mine. They are not doing the same job.",
        "url": "https://urgent.news/2026/09/01/i-tested-claude-codes-memory-against-mine-they-are-not-doing-the-same",
        "published": "2026-09-01T20:40:47.000Z"
      }
    ]
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}