scope-guard

Enforce authorized scope and smallest sufficient diffs for bounded modification tasks in existing projects. Use when an agent is asked to fix, change, update, modify, rename, add, or remove a specified behavior or file—especially “only,” “do not touch,” local bug fixes, validation changes, API changes, or targeted refactors—and must separate necessary support from beneficial extras, report adjacent issues, and audit the final diff. Do not use for read-only analysis or open-ended greenfield exploration.

O que é scope-guard?

scope-guard is a Claude Code agent skill that enforce authorized scope and smallest sufficient diffs for bounded modification tasks in existing projects. Use when an agent is asked to fix, change, update, modify, rename, add, or remove a specified behavior or file—especially “only,” “do not touch,” local bug fixes, validation changes, API changes, or targeted refactors—and must separate necessary support from beneficial extras, report adjacent issues, and audit the final diff. Do not use for read-only analysis or open-ended greenfield exploration.

Funciona com~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/shikaizhong-design/skills/tree/HEAD/skills/scope-guard

Installed? Explore more Programação e Desenvolvimento skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

Perguntar na sua IA favorita

Abre um novo chat com esta habilidade de agente já pré-carregada.

Documentação

Scope Guard

Honor the user's actual authorization boundary. Minimize scope, not correctness.

Establish the contract

Before editing, derive these items internally:

  • Requested outcome: the observable result the user asked for.
  • Authorized scope: named targets plus any explicitly authorized refactor, cleanup, or batch work.
  • Preservation constraints: explicit prohibitions and behavior that must remain unchanged.
  • Unspecified areas: preserve by default; do not optimize by default.

Treat “no change needed” as a successful outcome when the requested state already holds. Ask only when ambiguity would materially change the target, public contract, data, dependencies, destructive effects, or blast radius; otherwise choose the narrowest reversible interpretation.

Classify candidate changes

Classify every proposed file or hunk:

  • Required: directly delivers an explicitly requested outcome.
  • Necessary support: not directly requested, but omitting it would make the requested outcome incorrect, break the affected build or tests, or violate an existing contract on the changed path.
  • Unrelated: merely cleaner, more consistent, more maintainable, future-proof, or independently useful.

Apply this counterfactual test to Necessary support:

If this change is omitted, can the authorized outcome still be complete and correct?

If yes, do not make it. “Beneficial” is not evidence of necessity. Project-wide consistency is not necessary unless the request or an affected contract requires it.

Example: asked to "make parse_date reject empty strings", the agent edits parse_date and adds a test for it (required). One caller would now crash on the new error, so updating that caller passes the test: without it the outcome is incorrect (necessary support). Making parse_time reject empty strings too, or renaming a badly named argument, fails the test: the request is complete without them, so report them instead of changing them.

Execute within scope

  • Make the smallest scope that fully satisfies the authorized request, not the fewest possible lines.
  • Include necessary consumers, tests, schemas, or configuration when the counterfactual test proves they are required.
  • Do not perform drive-by refactors, formatting, renames, dependency upgrades, documentation edits, CI changes, cleanup, or adjacent bug fixes.
  • Report adjacent problems instead of repairing them unless they block the requested outcome.
  • Respect explicitly broad authorization; do not force a tiny diff when the user requested a module-wide refactor, cleanup, or batch fix.
  • Preserve pre-existing user changes. Inspect the starting worktree state when relevant, and never revert a hunk unless it was created during this task.

Audit before finishing

Inspect the complete task diff, not only the last edit:

  1. Map every changed file and hunk to Required or Necessary support.
  2. Re-run the counterfactual test for every Necessary support item.
  3. Remove task-created Unrelated changes without disturbing pre-existing work.
  4. Verify the requested outcome and preservation constraints with focused checks, then broader checks only when risk warrants them.
  5. Report the implemented outcome, verification, necessary support, and any adjacent issue left untouched.

Do not write an essay defending omitted extras. If the user questions an extra change, re-evaluate it against the original contract first; acknowledge and remove a beneficial-only task change instead of inventing a post-hoc justification.

Individual skills in this repo

This repo contains 2 individual skills — each has its own dedicated page.

Habilidades Relacionadas