agentleFS
LedgerHQLedgerHQ/ledger-live/.agents/skills/comments/SKILL.md

comments

Skill627 starsChanged 8 days agoMITView on GitHub

Replace code comments with clearer names, explainer variables and test names, and keep the rare necessary comment to one short line or a link. Read when writing or reviewing code and about to add a `//` or `/* */` comment or a JSDoc block, or when a review flags a comment as noise, outdated or a paraphrase of the code.

9 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

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

  • 0

    Common

    Most of the 9 edited versions we read keep these.

  • 5

    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 code isn't clear, make it clearer:

    line 20
  2. Distinctive:

    Use assertions to explain behaviour

    line 24
  3. Distinctive:

    Be concise: Use as few words as possible to convey the necessary information.

    line 89
  4. Distinctive:

    Use JSDocs: Only when describing a shared function.

    line 90
  5. Distinctive:

    Prefer a link: If the comment is explaining a workaround for a known issue, link to the issue or docs.

    line 91

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

Comments in code

🧀 Avoid comments

Comments are code smells because they go out-of-date, bloat context, and lead to confusion.

Don't reference existing comments in the codebase – follow these rules

  • Avoid adding comments – always prefer good names (explainer variables, functions, tests)
  • Use test names to describe behaviour – unit tests are living documentation
  • Good code explains itself – don't add comments that duplicate what the code already conveys

💡 Treatments

When code isn't clear, make it clearer:

  • Rename variables and functions to make comments unnecessary
  • Extract variables and functions to improve readability
  • Use assertions to explain behaviour

Use test names to explain non-obvious details

❌ Bad

it("diffs the current value against resolved when targeted", () => {
  const { result } = renderHook(() => useJsonEditor(makeProps()));
  act(() => result.current.setDiffTarget("resolved"));
  // Current equals resolved → every line is unchanged.
  expect(result.current.diffJson.every((l) => l.state === "none")).toBe(true);
});

✅ Good

it("resets the state of every line when the diff is resolved", () => {
  const { result } = renderHook(() => useJsonEditor(makeProps()));
  act(() => result.current.setDiffTarget("resolved"));
  expect(result.current.diffJson.every((l) => l.state === "none")).toBe(true);
});

Let code speak for itself

❌ Bad

/* Whether the filter trigger should be displayed */
showFilter: boolean;

✅ Good

showFilter: boolean;

Replace comments with explainer variables

Move the comment into a variable name:

Before

// NB `app.trustchain` is an encrypted db path: while the app is password-locked it reads back
// as the ciphertext string. Importing it would regenerate member credentials and null the
// trustchain (LIVE-36130). IsUnlocked re-runs this thunk once the encryption key is set.
// `undefined` must still go through: that is the legitimate "nothing persisted" case.
if (typeof data === "string") return;

After

const dataIsEncrypted = typeof data === "string";
if (dataIsEncrypted) return;

☝️ When comments are necessary

Comments are only for vital information that can't go anywhere else. Always prefer not adding comments. If a comment is the only way, follow these guidelines:

  • Be concise: Use as few words as possible to convey the necessary information.
  • Use JSDocs: Only when describing a shared function.
  • Prefer a link: If the comment is explaining a workaround for a known issue, link to the issue or docs.

❌ Bad

# pnpm patches add 'patch_hash=HASH' to virtual store paths, which prefab 2.1.0
# (introduced via AGP 8.11) misparses as an option flag due to a clikt bug that splits
# positional path arguments at '='. Pinning prefab to 2.0.0 in gradle.properties avoids
# this; keeping path segments ≤ 80 chars shortens virtual-store paths to reduce the
# likelihood of triggering prefab path-parsing issues as an additional safeguard.
android.prefab.version=2.0.0
virtual-store-dir-max-length=80

✅ Better

# Workaround for Prefab 2.1.0/Clikt bug
# See: https://github.com/google/prefab/issues/187
android.prefab.version=2.0.0
virtual-store-dir-max-length=80

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.