agentleFS
MediaPluralMediaPlural/agent-proven/skills/verbose-code-trim/SKILL.md

verbose-code-trim

Skill1 starsChanged 12 days agoMITView on GitHub

Cut verbosity without losing behavior — same, shorter.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before reviews: reviewers spend budget on verbosity instead of substance

    line 26
  2. Very specific:

    Don't use for: hot paths without a measurement (see measure-first — "shorter is faster" is a claim), public API signatures, …

    line 30
  3. Distinctive:

    Trim one target at a time: After each: the same tests, the same lint.

    line 55
  4. Distinctive:

    If a trim needs a behavioral argument ("this can't raise because..."), write that proof as a comment or a test — the proof is the trim's …

    line 56

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

Verbose Code Trim

Cut bloat: verbose constructs, redundant ceremony, over-guarded logic, boilerplate a language idiom already covers. Every trim must preserve behavior exactly — the contract is "shorter says the same," verified by tests and by diff-reading. This is not about cleverness; compressed code must stay the MOST readable option, not the least.

When to Use

  • Agent-generated batches: models pad code with ceremony (over-explicit checks, re-stated invariants, wrapper noise)
  • Before reviews: reviewers spend budget on verbosity instead of substance
  • Post-migration: old-style idioms a newer language version makes redundant
  • "This function is 60 lines and I can't find the logic"

Don't use for: hot paths without a measurement (see measure-first — "shorter is faster" is a claim), public API signatures, security-critical validation (explicit > terse, always), or code that's long because the domain is long.

The Trim Targets

TargetVerbose formTrimmed form
Manual loops5-line accumulate loopcomprehension / sum / itertools
Re-stated invariantsre-checking a precondition already guaranteed upstreamtrust the contract, delete the re-check (prove it)
Over-exceptiontry/except around code that can't raisedelete the wrapper (prove it can't)
Boolean ceremonyif x: return True else: return Falsereturn x
Chain-of-elifelif ladder mapping valuesdict dispatch / match
Wrapper passthroughfunction that forwards args unchangedcall directly (see dead-code-sweep)
Overbuilt classesclass with state used oncefunction
Comment-code echocomment restating the next linedelete the comment (prose-hygiene)
Defensive defaultsdefault parameter never exerciseddelete or assert

Procedure

  1. Pick a unit (function or module) and establish the green baseline: tests passing on it, lint clean.
  2. Mark the logic lines — the lines that DO the thing. Everything else is candidate ceremony.
  3. Trim one target at a time. After each: the same tests, the same lint. If a trim needs a behavioral argument ("this can't raise because..."), write that proof as a comment or a test — the proof is the trim's license.
  4. Re-read the result. The trimmed code must be MORE readable, not denser. If you have to unpack it mentally, un-trim — the target was wrong, not the code.
  5. Diff-verify: the final diff shows no logic-line changes — only ceremony removal. (git diff should read like subtraction.)

Completion criterion: tests green before/after; lint clean; the diff is pure subtraction or idiom replacement; a cold reader picks the trimmed version.

Pitfalls

  • Cleverness creep: comprehensions nested 3 deep "save lines" by spending readability. Rule: if the trim needs a comment to explain, it isn't a trim.
  • Silent behavior change: deleting "redundant" checks that weren't (order-of-evaluation, side effects in the removed expression). The baseline gate catches these — never skip it for "obviously safe" trims.
  • Trimming the explanation with the bloat: a long function may be long because it carries WHY-comments. Those move to prose-hygiene for tightening, not deletion.
  • Public contracts: signatures, exception surface, and return types are behavior. Trims that change call sites aren't trims — they're refactors.

Verification

Runnable check: the unit's tests before and after, plus a line-count delta:

bash <repo>/scripts/run_tests.sh <unit-tests> -- -q   # green, both sides
git diff --stat                                       # net subtraction

Expected: identical pass set both sides; net negative diff (or neutral where a comment moved); no logic-line additions in the diff.

Evidence to capture: both test outputs, the diff, and the line-count delta (before → after).

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.