agentleFS
smileynetsmileynet/code-spice/skills/code-readability/SKILL.md

code-readability

Skill0 starsChanged 9 months agoMITView on GitHub

Code readability patterns covering comments, function decomposition, nesting, naming conventions, and code structure. Use when evaluating whether code is easy to understand, deciding when and how to write comments, decomposing functions, reducing nesting depth, improving code structure, or reviewing code for readability. Covers comment strategy, function length, abstraction level mixing, nesting reduction, anonymous function readability, and making bad code visually obvious.

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

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

  • 0

    Common

    Most of the 3 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:

    Before committing code, verify:

    line 68

“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

Quick Reference

The Readability Checklist

DimensionQuestionIf No...
NamesCan I understand what this does from the names alone?Rename variables, functions, classes
CommentsDo comments explain why, never what?Delete "what" comments; improve names instead
Function lengthDoes each function do one thing at one abstraction level?Extract methods
NestingIs nesting 2 levels or fewer?Use early returns, extract helper functions
ConsistencyDoes this code follow the same style as surrounding code?Adopt the project's conventions
Surprise factorWould another engineer expect this behavior from reading the signature?Rename or restructure to match expectations

The Comment Decision Table

SituationActionExample
Code does something non-obviousWrite a why comment// Retry limit set to 3 per SLA with payments team
Name doesn't convey intentFix the name, don't add a commentRename d to elapsedDays
Complex algorithm or formulaComment the approach, not the steps// Uses Dijkstra's — graph is sparse
Workaround for a bug or limitationComment what and why// Safari doesn't support ResizeObserver in iframes (WebKit #219765)
Legal or licensing requirementKeep the comment// SPDX-License-Identifier: MIT
Commented-out codeDelete itVersion control remembers
TODO or FIXMEInclude a ticket reference// TODO(CS-142): Replace with batch API
Section header in a long functionExtract a function insteadThe function name becomes the "header"

Documentation Value Hierarchy

LevelReachMaintenance CostReliability
Good namesEvery call siteZero (name is the code)Always current
Type signaturesEvery caller, IDELow (compiler verifies)Enforced
CommentsReaders of this file onlyMedium (can drift)Trust but verify
External docsThose who find themHigh (often forgotten)Frequently stale

Decision Tables

"Should I write a comment?"

The comment would explain...Write it?Instead...
What the code doesNoImprove the name or extract a function
Why the code does it this wayYes—
What a variable holdsNoRename the variable
A workaround or hackYesInclude link to issue/ticket
The algorithm being usedYes (if non-obvious)—
A section of a long functionNoExtract the section into a named function

"Is this function too long?"

SignalVerdict
Can describe in one sentence without "and"Length is fine
Has blank-line-separated sectionsExtract sections
Mixes abstraction levelsSplit by level
Requires scrolling and mental bookmarkingExtract for readability
Every line contributes to one operationLength is fine

Readability Checklist

Before committing code, verify:

  • Names reveal intent without needing comments
  • Comments explain why, not what
  • No commented-out code
  • Functions operate at a single abstraction level
  • Nesting is 2 levels or fewer
  • Anonymous functions are short and their purpose is obvious
  • Formatting follows project conventions
  • Code follows the same patterns as surrounding code

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.