ClaudeMods
☰
ZH-TW
● 0 人在線上 · 瀏覽 0 次
贊助提交作品
GitHub 儲存庫 · 發布者 theonly1me

scope-guard

一個 Claude Code 外掛程式,用於偵測 Claude 何時編輯或刪除請求之外的檔案。明確的漂移會在問題對話方塊中暫停;較輕微的漂移會在提示上方標記,並帶有「拉回」、「確定」和「允許資料夾」鍵。

theonly1me@theonly1me

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

原貼文圖片1
已翻譯

關於這個 mod

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
原文 / README

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.

Scope Guard preview

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.

How it works

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:

  • The file is not in your request, and Claude did not read or search it this turn.
  • The file is outside the project.
  • The change deletes or moves files.
  • The change rewrites most of a long file, or an edit removes 40 lines or more.
  • The file is the one that reaches the many-files limit for this turn (8 by default).

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.

How to use

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).

How to interact

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
  • Allow once lets this change run.
  • Allow for this task lets this file and its folder through until your next new request.
  • Stop refuses the change, and Claude reads why. Text typed under "Other" goes to Claude with the refusal.

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
  • 7 Pull back tells Claude to stay in scope and revert the change if the request does not need it. During a turn the note reaches Claude mid-turn; after the turn it becomes your next prompt.
  • 8 Fine clears the flag.
  • 9 Allow this folder clears every flag in that folder and stops new ones there for this task.

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.

Settings

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.

其他同名作品

更多類似作品