Skip to content

Update prek skills to warn against directory-scoped files patterns#1839

Merged
nathanjmcdougall merged 2 commits into
mainfrom
copilot/fix-prek-hook-directory-scope
Apr 7, 2026
Merged

Update prek skills to warn against directory-scoped files patterns#1839
nathanjmcdougall merged 2 commits into
mainfrom
copilot/fix-prek-hook-directory-scope

Conversation

Copilot AI commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Agents were configuring prek hooks with files: ^(src|tests)/ instead of using types filters or pass_filenames, silently missing violations outside those directories.

Changes

  • usethis-prek-add-hook (v1.4 → v1.5): New "File targeting" section with the directive to use types: [python] or pass_filenames: false instead of directory-scoped files patterns. Documents the narrow exception for pygrep hooks where the pattern is only a violation in a specific directory.
  • usethis-prek-hook-bespoke-create (v1.2 → v1.3): Added warning in the "Wiring into .pre-commit-config.yaml" key points against files-based directory scoping.

Principle

# ✗ Don't — silently misses violations outside src/tests
- id: check-comment-keywords
  types: [python]
  files: ^(src|tests)/

# ✓ Do — catches violations everywhere
- id: check-comment-keywords
  types: [python]

Update usethis-prek-hook-bespoke-create (v1.2 → v1.3) and
usethis-prek-add-hook (v1.4 → v1.5) to explicitly warn against using
directory-scoped `files` patterns when configuring prek hooks.

Resolves #1838

Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/82e3d1c4-6873-4c27-8d11-a07195120215

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix agent to never scope prek hooks to specific directories Update prek skills to warn against directory-scoped files patterns Apr 7, 2026
Copilot AI requested a review from nathanjmcdougall April 7, 2026 04:25
@nathanjmcdougall nathanjmcdougall marked this pull request as ready for review April 7, 2026 04:28
@nathanjmcdougall nathanjmcdougall merged commit 5eb75b1 into main Apr 7, 2026
1 check passed
@nathanjmcdougall nathanjmcdougall deleted the copilot/fix-prek-hook-directory-scope branch April 7, 2026 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

agent: never scope prek hooks to specific directories — use types or pass_filenames instead

2 participants