LLM Skills
~/catalogue/debugging et maintenance//SKILL

Code propre

/SKILL

Rédigez un code lisible et facile à maintenir en adoptant une nomenclature rigoureuse, en créant des fonctions courtes et en mettant en place une gestion des erreurs claire.

wondelaiwondelai
1.7k
17 juin 2026
MIT License
// contenu du skill

name: clean-code

description: 'Write readable, maintainable code through disciplined naming, small functions, and clean error handling. Use when the user mentions "code review", "naming conventions", "function too long", "code smells", "readable code", "boy scout rule", "single responsibility", or "unit test quality". Also trigger when reviewing pull requests for readability, refactoring messy functions, debating comment styles, or improving error handling patterns. Covers SRP, comment discipline, formatting, and unit testing. For refactoring techniques, see refactoring-patterns. For architecture, see clean-architecture.'

license: MIT

metadata:

author: wondelai

version: "1.2.0"


Clean Code Framework

A disciplined approach to writing code that communicates intent, minimizes surprises, and welcomes change. Apply these principles when writing new code, reviewing pull requests, refactoring legacy systems, or advising on code quality.

Core Principle

Code is read far more often than it is written — optimize for the reader. The read-to-write ratio is well over 10:1, so every naming choice, function boundary, and formatting decision either adds clarity or adds cost. Clean code reads like well-written prose: names reveal intent, functions tell a story one step at a time, and the Boy Scout Rule applies — always leave the code cleaner than you found it.

Scoring

Goal: 10/10. Rate any code 0-10 against the principles below. Report the current score and the specific improvements needed to reach 10/10.

  • 9-10: Names reveal intent, functions are small and focused, error handling is consistent, tests are clean and comprehensive
  • 7-8: Mostly clean with minor naming ambiguities or a few long functions; tests may lack edge cases
  • 5-6: Mixed — good patterns alongside unclear names, duplicated logic, or inconsistent error handling
  • 3-4: Long multi-purpose functions, misleading names, poor or missing tests
  • 1-2: Nearly unreadable — magic numbers, cryptic abbreviations, no structure, no tests

The Clean Code Framework

Six disciplines for writing code that communicates clearly and adapts to change:

1. Meaningful Names

Core concept: Names should reveal intent, avoid disinformation, and make the code read like prose. If a name requires a comment to explain it, the name is wrong.

Why it works: Names are the most pervasive form of documentation — a well-chosen name eliminates the need to read the implementation; a poor one forces every reader to reverse-engineer intent.

Key insights:

  • A name should answer why it exists, what it does, and how it is used
  • No encodings, prefixes, or type information (no Hungarian notation); single letters only for tiny-scope loop counters
  • Classes are nouns; methods are verbs
  • One word per concept: don't mix fetch, retrieve, and get
  • Longer scope demands a longer, more descriptive name
  • Rename freely — IDEs make it trivial

Code applications:

ContextPatternExample
VariablesIntention-revealingelapsedTimeInDays not d
BooleansPredicate phrasingisActive, hasPermission, canEdit
FunctionsVerb + nouncalculateMonthlyRevenue() not calc()
ClassesNoun naming the responsibilityInvoiceGenerator not InvoiceManager

See: references/naming-conventions.md

2. Functions

Core concept: Functions should be small, do one thing, and do it well — ideally 4-6 lines, zero to two arguments, one level of abstraction.

Why it works: Small single-purpose functions are easy to name, understand, test, and reuse; long functions hide bugs, resist testing, and accumulate responsibilities.

Key insights:

  • Step-Down Rule: code reads top-down, each function calling the next level of abstraction
  • Argument count: zero best, one fine, two acceptable, three+ requires justification
  • Flag arguments are a smell — the function does two things; split it
  • Command-Query Separation: change state or return a value, never both
  • Extract till you drop: if you can pull out a named function, do it
  • No hidden side effects — the name must tell the whole truth

Code applications:

ContextPatternExample
Long functionExtract named stepsvalidateInput(); transformData(); saveRecord();
Flag argumentSplit into two functionsrenderForPrint() / renderForScreen() not render(isPrint)
Error casesGuard clauses at topEarly return for errors, single happy path
Many argumentsIntroduce parameter objectnew DateRange(start, end) not report(start, end, format, locale)
Side effectsMake effects explicitcheckPassword() that starts a session → rename or separate

See: references/functions-and-methods.md

3. Comments and Formatting

*Core concept:

// source originale publique
wondelai/skills
/clean-code/SKILL.md
Licence : MIT License
Projet indépendant, non affilié à Anthropic. Ce skill reste la propriété de son auteur original.
// installer ce skill
Collez cette commande dans votre terminal à la racine de votre projet :
mkdir -p .claude/commands && curl -o ".claude/commands/SKILL.md" "https://raw.githubusercontent.com/wondelai/skills/main/clean-code/SKILL.md"
Ensuite dans Claude Code, tapez /SKILL pour l'activer.
open_in_newVoir la source originale
// sauvegarder
Sauvegarde disponible après connexion.
loginSe connecter pour sauvegarder
// informations
Créateurwondelai
Étoiles 1.7k
LicenceMIT License
Mis à jour17 juin 2026
Format.md
AccèsGratuit
// similaires

Skills Debugging et maintenance

Voir toutarrow_forward