Skip to content
claude-mods
Menu

Mod 2 · cw-guards

Worktree path guard

Refuses worktrees under temp folders and merges whose tracked symlinks would delete ignored data, and warns on broad adds in linked worktrees.

Refuses git worktree add under /tmp, /private/tmp or $TMPDIR, where worktrees lose the direnv credentials. It works on real paths (expanding ~, $HOME and $TMPDIR and resolving links), and the refusal names the corrected path <repo>/.claude/worktrees/<name>. It refuses rather than rewriting the path. EnterWorktree with a path under those folders is refused too.

Warns on git add -A, git add ., git add --all and git commit -a inside a linked worktree: the command runs, and the model is told to check what was staged and to stage paths by name.

Refuses git merge when an incoming tracked symlink would land on an ignored, untracked path, which git deletes without a prompt, and refuses git pull in a checkout that has an ignored directory, giving the fetch-then-merge steps instead.

Git runs only for those commands, bounded to 5 s each. /worktree-guard allow-symlink-merge lets the next refused merge or pull through, once, when you type it.