agentleFS
sammasaksammasak/claude-code-skills/skills/lean-code/SKILL.md

lean-code

Skill1 starsChanged 28 days agoMITView on GitHub

Use when about to add a comment, doc block, error variant, config option, helper, or test beyond what the change strictly needs — in any code writing or review. Not for Rust-specific lints, crates, or toolchain choices — rust-engineering owns those.

8 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When touching code, remove what the change makes dead: unused impls, stale helpers, tests made redundant by better ones (replace, don't …

    line 26

“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “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

Lean Code

Code is cost; the behaviour is the asset. The best diff is the smallest one that solves the whole problem, and the best line is the one that no longer needs to exist.

Comments and docs

A comment earns its line only by stating what the code cannot: a constraint, an invariant, a consequence ("X breaks when…"), or a non-obvious why. Name things well enough that narration never becomes necessary.

State each fact exactly once, in the one place its reader looks. A public function's contract lives in its doc comment; the module doc then only routes ("parsing for duration strings — see parse_duration"), it does not restate the grammar. A doc line above an attribute or signature that re-says it (/// The input was empty. above #[error("duration string is empty")] Empty) is deleted on sight. Section banners (// ─── Config ───) are replaced by file/module structure.

Surface sized to real callers

Build for the callers that exist today:

  • An error type gets as many variants as callers branch on. A CLI that prints the message needs one well-worded message, not six variants carrying owned Strings.
  • A config option, trait, or generic parameter is added when the second concrete need arrives, never for a hypothetical one (see the deep-modules skill for seam discipline).
  • Deliver the design that fits now and stop; put future ideas in the commit message or nowhere, not as "we could later add a Jitter trait" notes in the code.

Deletion is a feature

When touching code, remove what the change makes dead: unused impls, stale helpers, tests made redundant by better ones (replace, don't layer). Weight cleanup toward code that changed recently (git history), leave stable corners alone.

Calibrate ceremony to the ask

Match effort to what was requested and to the environment: asked for code in a reply, write the code — a full crate scaffold, toolchain download, and pedantic-lint pass is for changes landing in a real repo. On these memory-constrained hosts, heavy verification runs once and sequentially, at the layer that owns it (git hooks / sdlc gates), not re-improvised per edit.

Red flags

  • The same contract explained in the module doc, the type doc, and the function doc.
  • A comment or doc line that would survive translation into the identifier under it.
  • Error variants, fields, or options nothing matches on or sets.
  • A "for future flexibility" abstraction with one user.
  • More lines of scaffolding and process than of requested change.

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.