theonly1me/claude-code-mods/tree/main/plugins/scope-guard

一个 Claude Code 插件,用于检测 Claude 何时编辑或删除请求之外的文件。明确的漂移会在问题对话框中暂停;较轻微的漂移会在提示上方标记,并带有“拉回”、“确定”和“允许文件夹”键。
theonly1me/claude-code-mods/tree/main/plugins/scope-guard

Scope Guard 将您最近的三个提示作为任务,并首先根据廉价规则(非请求文件、项目外路径、删除/移动、大量重写、多文件限制)检查 Edit、Write、NotebookEdit 和文件删除/移动的 shell 命令。标记的更改会发送到确认模型,该模型将其分类为在范围内、轻微漂移或明确漂移。明确的漂移会在 Claude Code 的问题对话框中等待,并带有“允许一次”/“允许此任务”/“停止”选项;较轻微的漂移会在提示上方显示一个条带,并带有“拉回”、“确定”和“允许文件夹”键。命令:/scope、/scope off、/scope on、/scope flag、/scope ask。设置:mode、confirmModel、manyFiles。通过 claude plugin marketplace add theonly1me/claude-code-mods 和 claude plugin install scope-guard@claude-code-mods 安装。需要 Claude Code 2.1.289 或更高版本。
请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。
claude plugin marketplace add theonly1me/claude-code-mods claude plugin install scope-guard
Scope Guard notices when Claude starts to change things you did not ask for. Clear drift waits for your answer; milder drift is flagged above the prompt.

claude plugin marketplace add theonly1me/claude-code-mods
claude plugin install scope-guard@claude-code-mods
Register the marketplace once. Run /reload-plugins in an open session after installing. Requires Claude Code 2.1.289 or later; no build step or runtime dependencies.
Scope Guard keeps your last three prompts as the task. Before each Edit, Write, NotebookEdit, and each shell command that deletes or moves files (rm, git rm, mv, git mv), it checks cheap rules first:
A file your request names, a file Claude already changed this turn, and scratch files under /tmp never count. When the rules find enough, Sonnet 5.5 reads your task, what Claude said just before the change, and the change itself, and decides: in scope, mild drift, or clear drift. If the model call fails, the rules decide alone.
Install it and work as usual. Nothing shows until Claude drifts.
/scope: show the task Scope Guard keeps, the paths you allowed, and the recent flags./scope off and /scope on: stop or start the checks. The choice stays for the next sessions./scope flag: flag drift above the prompt but never stop Claude./scope ask: stop clear drift with a question again (the default).On clear drift, Claude waits on Claude Code's own question dialog:
Scope
Claude wants to delete docs/old.md, outside your request. The request is about math.js only. Allow it?
❯ 1. Allow once
2. Allow for this task
3. Stop
Milder drift runs, and a band above the prompt flags it:
▌ SCOPE Claude chose to edit README.md, which looks outside your request.
The README is related but the request was only about math.js.
7: Pull back 8: Fine 9: Allow the top folder type the number, Enter
Type the number and press Enter. When the prompt is empty and Claude is not streaming text, the number alone works too. The status line shows how many flags are open.
Change these in /plugin:
mode (ask): ask, flag, or off, as with the commands above.confirmModel (claude-sonnet-5-5): the model that confirms a drift the rules found.manyFiles (8): how many distinct files Claude may change in one turn before that counts as drift.Most changes never reach the model. Each change the rules flag costs one short confirm call at medium effort, and Claude waits for it (20 seconds at most) before the change runs.
See the marketplace README for configuration, privacy, updates, and removal.