feat: advisory PreToolUse hook for ~/.claude/reference/ naming scope (#286) - #306
Merged
Merged
Conversation
…286) Adds scripts/reference-scope-guard.sh: warns (never blocks) when a Write/Edit targets ~/.claude/reference/ with a filename that doesn't match the directory's convention (lowercase kebab-case, no SPEC-*/ GRILL-*/BRAINSTORM-* prefix, no .html). Wires it into install-guards.sh (install_hook, Edit|Write PreToolUse registration, guards.json seed) alongside branch-guard and no-switch-guard, and adds a 13-case e2e suite (tests/test_reference_scope_guard.sh) covering clean/flagged filenames, tilde-path expansion, and out-of-scope paths/tools. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2 tasks
Data-Wise
added a commit
that referenced
this pull request
Jul 25, 2026
reference-scope guard (PR #306)
Data-Wise
added a commit
that referenced
this pull request
Jul 26, 2026
docs/index.md's "Latest" callout and docs/NEWS.md were both still describing v4.3.0 (#305/#306) under a v4.4.0 label — NEWS.md never got a v4.4.0 entry after that release, and index.md's callout inherited the stale text. Also adds [Unreleased] entries to both CHANGELOGs for the two post-4.4.0 fixes from this session: the branch-guard.sh 2>&1 repo-sync (0d11236) and the --refine docs drift (cf11471).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scripts/reference-scope-guard.sh: an advisory-only PreToolUse hook that warns (never blocks) when a Write/Edit targets~/.claude/reference/with a filename that doesn't match the directory's naming convention — lowercase kebab-case, no.html, noSPEC-*/GRILL-*/BRAINSTORM-*prefix (those belong indocs/specs/).scripts/install-guards.shalongsidebranch-guard/no-switch-guard:install_hookcopy step,Edit|Write-onlyPreToolUseregistration,guards.jsonregistry seed — same idempotent, lock-coordinated pattern as the existing two guards.tests/test_reference_scope_guard.sh) covering clean filenames (silent), each violation type (advisory), tilde-path expansion, and out-of-scope paths/tools (silent).Closes #286.
Design notes
~/.claude/reference/andWrite/Edittool calls only (noBashmatcher, matching the issue's proposed scope).~/.claude/reference/(SPEC-proof-tutorial-tooling.md,SPEC-tutor-command-fixes-2026-07-13.md,tutor-cookbook.html) — these are correctly flagged (advisory) by the new hook, not retroactively fixed by this PR.Test plan
HOOK_SCRIPT=scripts/reference-scope-guard.sh bash tests/test_reference_scope_guard.sh— 13/13 passed (repo copy)bash scripts/install-guards.sh— installs cleanly, registersEdit|Writematcher, seedsguards.json;settings.json/guards.jsonbothjq-valid afterbash tests/test_reference_scope_guard.sh— 13/13 passed against the installed hookbash tests/test_branch_guard.sh— 141/141 passed (unaffected by this change)bash tests/test_no_switch_guard.sh— 39/39 passed (unaffected by this change)python3 -m pytest tests/— 2615 passed, 0 failed, 49 skipped, 1 xfailed, 1 xpassed (pre-existing/benign)🤖 Generated with Claude Code