agentleFS
paulnsorensenpaulnsorensen/easy-cheese/.agents/skills/python-authoring/SKILL.md

python-authoring

Skill19 starsChanged 27 days agoMITView on GitHub

Write, edit, refactor, or review Python in easy-cheese with concise stdlib-first code, Python 3.12, wedge .pyz packaging, and repository test and validation conventions. Use for Python changes under src/, scripts/, .github/scripts/, or tests/, especially when the user asks for Pythonic, succinct, de-slopped, dataclass-based, CLI, validator, or bundled-helper code.

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

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

35 rules. About 0 are common, 18 are distinctive, and 17 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈18

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 17

    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. Distinctive:

    Read the root configuration, owning skill, target exports, immediate callers, and nearby conventions.

    line 14
  2. Distinctive:

    Keep every changed line traceable to the request.

    line 15
  3. Distinctive:

    Put code in the owning package and preserve the bundle boundary.

    line 16
  4. Distinctive:

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

    line 19
  5. Very specific:

    Treat the standard library as the default dependency budget for bundled helpers under src/.

    line 25
  6. Distinctive:

    Treat configured third-party imports as surface-specific exceptions: PyYAML for existing validators, docs tooling, and manifest/test paths.

    line 27
  7. Very specific:

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

    line 28
  8. Very specific:

    Use TypedDict only when a mapping must remain a mapping.

    line 34
  9. Very specific:

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

    line 35
  10. Distinctive:

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

    line 37
  11. Very specific:

    Keep skill runtime under src/easy_cheese/skills/<skill_name>/ and declare its CLI surface in commands.py.

    line 41
  12. Distinctive:

    Do not import another skill's internals.

    line 43
  13. Distinctive:

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

    line 44
  14. Very specific:

    Never edit skills/<skill>/scripts/<skill>.pyz by hand.

    line 45
  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 46
  16. Very specific:

    Keep .github/scripts/ validators read-only.

    line 47
  17. Very specific:

    Use match for genuine shape-based dispatch.

    line 51
  18. Distinctive:

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

    line 52
  19. Distinctive:

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

    line 53
  20. Very specific:

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

    line 54
  21. Distinctive:

    Prefer generators when the result is consumed once.

    line 55
  22. Very specific:

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

    line 56
  23. Distinctive:

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

    line 58
  24. Distinctive:

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

    line 59
  25. Distinctive:

    Delete narration comments and docstrings that restate the code.

    line 63
  26. Distinctive:

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

    line 64
  27. Very specific:

    Run basedpyright <changed .py files> (fall back to uvx basedpyright if the binary is absent) before finishing.

    line 71
  28. Very specific:

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

    line 77
  29. Distinctive:

    Read exit codes precisely: 0 clean, 1 diagnostics reported, 2 fatal internal error, 3 unreadable config, 4 bad CLI arguments.

    line 78
  30. Distinctive:

    Test observable behavior and the reason it matters.

    line 83
  31. Very specific:

    Keep filesystem tests inside tmp_path or an equivalent temporary directory.

    line 84
  32. Very specific:

    Run the most focused affected tests first.

    line 85
  33. Very specific:

    After archive inputs change, run just wedge-build, then just wedge-check before focused tests execute an archive.

    line 86
  34. Very specific:

    Run just check as the final project gate.

    line 87
  35. Distinctive:

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

    line 98

≈ “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 easy-cheese.

This is a repository-local skill. Keep it under .agents/skills/python-authoring/; do not mirror it into the published skills/ tree or add agents/openai.yaml. Renaming this directory requires updating the matching !.agents/skills/<dir>/ line in .gitignore — that path list is an allowlist, so a renamed dir without its own line is silently untracked.

Work in this order

  1. Read the root configuration, owning skill, 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 the bundle boundary.
  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. Type-check changed files with basedpyright, run targeted tests, rebuild affected bundles, then run just check.

