SafetyAppears in · Pane / Toast / Band / InlineAdded

Worktree Guard

Stops one session from staging or discarding another session's work in a shared worktree.

Worktree Guard · Effect preview · IllustrationIllustrative
> Add pagination to the order list
⏺ I’ll look at the list component first.
❯

Illustration. Actual results depend on the mod, terminal and environment.

Install

/plugin marketplace add thieung/claude-mods
/plugin install worktree-guard@thieung-mods
/reload-plugins

Run these commands one at a time in a Claude Code session.

What it accesses

Based on the author’s documentation, checked when listed; use claude plugin validate to check for yourself.

Reads

Yes

Reads git status/diffs, Bash command text and output, and Edit/Write file paths.

Writes files

None

Runs commands

Yes

Runs read-only git (status, diff, clean -n) and lsof with fixed arguments.

Network

None

Introduction

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 -u or git 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 clean and 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-files prints the last guarded list.
  • Ports. On EADDRINUSE a 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.