Aller au contenu
Skillpedia
Documentation40k · #7268

lean-comments

Ce qu’il fait

Cet outil aide à garder le code d'un programme propre et facile à comprendre. Il vérifie si les commentaires du code sont vraiment nécessaires et s'ils expliquent le « pourquoi » des choses, plutôt que de répéter ce que le code dit déjà.

Quand l’utiliser

  • ✓Quand vous ajoutez de nouveaux commentaires au code.
  • ✓Quand vous relisez des commentaires existants pour vérifier qu'ils sont utiles.
  • ✓Quand le code est confus et a besoin d'une explication claire.

Lien du skill

https://github.com/github/awesome-copilot/blob/main/skills/lean-comments/SKILL.md

Copiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.

Comment l’utiliser

Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.

Message prêt à coller

Utilise ce skill pour m’aider : https://github.com/github/awesome-copilot/blob/main/skills/lean-comments/SKILL.md Lis le fichier SKILL.md de ce lien et suis ses instructions pour ma tâche.
Envie que votre IA trouve seule des skills comme celui-ci ?Installez le MCP gratuit de Skillpedia : une ligne, et elle cherche parmi 15 000+ skills avant chaque tâche.Installer en 1 minute →

Exemple de demande à votre IA

“Relis les commentaires de cet extrait de code pour vérifier qu'ils sont essentiels et qu'ils expliquent le « pourquoi ».”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

L'outil se demande si un programmeur expérimenté perdrait des informations importantes en l'absence du commentaire. Il privilégie la suppression des commentaires qui répètent simplement le code ou qui sont évidents.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis GitHub.

Lean Comments

Goal

Keep the smallest amount of high-value commentary necessary to make a codebase easier and safer to understand and maintain.

The default is no comment.

A comment must preserve meaningful information that a competent maintainer cannot reasonably recover from the code, names, types, signatures, structure, tests, configuration, or nearby context.

Comments are not labels, narration, decoration, declaration summaries, change logs, or substitutes for clear code.

Reader model

Write for a competent maintainer reading the repository at HEAD months later, without access to the current conversation, prompt, diff, pull request, issue discussion, review discussion, or implementation process.

Document the durable state, contract, constraint, or rationale of the code as it exists. Do not assume the reader knows what changed, what came before, or what was discussed unless that context is deliberately preserved in a reliable project source.

Authority and evidence

Use this skill as the comment-policy authority when it is active.

Use language, framework, library, or infrastructure skills to determine whether a non-obvious constraint is real, not to override this skill's necessity test.

Honor explicit current repository requirements, public API documentation requirements, tooling contracts, and generated-source rules. Do not infer a documentation requirement merely from existing comment density or precedent.

Base retained or newly written rationale on evidence from the repository, tests, configuration, official API behavior, project documentation, issue tracker, ADRs, specifications, or another reliable source.

Never invent a security reason, performance reason, business rule, compatibility requirement, API constraint, historical reason, architectural rationale, or external limitation to justify commentary.

If no supported non-obvious reason exists, remove or omit it.

Core decision rule

Before retaining or adding ordinary commentary, mentally remove it and ask:

Would a competent maintainer lose meaningful, non-obvious information if this comment did not exist?

If no, remove or omit it.

If uncertain, prefer no comment unless repository evidence demonstrates that the information matters.

If yes, retain only the minimum information necessary.

Never preserve a comment merely because it is correct, harmless, already present, grammatically polished, written as a warning, related to security or validation, related to internal or public state, or attached to an exported declaration.

The information itself must justify the comment.

Decision order

Evaluate existing and proposed commentary in this order:

  1. Delete or omit if the information is already clear without it
  2. Express through code if a tiny behavior-preserving readability improvement removes the need for it
  3. Shorten if it is necessary but contains unnecessary information or words
  4. Rewrite if it is necessary but unclear, inaccurate, stale, awkward, or inconsistent
  5. Use declaration documentation if the information belongs to the declaration's contract, semantics, or intended usage
  6. Keep unchanged only if it is already necessary, minimal, accurate, durable, and correctly styled

Always decide necessity before wording.

Do not polish an unnecessary comment or convert one into documentation.

What deserves an implementation comment

Use an implementation comment when it preserves non-obvious information such as:

  • Why intentionally surprising code exists
  • An external constraint or compatibility requirement
  • An important invariant or subtle edge case
  • A meaningful tradeoff or required workaround
  • Non-obvious coupling
  • An ordering, timing, lifecycle, concurrency, performance, or security constraint
  • A reason an apparently simpler implementation would be incorrect

Prefer comments that explain why something matters.

Comments that merely explain what the code does should normally be removed.

Remove low-value commentary

Remove comments that merely:

  • Restate or translate the code into prose
  • Narrate the next statement or obvious control flow
  • Explain an obvious guard clause, return, assignment, or branch
  • Describe an obvious fetch, validation, transformation, mapping, filtering, creation, update, or deletion
  • Repeat a declaration name, property name, type, signature, parameter, or return type
  • Label or summarize a declaration

…

Questions fréquentes

Qu'est-ce que le « code source » ?

C'est le texte écrit par les programmeurs qui indique à un ordinateur quoi faire. C'est un peu comme une recette de gâteau.

Que sont les « commentaires » dans le code ?

Ce sont des notes insérées dans le code que les programmeurs utilisent pour expliquer les parties difficiles ou la raison d'un choix. L'ordinateur les ignore.

Pourquoi est-il important d'avoir de bons commentaires ?

De bons commentaires aident les autres programmeurs (ou vous-même, plus tard) à comprendre rapidement le code, ce qui facilite sa maintenance et la correction des erreurs.

Détails

Description originale de l’auteur

Audits, writes, and refines maintained first-party source-code comments and declaration-level documentation across languages. Use when adding, editing, reviewing, cleaning up, or auditing comments, doc comments, docstrings, TODO, FIXME, NOTE, suppressions, or other source commentary, including while modifying code and deciding whether a comment is warranted at all. Defaults to no comment unless it

repo: github/awesome-copilot

Popularité

Étoiles GitHub
40k
Position au classement
#7268
Licence
MIT
Mis à jour
15/10/2026

Ce skill vous est-il utile ?

0

Connectez-vous pour voter.

Commentaires

  • …

Autres skills de ce dépôt

Skills similaires