agentleFS
paulnsorensenpaulnsorensen/skillz-that-grillz/.agents/skills/python-authoring/SKILL.md

python-authoring

Skill1 starsChanged 19 days agoMITView on GitHub

Write, edit, refactor, or review Python as concise, stdlib-first, fully typed code that validates input at the boundary and passes basedpyright. Use when the user changes Python source, scripts, CLIs, validators, or tests, or says "make this more Pythonic", "clean up this Python", "de-slop this Python", "use a dataclass here", "fix the basedpyright errors", or invokes /python-authoring. Do NOT use for Bash scripts (/bash-shortening), task-runner recipes (/justfile), dependency-version conflicts (/version-doctor), or bug and security review (/age).

1 other project uses a version of this, 1 of them edited.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 1

    1. paulnsorensen/easy-cheese★ 1951% same

    Wrote their own version · 0

    None found.

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository5 other files it gives its agents.

The file

Show its rules and text

We split this skill into the rules it gives an agent

34 rules. About 0 are common, 20 are distinctive, and 14 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈20

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 14

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    Read the root configuration (pyproject.toml, lockfile, task runner), the target exports, immediate callers, and nearby conventions.

    line 25
  2. Distinctive:

    Keep every changed line traceable to the request.

    line 26
  3. Distinctive:

    Put code in the owning package and preserve existing module and package boundaries.

    line 27
  4. Distinctive:

    Remove only slop introduced by the change and code that the change orphaned.

    line 30
  5. Very specific:

    Run targeted tests, regenerate generated artifacts, then run just build.

    line 31
  6. Distinctive:

    Treat the standard library as the default dependency budget.

    line 38
  7. Distinctive:

    Keep test-only and tooling-only dependencies out of runtime modules.

    line 40
  8. Very specific:

    Prefer argparse, json, pathlib, tempfile, shutil, zipfile, collections, itertools, and contextlib over hand-written equivalents.

    line 41
  9. Very specific:

    Use TypedDict only when a mapping must remain a mapping.

    line 47
  10. Very specific:

    Use Enum or Literal for closed value sets and Protocol for structural interfaces that have multiple real consumers.

    line 48
  11. Distinctive:

    Do not pass raw structured dictionaries beyond the parsing boundary when a named record makes the contract clearer.

    line 50
  12. Distinctive:

    Do not import another package's private internals.

    line 54
  13. Distinctive:

    Keep cross-module orchestration in the owning workflow seam, not a leaf helper.

    line 56
  14. Distinctive:

    Never hand-edit generated artifacts.

    line 57
  15. Very specific:

    Keep CLI modules thin: accept argv, return an integer status, print diagnostics to stderr, and propagate failure through a nonzero exit.

    line 58
  16. Distinctive:

    Keep validators and linters read-only.

    line 59
  17. Very specific:

    Use match for genuine shape-based dispatch.

    line 63
  18. Distinctive:

    Use a handler mapping for stable command-to-function dispatch.

    line 64
  19. Distinctive:

    Use an assignment expression only when it removes a repeated computation or clarifies a loop condition.

    line 65
  20. Very specific:

    Use any, all, comprehensions, and generator expressions for pure collection queries or transformations.

    line 66
  21. Distinctive:

    Prefer generators when the result is consumed once.

    line 67
  22. Very specific:

    Use enumerate, direct iteration, f-strings, context managers, and pathlib instead of manual indexing, string assembly, cleanup, or path …

    line 68
  23. Distinctive:

    Keep new top-level functions at 40 lines or fewer unless one contiguous algorithm is clearer than an artificial split.

    line 70
  24. Distinctive:

    Prefer one clear expression to verbose scaffolding, but split dense expressions when intermediate names explain intent.

    line 71
  25. Distinctive:

    Delete narration comments and docstrings that restate the code.

    line 75
  26. Distinctive:

    Remove abstractions with one concrete consumer unless the current task requires the seam.

    line 76
  27. Very specific:

    Run just build after a Python change.

    line 83
  28. Very specific:

    Keep typeCheckingMode = "recommended" and failOnWarnings = true.

    line 85
  29. Very specific:

    Use --outputjson when a tool needs machine-readable diagnostics.

    line 89
  30. Distinctive:

    Treat findings as potential dead code.

    line 96
  31. Distinctive:

    Test observable behavior and the reason it matters.

    line 103
  32. Very specific:

    Keep filesystem tests inside tmp_path or an equivalent temporary directory.

    line 104
  33. Very specific:

    Run the most focused affected tests first, then run just build as the canonical full gate.

    line 105
  34. Distinctive:

    No silent failures, speculative abstractions, narration comments, unnecessary local annotations, or unrelated cleanup remain.

    line 116

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Authoring Python

