collision-guard

Reviewed at commit 33a936f

Asks before Claude edits a file another open chat changed in the last 30 minutes: Proceed, Move to a worktree, or Cancel (/guard)

Made by
Nate Herk
What we checked

Before Claude edits or writes a file, checks whether another open chat on your machine changed that file in the last 30 minutes and, if so, asks you to proceed, move to a git worktree, or cancel. To do this each chat keeps a small file under ~/.claude/mods-data listing the files it edited, plus the start of its first prompt. No network calls.

Review details

Static review of the source at the pinned commit; not run. Hooks: session.start, session.end, prompt.submit (keeps the first 80 characters of the first prompt as the chat name), tool.call for Edit, Write and NotebookEdit, and command.run for /guard (on, off, window). Each chat writes ~/.claude/mods-data/collision-guard/<session id>.json with its title (the 80-character prompt start), folder and the paths and times of files it edited, refreshed every minute and emptied of paths at session end; the file is not deleted, so the title and folder stay. It reads the other chats' files there (ignored when older than 15 minutes) and optionally ~/.claude/mods-data/recording.json to hide chat names. It skips ~/.claude/projects and ~/.claude/mods-data. Runs one process: git ls-files --error-unmatch on the edited path (argument list, with --) to decide whether to offer the worktree option. The answer comes back to Claude as the refusal text, which includes the other chat's title; the worktree choice tells Claude to use EnterWorktree. Without a surface to ask (-p runs) the edit goes ahead. Settings are kept with $.store. No network, no model calls, no settings or config changes. Helper files (coach.mjs, fmt.mjs, privacy.mjs, pricing.mjs) are shared pure functions; only normPath, chatName, clip, basename, minutes and makeMasker are used.

What it uses
  • Reads your prompts: yes
  • Sees tool calls: yes
  • Blocks or changes tool calls: yes
  • Reads or writes files: yes
  • Runs programs on your machine: yes
  • Calls the model (uses tokens): no
  • Sends data over the network: no
  • Stores data: yes
  • Shows something on screen: yes
Hooked events
Made this mod? Add a badge to your README

modsforClaude badge for collision-guard

Paste this into your README. The badge says reviewed once the current version has been reviewed, and links readers to this page.

[![Listed on modsforClaude](https://modsforclaude.com/badge/collision-guard.svg)](https://modsforclaude.com/mods/collision-guard/)

← All mods