You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add placement guidance to usethis-prek-add-hook skill (#1507)
* Initial plan
* Add placement guidance to usethis-prek-add-hook skill
Add two placement principles:
1. Configuration hooks before code hooks
2. Similar-purpose hooks close together
Also add placement as an explicit procedure step and bump version to 1.2.
Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/437beaf4-5ee2-4cef-9977-2d5b917a6315
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copy file name to clipboardExpand all lines: .agents/skills/usethis-prek-add-hook/SKILL.md
+17-2Lines changed: 17 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: Add a prek hook for dev
4
4
compatibility: usethis, prek, git
5
5
license: MIT
6
6
metadata:
7
-
version: "1.1"
7
+
version: "1.2"
8
8
---
9
9
10
10
# Adding a prek Hook
@@ -17,7 +17,8 @@ This project uses [prek](https://prek.j178.dev/) to manage Git hooks. Hooks are
17
17
18
18
1. Add the hook entry to `.pre-commit-config.yaml`.
19
19
2. Set the `priority` field on the hook.
20
-
3. If the tool is available as a Python package, add it as a dev dependency with `uv add --dev`.
20
+
3. Place the hook entry at the correct position in the file.
21
+
4. If the tool is available as a Python package, add it as a dev dependency with `uv add --dev`.
21
22
22
23
## Adding a hook entry
23
24
@@ -82,6 +83,20 @@ This ordering ensures that the comprehensive tool gets the final say and can cle
82
83
83
84
When adding a new hook, inspect the existing `.pre-commit-config.yaml` to determine the correct priority level. If the new hook writes to files already covered by another hook at a given priority level, use a **different** priority level and follow the ordering principle above. Introduce a new priority level if needed — there is no fixed limit on the number of levels.
84
85
86
+
## Placement within the file
87
+
88
+
Beyond priority levels, the **position** of a hook entry within `.pre-commit-config.yaml` matters for readability and maintainability. Follow these principles when deciding where to insert a new hook entry:
89
+
90
+
### Configuration hooks before code hooks
91
+
92
+
Place hooks that operate on **meta-programming or configuration files** (e.g. dependency syncing, pyproject.toml validation/formatting, lock file exports) **before** hooks that operate on **source code** (e.g. code formatters, linters, type checkers). This keeps the file logically structured: project setup and configuration concerns come first, then code quality concerns.
93
+
94
+
### Similar-purpose hooks close together
95
+
96
+
Place a new hook **close to existing hooks with a similar purpose or motivation**. For example, a new code formatter should be placed near other code formatters, not at the opposite end of the file from them. If two hooks need to be at different priority levels (e.g. to avoid write conflicts), they may still be placed adjacently in the file — priority ordering does not require physical separation.
97
+
98
+
Within the same priority group, **re-order hooks** if needed to maintain cosmetic proximity between the newly added hook and the most closely related existing hooks.
99
+
85
100
## Adding as a dev dependency
86
101
87
102
If the tool being added as a hook is available as a Python package, it should also be added as an explicit dev dependency:
0 commit comments