Skip to content

guardrails: cli-flag-verify PostToolUse hook scans whole file, warns on pre-existing lines outside the edited hunk #543

Description

@kyle-sexton

Category: behavioral

What happened

During a babysit-prs pass on #529 I edited a single prose line (line 57) in plugins/testing/skills/diagnose/context/loop.md. The cli-flag-verify PostToolUse:Edit hook then flagged dotnet test --project on line 61 — a pre-existing, illustrative code block I did not touch:

cli-flag-verify: 1 unknown flag(s) in ...loop.md
  UNKNOWN_FLAG: dotnet test --project (not found in 'dotnet test --help')

Why it is friction

The hook re-scans the entire file after any edit rather than scoping to the changed hunk. Editing unrelated prose surfaces warnings about flags in lines the change never touched. On docs files that carry deliberately illustrative command snippets, this is recurring noise: every future edit to the file re-raises the same warning, and it competes for attention with warnings that ARE about the current change. (dotnet test --project is also SDK-version-dependent — valid under the .NET 10 MTP-based dotnet test, absent in older VSTest-based dotnet test — so the flag itself is arguable, but that is secondary to the scoping point.)

Suggested direction

Scope cli-flag-verify to the added/changed lines of the edit (the diff hunk) rather than the whole file, so it flags flags the current edit introduced, not pre-existing content. Whole-file scanning still has value for newly-created files; the regression is specifically re-warning on untouched lines during incremental edits.

Context

Filed by an automated PR-babysitting worker (self-observation).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: mediumReal value, no hard deadline; normal backlog flow.status: readyTriaged, unblocked, and fully specified; eligible to pick up.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions