Title: agent: never scope prek hooks to specific directories — use types or pass_filenames instead · Issue #1838 · usethis-python/usethis-python · GitHub
Open Graph Title: agent: never scope prek hooks to specific directories — use types or pass_filenames instead · Issue #1838 · usethis-python/usethis-python
X Title: agent: never scope prek hooks to specific directories — use types or pass_filenames instead · Issue #1838 · usethis-python/usethis-python
Description: 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 word...
Open Graph Description: 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 ...
X Description: 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 ...
Opengraph URL: https://github.com/usethis-python/usethis-python/issues/1838
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"agent: never scope prek hooks to specific directories — use types or pass_filenames instead","articleBody":"## What happened\n\nThe `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.\n\n## Root cause\n\nThe 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.\n\n## Generalised principle\n\nWhen configuring prek hooks, never scope them to specific directories (e.g. `files: ^(src|tests)/`). Instead, either:\n1. Use `types: [python]` (or other type filters) to match all files of a given type across the entire repository, or\n2. Use `pass_filenames: false` and let the hook script determine its own file targets via CLI arguments.\n\nDirectory-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.\n\n## Resolution\n\nRemoved 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.\n\n## Follow-up\n\nConsider 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.","author":{"url":"https://github.com/nathanjmcdougall","@type":"Person","name":"nathanjmcdougall"},"datePublished":"2026-04-07T03:49:13.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/1838/usethis-python/issues/1838"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:79de9a07-90f6-13f4-930f-02891a802214 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A812:2D2253:ABFF73:F15413:6A4C9F1D |
| html-safe-nonce | f5eefb05cb1f935934188190986d4c8a9e7b9b2a35333d27db9d3e493a68f156 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBODEyOjJEMjI1MzpBQkZGNzM6RjE1NDEzOjZBNEM5RjFEIiwidmlzaXRvcl9pZCI6IjQzNjIyNzY2NDY1NjE4MTYzNDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6b15d3a8599d8b1b9e06e0fc297ec0ce659a1262c6974a30acc7ad5461fc0c85 |
| hovercard-subject-tag | issue:4215279934 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/usethis-python/usethis-python/1838/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d3893e9a9a703aa100c1ef2e96a0ea466498d99e229bd0f2e2549f146bfcbc0c/usethis-python/usethis-python/issues/1838 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d3893e9a9a703aa100c1ef2e96a0ea466498d99e229bd0f2e2549f146bfcbc0c/usethis-python/usethis-python/issues/1838 |
| og:image:alt | 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 ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nathanjmcdougall |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3d11bb817438277de2a940854450e83a7d32b6aeb5014e9e6b00a6423900251c |
| turbo-cache-control | no-preview |
| go-import | github.com/usethis-python/usethis-python git https://github.com/usethis-python/usethis-python.git |
| octolytics-dimension-user_id | 216362695 |
| octolytics-dimension-user_login | usethis-python |
| octolytics-dimension-repository_id | 842189705 |
| octolytics-dimension-repository_nwo | usethis-python/usethis-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 842189705 |
| octolytics-dimension-repository_network_root_nwo | usethis-python/usethis-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ae90d426644ca15e89bacceb72e51f4e9dbf85f7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width