agentleFS
ccomkhjccomkhj/skills/simplify-python/SKILL.md

simplify-python

Skill10 starsChanged 19 days agoMITView on GitHub

Simplify recently written or edited Python for readability without changing behavior. Use for cleanup, idiomatic rewrites, flatter control flow, and trimming redundant code or docstrings. Not for performance tuning or behavior-changing redesign.

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. About 0 are common, 6 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use guard clauses for preconditions and continue for rejected loop items.

    line 18
  2. Distinctive:

    Remove dead code, redundant state, and intermediates that add no meaning.

    line 19
  3. Distinctive:

    Keep related calculations, explanations, and uses close without changing evaluation order, timing, lifetime, or scope.

    line 20
  4. Distinctive:

    Don't Repeat Yourself (DRY): deduplicate shared knowledge that changes together, not merely similar-looking code.

    line 23
  5. Distinctive:

    Use these when clearer and equivalent for the actual code.

    line 29
  6. Very specific:

    Prefer enumerate, zip, and unpacking over manual indexing and temporary swaps.

    line 31
  7. Very specific:

    Use comprehensions for simple collection building.

    line 32
  8. Very specific:

    Prefer named builtins and standard-library tools (sum, Counter, defaultdict, pathlib) when they remove bookkeeping.

    line 33
  9. Very specific:

    Consider f-strings for formatting.

    line 34
  10. Very specific:

    Consider dataclass for plain data containers after checking generated methods against the existing contract.

    line 35
  11. Distinctive:

    Use walrus expressions, structural matching, and iterator chains selectively.

    line 36
  12. Very specific:

    Do not add missing docstrings during cleanup unless asked.

    line 42
  13. Distinctive:

    Run relevant existing tests and applicable lint/type checks, plus required repository checks.

    line 48

≈ “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

simplify-python

Optimize for reader effort, not line count. Work on recently modified code unless asked otherwise; follow repository conventions and the supported Python version.

Contract

Preserve return values, exception types and timing, side effects and their order, and observable laziness/short-circuiting. Base equivalence on actual types, callers, and contracts; skip unresolved uncertainty. A zero-change pass is valid.

Readability rules

Tiebreaker (Reversibility): when two forms read equally well, prefer the one that is easier to change; cleanup should not lock in choices that are currently cheap to revisit.

  • Use guard clauses for preconditions and continue for rejected loop items. Keep peer branches together when that reads better.
  • Remove dead code, redundant state, and intermediates that add no meaning. Keep explaining variables and names that express domain meaning or units.
  • Keep related calculations, explanations, and uses close without changing evaluation order, timing, lifetime, or scope.
  • Extract a helper when its name exposes a meaningful step and saves more effort than the indirection costs. Avoid helpers requiring tangled state or vague names.
  • Inline thin, single-use helpers only when they provide no domain meaning, public interface, test seam, or extension point.
  • Don't Repeat Yourself (DRY): deduplicate shared knowledge that changes together, not merely similar-looking code. Counts and nesting depth are review signals, not targets.
  • Orthogonality: do not couple independent parts through a shared helper, flag, or state, so a change to one does not ripple into the others. When DRY and Orthogonality conflict, keep unrelated code separate.
  • Simplify boolean expressions only when easier to read; do not mechanically push negations inward.

Python idioms

Use these when clearer and equivalent for the actual code. Read the relevant entries in Python gotchas when a candidate touches iteration, comparisons, cleanup, mappings, or implicit behavior.

  • Prefer enumerate, zip, and unpacking over manual indexing and temporary swaps.
  • Use comprehensions for simple collection building; keep explicit loops for complex control flow. Consider any/all for short-circuit searches.
  • Prefer named builtins and standard-library tools (sum, Counter, defaultdict, pathlib) when they remove bookkeeping.
  • Consider f-strings for formatting; retain lazy logging arguments such as logger.info("got %s", x).
  • Consider dataclass for plain data containers after checking generated methods against the existing contract.
  • Use walrus expressions, structural matching, and iterator chains selectively; saving lines alone is not a reason.

Docstrings

Trim prose that repeats the signature or implementation. Keep contracts, units, ranges, exceptions, mutation, and rationale. Use a short imperative summary; add detail only when useful to callers. Follow repository formatting conventions.

Do not add missing docstrings during cleanup unless asked. Preserve doctests and any runtime use of __doc__.

Workflow

  1. Inspect the changed region and relevant callers; choose useful simplifications.
  2. Batch related tidyings and keep unrelated changes separable.
  3. Run relevant existing tests and applicable lint/type checks, plus required repository checks. Broaden for scope, failures, or uncertainty; green tests alone do not establish equivalence.
  4. Report changes and verification, including material baseline failures or limitations. Explain non-obvious equivalence and mention skipped candidates only when material to the result.

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.