scope-guard

Reviewed at commit d1db6fe

Tracks recognized file edits against a configurable threshold, with a model judge and user overrides that can permit further edits.

Made by
Yash Gadodia
What we checked

Counts the distinct files a turn edits (Edit, Write, NotebookEdit, and files written by Bash such as sed -i, redirects, tee, cp, mv, touch) and at a threshold of 4 refuses the edit and asks you to restate the goal. A Haiku call on your own account may let one in-scope edit through. In non-interactive runs it also ends the turn. It adds a short rule to the prompt context and stores only its threshold and judge settings.

Review details

Static review of the source at the pinned commit; not run. Registers session.start, prompt.submit, command.run (/scope [n|off|judge on|off|status]), prompt.context, turn.start and two tool.check hooks (editing tools and Bash). The tool.check hooks only deny or pass through; they never approve permissions. At the threshold the mod optionally calls $.model.complete with claude-haiku-4-5-20251001 (max 200 tokens), sending the first user prompt as the goal, the file names touched so far and the first 1500 characters of the pending edit or command; this stays on the user's own Claude account. A malformed or failed judge reply falls through to the ask or deny. Interactive sessions get a $.ui.ask with Stop, Continue or Off for this session; headless runs deny the edit and call $.turn.abort after 250 ms. Errors in the hooks fail closed (deny with an explanation). The prompt.context hook injects a named block describing the rule. It reads the session transcript ($.session.messages) once at session start to rebuild the goal and touched files. The CLAUDE_MODS_DISABLE env var turns it off. $.store holds threshold and judge flag. No network, fs or process calls of its own.

What it uses
  • Reads your prompts: yes
  • Sees tool calls: yes
  • Blocks or changes tool calls: yes
  • Reads or writes files: no
  • Runs programs on your machine: no
  • Calls the model (uses tokens): yes
  • Sends data over the network: no
  • Stores data: yes
  • Shows something on screen: yes
Hooked events
Screenshot of scope-guard

Counts the distinct files a turn edits and stops at a threshold to make the goal get restated, so a small ask cannot quietly become a refactor.

Made this mod? Add a badge to your README

modsforClaude badge for scope-guard

Paste this into your README. The badge says reviewed once the current version has been reviewed, and links readers to this page.

[![Listed on modsforClaude](https://modsforclaude.com/badge/scope-guard.svg)](https://modsforclaude.com/mods/scope-guard/)

← All mods