Produce the smallest readable Python change that satisfies the request and matches the project.

This is a repository-local skill for skillz-that-grillz. It lives under .agents/skills/python-authoring/, with a .claude/skills/ symlink for Claude Code. metadata.internal: true hides it from npx skills add, and gh skill install skips hidden directories. Do not move it into the published skills/ tree.

Work in this order

  1. Read the root configuration (pyproject.toml, lockfile, task runner), the target exports, immediate callers, and nearby conventions.
  2. Keep every changed line traceable to the request. Do not invent orchestration, compatibility layers, abstractions, dependencies, or future flexibility.
  3. Put code in the owning package and preserve existing module and package boundaries.
  4. Validate untrusted input once at the boundary, then work with typed trusted data.
  5. Choose the clearest succinct Python construct; do not compress code until it becomes harder to read.
  6. Remove only slop introduced by the change and code that the change orphaned.
  7. Run targeted tests, regenerate generated artifacts, then run just build. It includes root basedpyright and Vulture checks.

Done when every item in the completion check holds.

Keep runtime code stdlib-first

  • Target the Python version the project declares in requires-python. Use its language and typing features directly; do not add compatibility code for older versions.
  • Treat the standard library as the default dependency budget. Add a third-party runtime dependency only when the project already uses it or the user approves it, and declare it where the project declares dependencies.
  • Reuse existing parsing and I/O boundaries instead of importing a second library for the same job.
  • Keep test-only and tooling-only dependencies out of runtime modules.
  • Prefer argparse, json, pathlib, tempfile, shutil, zipfile, collections, itertools, and contextlib over hand-written equivalents.

Model and validate data explicitly

  • Parse untrusted text with the appropriate stdlib parser, require the expected container shape, check required keys and value types, and raise a specific error at the boundary.
  • Convert validated mappings into frozen dataclasses or domain value types when named fields and invariants make the contract clearer.
  • Use TypedDict only when a mapping must remain a mapping. It documents a static shape; it does not validate runtime input.
  • Use Enum or Literal for closed value sets and Protocol for structural interfaces that have multiple real consumers.
  • Fully annotate function and public-method boundaries. Omit obvious local annotations when inference is clear.
  • Do not pass raw structured dictionaries beyond the parsing boundary when a named record makes the contract clearer.

Preserve module boundaries

  • Do not import another package's private internals. Consume its public interface.
  • Move code to a shared module only when multiple existing consumers need the same behavior.
  • Keep cross-module orchestration in the owning workflow seam, not a leaf helper. Avoid reverse dependencies and import cycles.
  • Never hand-edit generated artifacts. Change their sources and run the project's generator.
  • Keep CLI modules thin: accept argv, return an integer status, print diagnostics to stderr, and propagate failure through a nonzero exit.
  • Keep validators and linters read-only. They inspect and report; they do not mutate the workspace.

