A defense-in-depth guard for DeepSeek Harness that prevents agents from silently creating or mutating Git worktrees.
It combines:
- A global
AGENTS.mdpolicy telling agents to stay in the current workspace unless the user explicitly requests a worktree. - A
tools/pre-executeguard that requires one-time human approval before mutatinggit worktreecommands execute.
Large Unity and game projects are expensive and risky to duplicate. Agents may otherwise create worktrees for isolation, parallel tasks, reviews, tests, or subagents even when the user did not request one. Prompt instructions reduce that behavior; an execution guard prevents prompt drift from silently carrying it out.
The following subcommands require one-time approval:
git worktree addgit worktree movegit worktree removegit worktree prunegit worktree lockgit worktree unlockgit worktree repair
git worktree list remains available without approval. Normal branch commands such as git switch -c feature are unaffected.
- DeepSeek Harness with the Web profile
- PowerShell 7+
- Node.js 20+ for tests
- An interactive DSH approval responder (provided by the Web app)
git clone https://github.com/cty41/dsh-worktree-guard.git
cd dsh-worktree-guard
pwsh -File ./scripts/install.ps1The installer:
- copies the plugin into
~/.dsh/profiles/web/plugins/dsh-worktree-approval; - appends clearly marked managed blocks to
~/.dsh/profiles/web/cordis.patch.ymland~/.dsh/AGENTS.md; - adds a
danger-full-access-askpermission preset; - selects that preset for future sessions;
- records the previous default preset for uninstall.
Use another DSH home or profile if needed:
pwsh -File ./scripts/install.ps1 -DshHome D:\dsh-home -Profile webCreate a new DSH session after installation. Permission snapshots on existing sessions are intentionally unchanged. If the running Web Host does not pick up the new local module, restart that Host once.
pwsh -File ./scripts/uninstall.ps1The uninstaller removes only managed blocks and the installed plugin directory. It restores the previous default permission preset when installation recorded one.
npm testThe tests cover Git executable variants, -C, quoted paths, command chains, read-only worktree listing, ordinary branch commands, and prose containing worktree examples.
This is a DSH tool-layer policy, not an operating-system sandbox. It inspects terminal tool command strings and fails closed when approval is rejected, cancelled, or unavailable. An opaque executable that internally runs Git cannot be identified by command-string inspection. The global agent policy prohibits indirect circumvention; stronger adversarial isolation requires an OS policy or Git executable proxy.
MIT