cd /news/ai-agents/what-really-happens-when-two-claude-… · home › topics › ai-agents › article
[ARTICLE · art-178796] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

What Really Happens When Two Claude Code Sessions Edit the Same File

A developer at Flisk released Run My Agents, a Claude Code plugin that uses a PreToolUse hook on Edit, Write, MultiEdit and NotebookEdit to record which session touched a file in ~/.run-my-agents/claims.json, warning when two sessions edit the same file so the agent re-reads and merges instead of overwriting. The tool is a warning rather than a lock, skips lockfiles, generated files, dist/ and node_modules/, and ships with a macOS app and a local board page that lists sessions and flags conflicting edits. The author notes shell writes via sed or echo are not detected and that the approach does not cover agents on shared files across machines.

key takeaway

A PreToolUse hook that records per-session file claims in a shared JSON file can warn concurrent Claude Code sessions to re-read and merge rather than overwrite, though it misses shell writes like sed or echo and only covers sessions on one machine.

by read2 min views2 publishedNov 30, 2026

You open a second Claude Code session on the same repo to fix a bug while the first one works on a feature. Both touch api.ts. The later write wins and the earlier work is gone. Run My Agents is a small plugin that catches this.

In Claude Code:

/plugin marketplace add flisk-sh/run-my-agents
/plugin install run-my-agents@run-my-agents

There is also a macOS app, installed with curl -fsSL https://run-my-agents.flisk.si/install.sh | sh. The page says it is free, with no server, no account and no keys.

api.ts. A PreToolUse hook runs before Edit, Write, MultiEdit and NotebookEdit, and writes down which session touched the file in ~/.run-my-agents/claims.json. It is a warning, not a lock. The point is that the agent re-reads the file and merges its change into the new content instead of overwriting it.

Variable Default
RUN_MY_AGENTS_TTL_MINUTES 10
RUN_MY_AGENTS_DIR ~/.run-my-agents
RUN_MY_AGENTS_MODE warn (off disables the warning)
RUN_MY_AGENTS_IGNORE none, for example *.snap,docs/gen/**
RUN_MY_AGENTS_DEBUG off, 1 writesdebug.log

Lockfiles, *.generated.*, dist/ and node_modules/ are always skipped. When a session ends, its claims are dropped.

Git worktrees keep files apart but not ports. The Flisk agent docs say two worktrees of one repository inherit the same project name and fixed ports, so starting flisk up in both can cause container name conflicts and EADDRINUSE errors. Give each worktree a unique project.name in .flisk/project.json and distinct port overrides in .env, or run validation tasks one at a time.

The repo also has a local page that shows every Claude Code session as a card, with the files it touched and a warning when two sessions edited the same file. It reads ~/.claude/projects and refreshes every 5 seconds:

cd services/app/board && bun install && bun start

Then open http://localhost:4100.

sed or echo > file, are not seen. node on your PATH. If your agents run on shared files across machines, this will not help. For several sessions on one laptop, it is one small hook.

Next: starting computers for agents with Fleet.

── more in #ai-agents 4 stories · sorted by recency
── more on @claude code 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/what-really-happens-…] indexed:0 read:2min 2026-11-30 · —