Worktree Guard
Stops one session from staging or discarding another session's work in a shared worktree.
Illustration. Actual results depend on the mod, terminal and environment.
Install
/plugin marketplace add thieung/claude-mods
/plugin install worktree-guard@thieung-mods
/reload-pluginsRun these commands one at a time in a Claude Code session.
claude plugin marketplace add thieung/claude-mods
claude plugin install worktree-guard@thieung-modsThen run /reload-plugins in your session, or start a new session.
Please install the Claude Code mod "Worktree Guard" (https://github.com/thieung/claude-mods). Before installing, read the Security and Requirements sections of its README and tell me what it reads and writes, which commands it runs, whether it uses the network, and which Claude Code version, OS and terminal it needs. If everything looks fine, run claude plugin marketplace add thieung/claude-mods and claude plugin install worktree-guard@thieung-mods, then remind me to run /reload-plugins in my session.Send this to Claude Code so it reads the author’s instructions before installing.
git clone https://github.com/thieung/claude-mods
cd claude-mods
claude --plugin-dir ./worktree-guardClone the repository and try it in a local session with --plugin-dir.
What it accesses
Based on the author’s documentation, checked when listed; use claude plugin validate to check for yourself.
Reads
YesReads git status/diffs, Bash command text and output, and Edit/Write file paths.
Writes files
NoneRuns commands
YesRuns read-only git (status, diff, clean -n) and lsof with fixed arguments.
Network
NoneIntroduction
Worktree Guard is a Claude Code mod for worktrees shared by several sessions.
- Stage guard. It records files already dirty at session start and files this session writes via Edit/Write/NotebookEdit. When the model runs
git add -A,git add .,git add -uorgit commit -a, foreign files (dirty before, never edited by this session) trigger a question and are blocked unless you allow them; files of unknown origin only raise a toast. - Destructive preview.
git stash,git checkout -- …,git restore,git reset --hard,git cleanand similar are dry-run first so you can allow or block. - Display. A pane groups files by directory; narrow terminals (<144 columns) get a single line above the prompt;
/guard-filesprints the last guarded list. - Ports. On
EADDRINUSEa toast names the PID and cwd holding the port; at session end it lists listeners left in the worktree.
The author calls it a safety net, not access control: aliases, scripts and commands built at run time slip through, and plain git commit is not guarded. UI strings are in Vietnamese. No minimum Claude Code version is stated. Scores are calibrated from docs, not run-tested.
Who it is for
- People running several Claude Code sessions in one worktree
- Anyone worried the model will git add -A someone else's changes
Requirements
- Needs git; port lookup uses lsof.
- UI strings are in Vietnamese.