Prefer succinct, readable Python

  • Use match for genuine shape-based dispatch; keep a simple if for a binary decision.
  • Use a handler mapping for stable command-to-function dispatch; do not create a registry for one or two branches.
  • Use an assignment expression only when it removes a repeated computation or clarifies a loop condition.
  • Use any, all, comprehensions, and generator expressions for pure collection queries or transformations. Keep a loop when it carries state, side effects, or clearer early exits.
  • Prefer generators when the result is consumed once.
  • Use enumerate, direct iteration, f-strings, context managers, and pathlib instead of manual indexing, string assembly, cleanup, or path manipulation.
  • Ignore only named, intentional failures. Never use a bare except, swallow Exception, return an empty default on failure, or use contextlib.suppress(Exception).
  • Keep new top-level functions at 40 lines or fewer unless one contiguous algorithm is clearer than an artificial split.
  • Prefer one clear expression to verbose scaffolding, but split dense expressions when intermediate names explain intent.

De-slop before finishing

  • Delete narration comments and docstrings that restate the code. Keep non-obvious rationale and public API documentation.
  • Remove abstractions with one concrete consumer unless the current task requires the seam.
  • Name values after domain concepts, not containers or implementation types.
  • Consolidate repetitive tests by behavior; do not add shallow input-variation tests.
  • Fix the underlying lint issue instead of adding a suppression.

Type-check with basedpyright

  • Run just build after a Python change. Its root basedpyright check covers authored Python in .github/scripts, packages, and skills.
  • Root configuration in pyproject.toml uses Python 3.11, the root .venv, and execution environments for local packages.
  • Keep typeCheckingMode = "recommended" and failOnWarnings = true. Fix all errors and warnings without a baseline.
  • Preserve the independent fromargs type check and its package configuration.
  • basedpyright is stricter than stock pyright. Assign deliberately ignored call results to _ (reportUnusedCallResult), collapse implicit string concatenations, and cast untrusted boundary reads to their validated type.
  • Fix the type at its source. When a suppression is genuinely unavoidable, use a rule-scoped # pyright: ignore[ruleName], never a bare # type: ignore or a file-wide switch. reportIgnoreCommentWithoutRule flags unscoped ignores.
  • Use --outputjson when a tool needs machine-readable diagnostics. In GitHub Actions the CLI detects CI and emits inline PR annotations with no extra flags.
  • Read exit codes precisely: 0 no errors, 1 errors reported, 2 fatal internal error, 3 unreadable config, 4 bad CLI arguments. Warnings exit 1 only when failOnWarnings is on; when it is off, read the warning count in the output, because exit 0 does not prove zero warnings. Treat 2–4 as tooling breakage to fix or report, never as type findings.
  • Pin basedpyright to an exact version for reproducible results.

Check unused code with Vulture

  • just build runs Vulture at 60% minimum confidence across authored Python, including tests and examples.
  • Treat findings as potential dead code. Trace dynamic callers before deletion.
  • Exempt only proven framework callbacks with narrow decorator or name rules. Do not add a broad whitelist or a baseline.
  • The repo gate (.github/scripts/check_dead_code.py) exempts the fields of all module-level TypedDict classes, including subclasses. This is a structural rule, not a name list. Unpack and TypedDict keys are read by string, so Vulture cannot see the reads. Function-local TypedDict classes are not exempt. Do not add global name ignores for field names.
  • Vulture exit 3 means unused code was found. Resolve each real finding before completion.

Test and finish

  • Test observable behavior and the reason it matters; do not add assertions that can pass when the implementation is broken.
  • Keep filesystem tests inside tmp_path or an equivalent temporary directory. Do not depend on user paths, repository-external state, network access, or auto-loaded pytest plugins.
  • Run the most focused affected tests first, then run just build as the canonical full gate.

Completion check

Confirm:

  • Runtime imports obey the stdlib-first dependency policy.
  • Boundary input is validated once and converted into an appropriate trusted representation.
  • Code lives in the owning module or a justified shared module.
  • Generated artifacts match their sources when applicable.
  • CLI and validator failures remain loud, read-only validators remain read-only, and tests are hermetic.
  • No silent failures, speculative abstractions, narration comments, unnecessary local annotations, or unrelated cleanup remain.
  • Root basedpyright reports zero errors and warnings. Vulture reports no unused code at 60% confidence.
  • A fresh just build run passed.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.