Skip to content

Context Guard hooks false positive on context-system rule files #12

@nathanschram

Description

Problem

The Context Guard hooks (context-structural-change.sh, context-guard-stop.sh, context-commit-guard.sh) detect changes to .claude/rules/*.md as "structural changes" and trigger context drift warnings. However, only context-quality.md was excluded from detection — the other three ContextDocs/PitchDocs infrastructure rules fall through to the wildcard pattern and trigger false positives:

  • .claude/rules/context-awareness.md — context trigger map (ContextDocs infrastructure)
  • .claude/rules/docs-awareness.md — docs trigger map (PitchDocs infrastructure)
  • .claude/rules/doc-standards.md — doc quality standards (PitchDocs infrastructure)

Observed behaviour

In brand-copilot/main, the context-updater agent was launched to "fix drift" that was actually a false positive from modifying context-awareness.md.

Fix

Expand the exclusion patterns in all three hooks to cover all four infrastructure rule files. User-defined rules (e.g., .claude/rules/naming.md) continue to trigger reminders as expected.

Files affected

  • hooks/context-structural-change.sh
  • hooks/context-guard-stop.sh
  • hooks/context-commit-guard.sh
  • tests/test-hooks.sh (12 new test cases)
  • .claude/hooks/* (synced via scripts/update-installed-hooks.sh)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions