agentleFS
phanijappsphanijapps/memex/.agents/skills/clean-comments/SKILL.md

clean-comments

Skill0 starsChanged 59 days agoMITView on GitHub

Use when writing, fixing, editing, or reviewing Python comments and docstrings. Enforces high-information documentation—call-sufficient contracts, pyguide-style sections on public APIs, doctest examples—while removing metadata, redundancy, stale comments, and commented-out code.

7 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 7 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:

    Write comments and docstrings only when they add information the code cannot express clearly by itself.

    line 15
  2. Distinctive:

    Prefer this order — improve the code before adding a comment:

    line 23
  3. Distinctive:

    Never delete a comment that records a design decision, external constraint, security rule, concurrency assumption, or reason an obvious …

    line 33
  4. Distinctive:

    If it answers none of these, improve the code or delete the comment.

    line 95

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

Clean Comments

Write comments and docstrings only when they add information the code cannot express clearly by itself.

The goal is not fewer comments. The goal is higher information density: contracts, rationale, constraints, invariants, side effects, surprises.

Core Principle

Prefer this order — improve the code before adding a comment:

  1. Clear names
  2. Small, focused functions and classes
  3. Type annotations
  4. Constants instead of magic values
  5. Assertions or validation for enforceable invariants
  6. Docstrings for public contracts
  7. Comments for non-obvious reasoning or constraints

Never delete a comment that records a design decision, external constraint, security rule, concurrency assumption, or reason an obvious alternative is wrong — rewrite it more clearly instead. Git preserves history; comments preserve reasoning.

Comment Rules (quick reference)

Full rules with examples: references/comments.md

RuleOne line
C1 No inappropriate infoNo authors, dates, tickets, change history — that belongs to Git/issue trackers
C2 Delete obsolete commentsA stale comment is worse than none; update docs in the same edit as the code
C3 No redundant commentsNever restate what the code says; add semantics, not translation
C4 Write comments wellBrief, specific, adjacent to the code, focused on why
C5 No commented-out codeDelete it; Git preserves versions
C6 Intent, not mechanicsExplain why and constraints, not what
C7 Refactor before commentingRename, extract, constant, type, validate — comment only what remains
No TODO/FIXME/HACK labelsExplain the actual constraint instead; TODOs must name concrete unresolved work
No decorative sections or closers# ==== X ==== and # end if are noise; fix the structure

Docstring Rules (quick reference)

Full rules with examples: references/docstrings.md Templates to copy: assets/docstring-templates.md

RuleOne line
Call-sufficiency testA docstring must let a caller write the call without reading the body
Document contracts, not syntaxNever restate names, types, or obvious returns
Method documentationpyguide-style sections (Args/Returns/Raises) on public APIs, with real contract content — never skeleton filler
Style ladderOne-liner → summary + details → sections; escalate only as facets grow
Examples beat proseRunnable doctest examples for tricky behavior
Negative spaceWhat it does NOT do (no I/O, no locking, no retry) is contract
Class invariants onceClass docstring carries invariants so methods don't repeat them
Sections only where owedInternals stay terse; private helpers need nothing by default

Review at a Glance

Classify before changing — never delete first and reason afterward:

CategoryAction
contract / rationale / constraint / invariantKeep or clarify
redundant / commented_code / metadataDelete
staleUpdate or delete
unclearRewrite if useful, otherwise delete

Full procedure, editing and reviewing workflows, output behavior: references/reviewing.md

Final Test

A comment or docstring survives review only if it answers a question the code cannot answer on its own:

  • Why? Under what constraint?
  • What must remain true?
  • What does the caller rely on — and what must the caller know to call this without reading the body?
  • What surprising behavior or side effect exists?

If it answers none of these, improve the code or delete the comment.

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.