Skip to content

guardrails: cli-flag-verify PostToolUse hook flags pre-existing unrelated lines (not diff-scoped) #544

Description

@kyle-sexton

Category

behavioral / improvement

Observed during

PR babysitting on #528. Edited plugins/toolchain/skills/check/SKILL.md at line 65 (replacing a sed prefix-strip with ${DEFAULT_BRANCH#"$REMOTE/"} parameter expansion). The PostToolUse cli-flag-verify hook fired and reported:

UNKNOWN_FLAG: dotnet test --project (not found in 'dotnet test --help')

Problem

The flagged token lives on line 108 — unrelated prose about ecosystem gotchas (For ecosystem-specific gotchas (xUnit --nologo trap, dotnet test --project, etc.)...), 43 lines away from the actual edit. The hook scans the whole edited file, not the diff, so any edit to a file that already contains a flag the DB doesn't recognize surfaces a "possible hallucination" warning about a line the agent never touched.

Impact

  • Noise on every unrelated edit to any file containing a pre-existing (real or false-positive) flag hit.
  • Pressure to "fix" out-of-scope lines to silence the warning, or to add skip-list entries, neither of which the current edit warrants.
  • Erodes signal: a genuine hallucinated flag introduced by the edit is harder to spot amid pre-existing-line noise.

Suggested direction

Scope the cli-flag-verify check to tokens introduced/changed by the edit's hunk (diff-scoped), rather than re-scanning the entire file body on each PostToolUse. Separately, triage may want to confirm whether dotnet test --project is a genuine false positive in the flag DB (it is documented for dotnet test), but the diff-scoping behavior is the primary report.

Related

Filed per babysit self-observation. Not refiling known: #484, #465, #473, #499, #504, #511, #512, #524.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs-decisionAwaiting a human or maintainer judgment call.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions