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.