What happened
The check-comment-keywords prek hook was configured with files: ^(src|tests)/, restricting it to only source and test directories. This was caught in code review.
Root cause
The hook was configured based on the literal wording of the issue description ("scanning all Python files in src/ and tests/") rather than following the established conventions of existing hooks in the project. Existing hooks like check-docstring-substrings use types: [python] without any files restriction, applying to all Python files in the repository.
Generalised principle
When configuring prek hooks, never scope them to specific directories (e.g. files: ^(src|tests)/). Instead, either:
- Use
types: [python] (or other type filters) to match all files of a given type across the entire repository, or
- Use
pass_filenames: false and let the hook script determine its own file targets via CLI arguments.
Directory-scoped hooks are fragile — they silently miss violations in unexpected locations and create a false sense of coverage. If a check is worth running, it is worth running everywhere.
Resolution
Removed the files: ^(src|tests)/ line from the check-comment-keywords hook entry in .pre-commit-config.yaml, leaving types: [python] as the sole file filter.
Follow-up
Consider updating the usethis-prek-hook-bespoke-create and usethis-prek-add-hook skills to explicitly warn against directory-scoped files patterns for hooks that should apply project-wide.
What happened
The
check-comment-keywordsprek hook was configured withfiles: ^(src|tests)/, restricting it to only source and test directories. This was caught in code review.Root cause
The hook was configured based on the literal wording of the issue description ("scanning all Python files in
src/andtests/") rather than following the established conventions of existing hooks in the project. Existing hooks likecheck-docstring-substringsusetypes: [python]without anyfilesrestriction, applying to all Python files in the repository.Generalised principle
When configuring prek hooks, never scope them to specific directories (e.g.
files: ^(src|tests)/). Instead, either:types: [python](or other type filters) to match all files of a given type across the entire repository, orpass_filenames: falseand let the hook script determine its own file targets via CLI arguments.Directory-scoped hooks are fragile — they silently miss violations in unexpected locations and create a false sense of coverage. If a check is worth running, it is worth running everywhere.
Resolution
Removed the
files: ^(src|tests)/line from thecheck-comment-keywordshook entry in.pre-commit-config.yaml, leavingtypes: [python]as the sole file filter.Follow-up
Consider updating the
usethis-prek-hook-bespoke-createandusethis-prek-add-hookskills to explicitly warn against directory-scopedfilespatterns for hooks that should apply project-wide.