Keep runtime code stdlib-first

  • Target Python 3.12. Use its language and typing features directly; do not add compatibility code for older versions.
  • Treat the standard library as the default dependency budget for bundled helpers under src/. Any third-party runtime dependency must be pure Python and admitted to requirements/runtime.txt; bundle builds resolve internal and external hashes into an ephemeral requirements file.
  • Reuse the existing JSON-first, optional-YAML manifest boundary instead of importing PyYAML into new bundled modules.
  • Treat configured third-party imports as surface-specific exceptions: PyYAML for existing validators, docs tooling, and manifest/test paths; pytest for tests. A new dependency requires an explicit package and CI decision.
  • 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 skill package boundaries

  • Keep skill runtime under src/easy_cheese/skills/<skill_name>/ and declare its CLI surface in commands.py.
  • Move code to src/easy_cheese/shared/ only when multiple existing skills need the same behavior; bundle it into each owning archive.
  • Do not import another skill's internals. Each archive carries its complete pure-Python runtime closure.
  • Keep cross-skill orchestration in the owning workflow seam, not a leaf helper. Communicate through public or persisted contracts to avoid reverse dependencies and cycles.
  • Never edit skills/<skill>/scripts/<skill>.pyz by hand. Run just wedge-build after changing archive inputs and just wedge-check to verify committed archives.
  • Keep CLI modules thin: accept argv, return an integer status, print diagnostics to stderr, and propagate failure through a nonzero exit.
  • Keep .github/scripts/ validators 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 basedpyright <changed .py files> (fall back to uvx basedpyright if the binary is absent) before finishing. Changed files must report zero errors and warnings.
  • Repo config lives in [tool.basedpyright] in pyproject.toml: include paths, pythonVersion = "3.12", and an execution environment pinning src/easy_cheese_schemas to 3.11 to honor the published wheel's requires-python >=3.11. typeCheckingMode is deliberately unset — basedpyright defaults to recommended, which enables every rule with an error/warning split and failOnWarnings, so a full run fails on warnings too.
  • The whole repo is basedpyright-clean and just typecheck (wired into just check, just ci, and the validate workflow) enforces zero errors and warnings. Any diagnostic your change surfaces is yours to fix before finishing — there is no baseline and no pre-existing backlog to defer to. Imports resolve against .venv-typing; just typecheck-install (re)creates it from requirements/typing.txt.
  • basedpyright is stricter than stock pyright; its extra rules are binding here: assign deliberately ignored call results to _ (reportUnusedCallResult), collapse implicit string concatenations, and cast untrusted boundary reads to their validated type.
  • Load build-only modules that are excluded from wheels with importlib.import_module plus cast-typed getattr, not static imports the checker cannot resolve.
  • Fix the type at its source. When a suppression is genuinely unavoidable, use 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 clean, 1 diagnostics reported, 2 fatal internal error, 3 unreadable config, 4 bad CLI arguments. Treat 2–4 as tooling breakage to fix or report, never as type findings.
  • The binary is mise-managed and pinned to an exact version (upstream recommends exact pinning for reproducibility); the pyright and pyright-langserver shims resolve to basedpyright.

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. Focused pytest and browser commands execute committed skills/<skill>/scripts/<skill>.pyz archives without rebuilding them. Keep repository imports unavailable when testing archive isolation.
  • After archive inputs change, run just wedge-build, then just wedge-check before focused tests execute an archive. Run just update-generated when generated runtime sources change.
  • Run just check as the final project gate.

Completion check

Confirm:

  • Runtime imports obey the stdlib-first, surface-specific dependency policy.
  • Boundary input is validated once and converted into an appropriate trusted representation.
  • Code lives in the owning skill source or a justified shared module.
  • Command registration, generated runtime sources, and committed archives match their inputs when applicable (scripts/runtime_gates.py, just wedge-check).
  • 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.
  • Changed Python files pass basedpyright with zero errors and warnings.
  • A fresh just check 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.