Inspired by discussions here and on X about AI agents going rogue with hallucinations or excessive edits, I decided to build Scope Guard: a lightweight plugin for Claude Code that intervenes before the agent completes its work, ensuring edits stay strictly within your specified intent.
Why Scope Creep Matters Scope creep happens because LLMs like Claude are trained to be helpful, but without explicit boundaries, they infer too much—leading to changes in files you didn't mention, or additions that seem "obviously" related but aren't. In production workflows, this means more time debugging, reviewing, or rolling back. Recent threads (like those on hallucinations in Claude Code) show this is a growing pain point as we rely more on AI for coding.
Introducing Scope Guard Scope Guard is a zero-dependency JavaScript plugin that hooks into Claude Code's lifecycle to enforce prompt adherence. It's minimalist by design: no API keys, no config files, just plug-and-play.
Key Features: Prompt Capture: Saves your original instruction for reference.
Real-Time Change Tracking: Logs edits asynchronously without slowing down the agent.
Strict Evaluation: Uses Git diffs to analyze modifications post-tool use. Only allows changes to explicitly mentioned files or those logically essential (e.g., a test file for a function update). Everything else? Blocked as scope creep.
User-Friendly Intervention: If creep is detected, it halts completion and explains why, with options to approve, undo, or refine your prompt.
Cleanup Script: Keeps your project tidy by removing old session data.
How It Works Install via /plugins add https://github.com/andreahlert/scope-guard in Claude Code.
On prompt submit, it captures the intent.
As the agent edits, changes are tracked.
Before stopping, it evaluates: Is this file mentioned? Is the change required? If not—bam, intervention.
Examples:
Allowed: Prompt "Add email validation to auth.js" → Edits auth.js and auth.test.js.
Blocked: Same prompt → Tries to tweak unrelated db.js? Nope.
It's licensed under AGPL-3.0, and the repo is open for contributions. Check it out here: https://github.com/andreahlert/scope-guard. Star it if this resonates, fork it if you want to hack on it, or drop feedback in the issues—I'd love to hear how it fits (or doesn't) in your workflow.
What do you think? Have you run into scope creep with Claude Code? Let's discuss below!
Cheers, André