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. 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 writes debug.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 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.