agentleFS
LeahyCCLeahyCC/claude-skills/skills/code-readability/SKILL.md

code-readability

Skill3 starsChanged 8 months agoMITView on GitHub

Makes code readable at the point of use: no floating (magic) numbers or strings without a name or a unit-and-why note nearby, names that carry units and meaning, small functions, shallow nesting, honest comments, and no dead code. Balanced by default: 0, 1, -1, named object properties, tests, and self-evident math are exempt. Use when writing or reviewing code, naming a constant, adding a timeout, retry, threshold, limit, or percentage, or when a reviewer asks "what is this number / what does this do". Not for type safety (typescript-safety), UI text (ux-copy), or performance (spa-performance, react-performance).

3 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

4 rules. 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 4

    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:

    Read the change for a reader who arrives cold.

    line 27
  2. Distinctive:

    Read the resource for that smell in the table below.

    line 28
  3. Distinctive:

    Do not rename or restructure unrelated code in the same change.

    line 30
  4. Distinctive:

    If the project has linting, run it.

    line 31

“Common” is measured: kept by at least 6 in 10 of the 3 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

Code readability

Code is read at the point of use, by someone who does not have the author's head. A value, name, or shape that needs the author's memory to decode is a readability bug, even when it runs correctly.

Name it, or document it where it is used. Prefer naming. A named constant explains itself on every use and can only change in one place. A comment is the fallback for code that cannot hold a name (a config table, a protocol layout), and it must give the unit and the reason, not restate the literal.

Balanced, not strict. This skill flags meaning a reader cannot recover from context. It does not flag 0, 1, -1, a literal already labelled by the property or argument it sits in ({ timeoutMs: 5000 }), test data, or math whose meaning the formula itself carries (width / 2 for a centre). Chasing those teaches people to ignore the rule.

Source checks and dates: SOURCES.md.

Procedure

  1. Read the change for a reader who arrives cold. Mark every place you had to scroll, guess, or already know something to understand it.
  2. Read the resource for that smell in the table below.
  3. Fix by preference, in order: rename, extract a named constant or helper, restructure (guard clause, lookup table), then — only if none of those fit — a unit-and-why comment at the use site.
  4. Do not rename or restructure unrelated code in the same change. Readability fixes ride along only where the change already touches.
  5. If the project has linting, run it. Report findings as Must fix / Should fix / Leave, with the rule name. Never report a smell you did not actually see in the code.
a literal a reader can't decode ──> magic-numbers.md, magic-strings.md
a name that hides unit or meaning ──> naming.md
a function you must hold in your head ──> functions.md, nesting-and-conditionals.md
a comment that lies, repeats, or apologises ──> comments-and-dead-code.md
want a machine to catch it ──> linting.md

Where to read

TaskResource
Floating / magic numbers: timeouts, retries, thresholds, sizes, rates, the performance.now() deadlinemagic-numbers.md
Magic strings, status literals, boolean flag arguments, stringly-typed valuesmagic-strings.md
Names: units in names, abbreviations, boolean names, names that lie, scope and lengthnaming.md
Function size, doing one thing, abstraction levels, arguments, early returns as structurefunctions.md
Nesting depth, guard clauses, complex conditions, negations, nested ternariesnesting-and-conditionals.md
Comments that earn their place, comments that lie or repeat code, commented-out and dead code, TODOscomments-and-dead-code.md
ESLint no-magic-numbers and friends, tuned balanced, as warnings, adopted by directorylinting.md

The smells that cost the most time

SymptomUsual causeRead
performance.now() + 180_000 — 180 thousand what?A duration with no unit and no namemagic-numbers.md
setTimeout(fn, 86400000) runs daily, nobody dares change itMilliseconds computed in someone's head oncemagic-numbers.md
if (status === 3) in three files, meaning driftsA status code never became a named constant or unionmagic-strings.md
render(true, false, true) at the call siteBoolean flag arguments; the booleans carry no meaningmagic-strings.md
const d = 5000 then setTimeout(fn, d)Abbreviation dropped the unit the reader needednaming.md
A 200-line function where the bug hides in the middleSetup, logic, and formatting at mixed abstraction levelsfunctions.md
Code indented six levels, happy path at the bottom rightMissing guard clauses; errors handled by nestingnesting-and-conditionals.md
if (!isNotEmpty(x)) needs three readsStacked negations; the name or the condition should flipnesting-and-conditionals.md
A comment says "returns null on error"; the code throwsThe comment was true once and never updatedcomments-and-dead-code.md
80 lines of commented-out code "just in case"Git already keeps it; the block only confuses searchcomments-and-dead-code.md

Review checklist

  • No bare literal carries time, retries, thresholds, limits, money, rates, or sizes without a name or a unit-and-why note at the use site
  • Named constants are named for meaning and unit (SESSION_TIMEOUT_MS), not for their value (TIMEOUT_180000)
  • 0, 1, -1, labelled properties, and self-evident math were left alone
  • Strings compared in logic are named constants, enums, or union members — never retyped literals
  • No call passes bare booleans whose meaning is invisible at the call site
  • Names carry their unit and do not lie about type, side effects, or contents
  • Each function does one thing at one level of abstraction; length and nesting read as smell, not law
  • Conditions read in the positive where they can; no nested ternaries in prose-like code
  • Every comment adds why, a constraint, or a warning — none restate the code, none are stale
  • No commented-out code, no unreachable branches, no TODO without an owner or issue

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.