@robhowley/py-pit-skills 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,192 @@
1
+ ---
2
+ name: click-cli-linter
3
+ description: Audit and improve existing Python Click CLIs by identifying architecture problems, anti-patterns, and CLI UX issues, then proposing minimal, high-value fixes.
4
+ disable-model-invocation: false
5
+ ---
6
+
7
+ # click-cli-linter
8
+
9
+ Use this skill when reviewing or fixing an **existing** Python CLI built with **Click**.
10
+
11
+ This skill focuses on:
12
+ - identifying structural problems
13
+ - detecting non-idiomatic Click usage
14
+ - improving CLI UX
15
+ - proposing minimal patches rather than unnecessary rewrites
16
+
17
+ Apply this skill when the user:
18
+ - asks to audit a Click CLI
19
+ - wants feedback on existing Click code
20
+ - asks why a Click CLI feels messy or hard to maintain
21
+ - wants minimal fixes for a Click-based command-line tool
22
+ - pastes Click code and asks for improvement
23
+
24
+ Do not apply when:
25
+ - the user wants a new CLI designed from scratch with no existing code
26
+ - the task is unrelated to Python CLIs
27
+ - the user explicitly wants another framework
28
+
29
+ # Invocation heuristics
30
+
31
+ Prefer this skill when the user:
32
+ - mentions existing Click code
33
+ - asks for review, linting, cleanup, or refactoring
34
+ - wants architecture feedback on a Click CLI
35
+ - wants to fix help text, options, command grouping, or code layout
36
+
37
+ Do not prefer this skill when:
38
+ - there is no existing CLI to review
39
+ - the task is purely explanatory and not evaluative
40
+ - the user is asking for a fresh implementation only
41
+
42
+ # Mission
43
+
44
+ Audit an existing Click CLI and provide:
45
+ 1. the most important detected issues
46
+ 2. why they matter
47
+ 3. the smallest effective patch
48
+ 4. an improved version when useful
49
+
50
+ Prefer **minimal, high-leverage improvements** over full rewrites.
51
+
52
+ # Core review mental model
53
+
54
+ Review the CLI across three layers:
55
+ - architecture
56
+ - Click idioms
57
+ - command-line UX
58
+
59
+ Do not nitpick style unless it affects correctness, maintainability, or usability.
60
+
61
+ # The 5 review invariants
62
+
63
+ Always follow these rules.
64
+
65
+ ## 1. Prioritize real problems
66
+
67
+ Focus on:
68
+ - architecture breakdown
69
+ - non-idiomatic Click usage
70
+ - poor command discoverability
71
+ - inconsistent argument and option patterns
72
+ - output and help text problems
73
+
74
+ Do not pad the review with trivial style comments.
75
+
76
+ ## 2. Prefer minimal patches
77
+
78
+ Fix the smallest thing that materially improves the CLI.
79
+
80
+ Prefer:
81
+
82
+ print("Done")
83
+
84
+ to:
85
+
86
+ click.echo("Done")
87
+
88
+ rather than rewriting the whole command.
89
+
90
+ ## 3. Distinguish severity
91
+
92
+ Separate:
93
+ - correctness issues
94
+ - maintainability issues
95
+ - UX issues
96
+
97
+ Make it clear which problems are most important.
98
+
99
+ ## 4. Preserve intent
100
+
101
+ Do not change command names, hierarchy, or behavior unnecessarily.
102
+
103
+ Improve structure and idioms while preserving what the CLI is trying to do unless the current design is clearly broken.
104
+
105
+ ## 5. Stay Click-native
106
+
107
+ Recommend:
108
+ - `click.echo()`
109
+ - command groups where appropriate
110
+ - clear `@click.option()` / `@click.argument()` usage
111
+ - modularization for multi-command CLIs
112
+
113
+ Avoid recommending solutions that drift into another framework unless explicitly requested.
114
+
115
+ # Standard operating procedure
116
+
117
+ ## Step 1 — Inspect the CLI
118
+
119
+ Check for:
120
+ - monolithic files
121
+ - missing command groups
122
+ - awkward command hierarchy
123
+ - lack of help text
124
+ - inconsistent option naming
125
+ - misuse of positional arguments
126
+ - `print()` instead of `click.echo()`
127
+ - argparse-style parsing habits
128
+ - unnecessary global state or implicit shared state
129
+
130
+ ## Step 2 — Classify the issues
131
+
132
+ Group issues into:
133
+ - Correctness
134
+ - Maintainability
135
+ - UX
136
+
137
+ ## Step 3 — Propose minimal patches
138
+
139
+ Prefer small targeted changes.
140
+
141
+ Examples:
142
+ - replace `print()` with `click.echo()`
143
+ - add `help=` text to options
144
+ - split commands into modules when the file is clearly too large
145
+ - convert a flat command set into a root group only when the CLI structure already implies subcommands
146
+
147
+ ## Step 4 — Show the improved version
148
+
149
+ When useful, provide:
150
+ - a minimal diff-style patch
151
+ - or the corrected code block
152
+ - or a revised file layout for multi-command CLIs
153
+
154
+ # Output contract
155
+
156
+ When linting or reviewing a Click CLI, prefer this structure:
157
+
158
+ 1. Detected Issues
159
+ 2. Why They Matter
160
+ 3. Minimal Patch
161
+ 4. Improved Version
162
+
163
+ If the user asks for only a patch, still internally follow this structure and return the patch directly.
164
+
165
+ # Anti-patterns to flag
166
+
167
+ Call these out explicitly when present:
168
+ - `print()` instead of `click.echo()`
169
+ - mixing Click with argparse-style parsing
170
+ - manual help text formatting Click should generate
171
+ - all commands jammed into one file without need
172
+ - missing root groups for obvious multi-command CLIs
173
+ - inconsistent long-option naming
174
+ - positional arguments used for optional configuration
175
+ - hidden shared mutable state
176
+
177
+ # Response style
178
+
179
+ - concise
180
+ - specific
181
+ - patch-oriented
182
+ - severity-aware
183
+ - no unnecessary rewrite pressure
184
+
185
+ # Completion checklist
186
+
187
+ Before finishing an answer verify:
188
+ - the most important issues are identified first
189
+ - the patch is minimal and useful
190
+ - Click-native fixes are preferred
191
+ - the review preserves the CLI's intent
192
+ - the answer improves maintainability or UX in a concrete way
@@ -0,0 +1,398 @@
1
+ ---
2
+ name: code-quality
3
+ description: Opinionated code health stack for Python repos using Ruff, pre-commit, and Markdown linting. Prefers consolidation over redundant tooling, preserves working repos unless migration is requested, and provides a simple adoption path for both new and existing projects.
4
+ disable-model-invocation: false
5
+ ---
6
+
7
+ # code-quality
8
+
9
+ Opinionated guidance for adopting a **small, high-signal code health stack** in Python repositories.
10
+
11
+ This skill standardizes on:
12
+
13
+ - **Ruff** for Python linting and formatting
14
+ - **pre-commit** for local enforcement
15
+ - **Markdown linting** for docs quality
16
+ - a small set of **file-sanity hooks**
17
+
18
+ This skill is intentionally opinionated.
19
+ It favors **consolidation, low redundancy, fast feedback, and easy adoption**.
20
+
21
+ It is designed for both:
22
+
23
+ - **new repos** that need a clean default stack
24
+ - **existing repos** that want to add, simplify, or migrate code-quality tooling
25
+
26
+ This skill does **not** assume the repo must be 0→1.
27
+ It should be applied tactically in real repos with existing constraints.
28
+
29
+ ---
30
+
31
+ # Apply this Skill When
32
+
33
+ Apply this skill when the user:
34
+
35
+ - asks to add linting, formatting, hooks, or repo hygiene
36
+ - wants to standardize or simplify Python quality tooling
37
+ - wants to add or improve pre-commit
38
+ - wants to move to Ruff
39
+ - wants to reduce overlapping tools such as Black + isort + Flake8
40
+ - wants docs quality checks such as Markdown linting
41
+ - asks what local and CI checks a Python repo should run
42
+
43
+ Trigger phrases: "my CI keeps failing on style checks", "can I replace Black and Flake8 with
44
+ something simpler?", "what pre-commit hooks should I be using?", "how do I
45
+ set up linting for a new Python project?", "our repo has no formatting
46
+ enforcement, where do I start?"
47
+
48
+ Do **not** apply this skill when:
49
+
50
+ - the task is unrelated to repo tooling or code health
51
+ - the user explicitly wants a different stack
52
+ - the repo is constrained by external rules the user wants preserved
53
+
54
+ ---
55
+
56
+ # Mission
57
+
58
+ When this skill is active, the model's job is to assess the repo's current
59
+ code health tooling, produce concrete ready-to-use config that installs the
60
+ preferred stack or closes the gap from where the repo is, and leave the
61
+ developer with exact commands to verify it works.
62
+
63
+ ---
64
+
65
+ # Hard Rules
66
+
67
+ **MUST:**
68
+
69
+ - Prefer a **small number of high-leverage tools** over overlapping tool chains.
70
+ - Use **Ruff as the preferred Python lint + format target** unless the user explicitly wants something else.
71
+ - Keep the quality contract **easy to run locally** and **easy to mirror in CI**.
72
+ - Prefer **incremental adoption** in existing repos when a big-bang migration is unnecessary.
73
+ - Keep configuration centralized where practical, preferably in `pyproject.toml`.
74
+
75
+ **MUST NOT:**
76
+
77
+ - Introduce redundant Python tooling without a clear reason.
78
+ - Treat pre-commit as a kitchen-sink dumping ground.
79
+ - Add CI-only quality checks that are not part of the repo's local development contract.
80
+ - Replace a working stack silently; migration should be explicit when meaningful change is involved.
81
+ - Spread config across unnecessary files when one canonical location is sufficient.
82
+ - Add mypy, pyright, Black, isort, Flake8, autoflake, or similar tools "just because."
83
+ - Preserve overlapping tools after migrating to Ruff unless a specific gap requires it.
84
+ - Propose type-checking as part of the default code-health stack.
85
+
86
+ ---
87
+
88
+ # Core Position
89
+
90
+ The recommended default stack is:
91
+
92
+ - **Ruff** as the single Python lint + format tool
93
+ - **pre-commit** as the local enforcement layer
94
+ - **Markdown linting** for human-facing docs
95
+ - a few **boring sanity hooks** for common repo mistakes
96
+
97
+ This stack is preferred because it is:
98
+
99
+ - fast
100
+ - simple
101
+ - low-overhead
102
+ - easy to understand
103
+ - easy to adopt incrementally
104
+
105
+ ---
106
+
107
+ # SOP
108
+
109
+ 1. **Inspect existing tooling** — look for `.pre-commit-config.yaml`,
110
+ `pyproject.toml` tool sections, existing linters/formatters, CI config.
111
+ 2. **Assess the state** — healthy / partial / messy / missing. Identify
112
+ redundant tools (Black + isort + Flake8, etc.).
113
+ 3. **Recommend the smallest coherent path** — full install for green-field,
114
+ targeted extension or migration for existing repos.
115
+ 4. **Generate config** — use the canonical templates below as the starting
116
+ point; adapt rev pins and rule selections to match the repo's Python version
117
+ and existing suppressions.
118
+ 5. **Call out removals** — explicitly name overlapping tools to delete and why.
119
+ 6. **End with verification commands** — exact `ruff`, `pre-commit`, and
120
+ markdownlint commands to confirm the stack is working.
121
+
122
+ ---
123
+
124
+ # Preferred Stack
125
+
126
+ ## Python quality
127
+
128
+ Use Ruff for:
129
+
130
+ - linting
131
+ - formatting
132
+ - import sorting
133
+ - common modernization and cleanup checks
134
+
135
+ Preferred commands:
136
+
137
+ ```bash
138
+ ruff check .
139
+ ruff format .
140
+ ```
141
+
142
+ Ruff is the preferred consolidation target for Python code health.
143
+
144
+ ---
145
+
146
+ ## Local enforcement
147
+
148
+ Use pre-commit to run:
149
+
150
+ - Ruff check
151
+ - Ruff format check or formatter hook
152
+ - Markdown lint
153
+ - basic file-sanity hooks
154
+
155
+ Pre-commit should enforce the repo contract locally, not invent a second policy.
156
+
157
+ ---
158
+
159
+ ## Documentation quality
160
+
161
+ Use a Markdown linter for:
162
+
163
+ - `README.md`
164
+ - docs files
165
+ - contribution docs
166
+ - workflow docs
167
+ - skill docs or similar human-facing instructions
168
+
169
+ Docs are part of repo quality and must not be ignored.
170
+
171
+ ---
172
+
173
+ ## Basic sanity hooks
174
+
175
+ Prefer a small set of high-signal hooks such as:
176
+
177
+ - trailing whitespace cleanup
178
+ - end-of-file newline
179
+ - mixed line ending normalization
180
+ - YAML validation
181
+ - TOML validation
182
+ - merge conflict marker detection
183
+ - large file checks when appropriate
184
+
185
+ Keep this list short and boring.
186
+
187
+ ---
188
+
189
+ # Canonical Config Templates
190
+
191
+ Use these as the blessed starting point. Adapt rev pins and rule selections to the repo — the structure is the stable part.
192
+
193
+ ## `.pre-commit-config.yaml`
194
+
195
+ > **Note:** rev pins go stale — update to current stable versions before committing. The structure is the stable part.
196
+
197
+ ```yaml
198
+ repos:
199
+ - repo: https://github.com/pre-commit/pre-commit-hooks
200
+ rev: v4.6.0
201
+ hooks:
202
+ - id: trailing-whitespace
203
+ - id: end-of-file-fixer
204
+ - id: check-yaml
205
+ - id: check-toml
206
+ - id: check-merge-conflict
207
+
208
+ - repo: https://github.com/astral-sh/ruff-pre-commit
209
+ rev: v0.6.0
210
+ hooks:
211
+ - id: ruff
212
+ args: [--fix]
213
+ - id: ruff-format
214
+
215
+ - repo: https://github.com/igorshubovych/markdownlint-cli
216
+ rev: v0.41.0
217
+ hooks:
218
+ - id: markdownlint
219
+ ```
220
+
221
+ ## `pyproject.toml` Ruff block
222
+
223
+ > **Note:** adjust `target-version` to match the repo's Python version.
224
+ > `select` covers errors, pyflakes, import sorting, and pyupgrade — a
225
+ > high-signal low-noise default. Expand only when there's a clear reason.
226
+
227
+ ```toml
228
+ [tool.ruff]
229
+ line-length = 88
230
+ target-version = "py312"
231
+
232
+ [tool.ruff.lint]
233
+ select = ["E", "F", "I", "UP"]
234
+ ```
235
+
236
+ ---
237
+
238
+ # Existing Repo Strategy
239
+
240
+ This skill should be used **opportunistically and tactically** in existing repos.
241
+
242
+ General approach:
243
+
244
+ 1. identify the repo's current tooling
245
+ 2. determine whether it is healthy, partial, messy, or missing
246
+ 3. recommend the **smallest coherent path** toward a cleaner stack
247
+ 4. prefer consolidation when the repo is already paying complexity costs
248
+
249
+ This skill should **not** read like a rigid if/else decision tree.
250
+ It should behave like a practical engineer improving the repo from where it is.
251
+
252
+ Examples:
253
+
254
+ - a repo with no linting can adopt the preferred stack directly
255
+ - a repo with Black + isort + Flake8 can migrate toward Ruff if the user wants simplification
256
+ - a repo with partial pre-commit can add Ruff and Markdown lint without a full tooling reset
257
+ - a repo with a working non-Ruff stack should not be rewritten unless the user wants the change
258
+
259
+ ---
260
+
261
+ # Migration Bias
262
+
263
+ When the user wants to simplify or modernize tooling, the preferred migration target is:
264
+
265
+ - **Ruff**
266
+ - **pre-commit**
267
+ - **Markdown lint**
268
+ - minimal sanity hooks
269
+
270
+ Migration should aim to:
271
+
272
+ - remove redundancy
273
+ - reduce tool count
274
+ - preserve developer ergonomics
275
+ - preserve CI clarity
276
+ - keep adoption understandable
277
+
278
+ When migrating to Ruff, prefer to remove overlapping tools rather than run both indefinitely.
279
+
280
+ ---
281
+
282
+ # Config Discipline
283
+
284
+ Prefer `pyproject.toml` as the canonical configuration home for:
285
+
286
+ - Ruff
287
+ - pytest, when applicable
288
+ - other Python tooling that supports it
289
+
290
+ Use separate config files only when a tool truly requires them.
291
+
292
+ Do not create config sprawl.
293
+
294
+ ---
295
+
296
+ # Pre-commit Discipline
297
+
298
+ Pre-commit should be:
299
+
300
+ - fast enough that developers will actually use it
301
+ - aligned with the repo's real standards
302
+ - limited to checks with strong signal
303
+
304
+ Do not overload pre-commit with slow, redundant, or low-value hooks.
305
+
306
+ Pre-commit is an enforcement layer, not a philosophy engine.
307
+
308
+ ---
309
+
310
+ # CI Discipline
311
+
312
+ CI should mostly replay the same code-health contract expected locally.
313
+
314
+ Recommended CI quality steps:
315
+
316
+ - Ruff check
317
+ - Ruff format check
318
+ - Markdown lint
319
+ - tests, if present
320
+
321
+ Avoid introducing style tools in CI that developers are not expected to run locally.
322
+
323
+ ---
324
+
325
+ # Ignore Philosophy
326
+
327
+ Use a minimal-ignore approach.
328
+
329
+ Rules:
330
+
331
+ - prefer fixing code over expanding ignore lists
332
+ - prefer narrow rule-level ignores over broad file-level ignores
333
+ - document non-obvious ignores briefly
334
+ - do not accumulate unexplained exceptions
335
+
336
+ A large ignore list is usually a signal that the stack is drifting.
337
+
338
+ ---
339
+
340
+ # Adoption Philosophy
341
+
342
+ This skill should make the stack **easy to adopt**.
343
+
344
+ Preferred adoption characteristics:
345
+
346
+ - quick install
347
+ - one obvious command path
348
+ - one obvious config location
349
+ - one obvious local enforcement layer
350
+ - one obvious CI replay
351
+
352
+ For existing repos, favor changes that are:
353
+
354
+ - understandable
355
+ - reviewable
356
+ - low-drama
357
+ - easy to roll out incrementally
358
+
359
+ Do not require perfection before adoption begins.
360
+
361
+ ---
362
+
363
+ # Verification Expectations
364
+
365
+ When proposing or applying this stack, end with exact commands such as:
366
+
367
+ ```bash
368
+ ruff check .
369
+ ruff format --check .
370
+ pre-commit run --all-files
371
+ ```
372
+
373
+ Include Markdown lint commands if configured, plus test commands if relevant.
374
+
375
+ ---
376
+
377
+ # Completion Checklist
378
+
379
+ - [ ] Existing tooling was inspected before generating config
380
+ - [ ] Redundant tools (Black, isort, Flake8, autoflake) were called out for removal
381
+ - [ ] Config is centralized in `pyproject.toml` where possible
382
+ - [ ] `.pre-commit-config.yaml` uses the canonical structure as the base
383
+ - [ ] Pre-commit hooks are limited to high-signal checks
384
+ - [ ] CI steps mirror the local contract (no CI-only quality checks)
385
+ - [ ] Response ends with exact verification commands
386
+
387
+ ---
388
+
389
+ # Outcome
390
+
391
+ Applying this skill should produce a repo with:
392
+
393
+ - one clear Python quality toolchain
394
+ - one clear local enforcement path
395
+ - one clear CI quality contract
396
+ - less overlapping tooling
397
+ - better documentation hygiene
398
+ - lower maintenance overhead