Zum Inhalt springen
Skillpedia
Allgemeines Programmieren48k · #4151

clean-code

Was er macht

Dieses Tool hilft dir, Programmcode, der zwar funktioniert, aber schwer zu verstehen ist, in sauberen und gut lesbaren Code umzuwandeln. Dabei werden Best Practices befolgt, damit der Code für andere Entwickler übersichtlicher und verständlicher wird.

Wann du ihn nutzt

  • ✓Wenn du neuen Code schreibst und von Anfang an für Qualität sorgen möchtest.
  • ✓Wenn du fremden Code prüfst und Verbesserungsvorschläge machen willst.
  • ✓Wenn du alten, komplizierten Code reparieren oder verbessern möchtest.

Link zum Skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/clean-code/SKILL.md

Kopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.

So nutzt du ihn

Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.

Fertige Nachricht zum Einfügen

Nutze diesen Skill, um mir zu helfen: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/clean-code/SKILL.md Lies die SKILL.md unter diesem Link und folge ihren Anweisungen für meine Aufgabe.
Soll deine KI Skills wie diesen selbst finden?Installiere den kostenlosen Skillpedia-MCP: eine Zeile, und sie durchsucht vor jeder Aufgabe 15.000+ Skills.In 1 Minute installieren →

Beispielanfrage an deine KI

“Überarbeite diesen Code, damit er sauberer und leichter verständlich wird, ohne dass sich seine Funktion ändert.”

5 neue Skills pro Woche. 1 Minute Lesezeit.

So funktioniert es

Die KI analysiert den Code, den du bereitstellst, und wendet die Regeln für „Clean Code“ an. Dazu gehören aussagekräftigere Namen für Variablen und Funktionen, das Aufteilen langer Code-Abschnitte in kleinere, klar abgegrenzte Teile und das Entfernen überflüssiger Kommentare. So wird der Code besser lesbar.

Technischer Inhalt (originale SKILL.md)

Originaltext des Autors, auf Englisch, direkt von GitHub.

Clean Code Skill

This skill embodies the principles of "Clean Code" by Robert C. Martin (Uncle Bob). Use it to transform "code that works" into "code that is clean."

🧠 Core Philosophy

"Code is clean if it can be read, and enhanced by a developer other than its original author." — Grady Booch

When to Use

Use this skill when:

  • Writing new code: To ensure high quality from the start.
  • Reviewing Pull Requests: To provide constructive, principle-based feedback.
  • Refactoring legacy code: To identify and remove code smells.
  • Improving team standards: To align on industry-standard best practices.

1. Meaningful Names

  • Use Intention-Revealing Names: elapsedTimeInDays instead of d.
  • Avoid Disinformation: Don't use accountList if it's actually a Map.
  • Make Meaningful Distinctions: Avoid ProductData vs ProductInfo.
  • Use Pronounceable/Searchable Names: Avoid genymdhms.
  • Class Names: Use nouns (Customer, WikiPage). Avoid Manager, Data.
  • Method Names: Use verbs (postPayment, deletePage).

2. Functions

  • Small!: Functions should be shorter than you think.
  • Do One Thing: A function should do only one thing, and do it well.
  • One Level of Abstraction: Don't mix high-level business logic with low-level details (like regex).
  • Descriptive Names: isPasswordValid is better than check.
  • Arguments: 0 is ideal, 1-2 is okay, 3+ requires a very strong justification.
  • No Side Effects: Functions shouldn't secretly change global state.

3. Comments

  • Don't Comment Bad Code—Rewrite It: Most comments are a sign of failure to express ourselves in code.
  • Explain Yourself in Code:
    # Check if employee is eligible for full benefits
    if employee.flags & HOURLY and employee.age > 65:
    
    vs
    if employee.isEligibleForFullBenefits():
    
  • Good Comments: Legal, Informative (regex intent), Clarification (external libraries), TODOs.
  • Bad Comments: Mumbling, Redundant, Misleading, Mandated, Noise, Position Markers.

4. Formatting

  • The Newspaper Metaphor: High-level concepts at the top, details at the bottom.
  • Vertical Density: Related lines should be close to each other.
  • Distance: Variables should be declared near their usage.
  • Indentation: Essential for structural readability.

5. Objects and Data Structures

  • Data Abstraction: Hide the implementation behind interfaces.
  • The Law of Demeter: A module should not know about the innards of the objects it manipulates. Avoid a.getB().getC().doSomething().
  • Data Transfer Objects (DTO): Classes with public variables and no functions.

6. Error Handling

  • Use Exceptions instead of Return Codes: Keeps logic clean.
  • Write Try-Catch-Finally First: Defines the scope of the operation.
  • Don't Return Null: It forces the caller to check for null every time.
  • Don't Pass Null: Leads to NullPointerException.

7. Unit Tests

  • The Three Laws of TDD:
    1. Don't write production code until you have a failing unit test.
    2. Don't write more of a unit test than is sufficient to fail.
    3. Don't write more production code than is sufficient to pass the failing test.
  • F.I.R.S.T. Principles: Fast, Independent, Repeatable, Self-Validating, Timely.

8. Classes

  • Small!: Classes should have a single responsibility (SRP).
  • The Stepdown Rule: We want the code to read like a top-down narrative.

9. Smells and Heuristics

  • Rigidity: Hard to change.
  • Fragility: Breaks in many places.
  • Immobility: Hard to reuse.
  • Viscosity: Hard to do the right thing.
  • Needless Complexity/Repetition.

🛠️ Implementation Checklist

  • Is this function smaller than 20 lines?
  • Does this function do exactly one thing?
  • Are all names searchable and intention-revealing?
  • Have I avoided comments by making the code clearer?
  • Am I passing too many arguments?
  • Is there a failing test for this change?

Example

User request:

Refactor this working code for clearer names, smaller units, explicit errors, and preserved behavior; verify it with focused tests.

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.

…

Häufige Fragen

Was ist „Clean Code“?

Clean Code ist Code, den jeder Entwickler leicht lesen und verstehen kann, auch wenn er ihn nicht selbst geschrieben hat.

Warum sollte man aussagekräftigere Namen im Code verwenden?

Gute Namen verraten sofort, was der Code macht, ohne dass man zusätzliche Erklärungen braucht. Zum Beispiel ist „verstricheneZeitInTagen“ besser als „d“.

Was sind „Code Smells“?

Das sind Anzeichen im Code, dass etwas nicht stimmen könnte oder verbessert werden sollte, zum Beispiel verwirrende Namen, zu lange Funktionen oder doppelter Code.

Details

Originalbeschreibung des Autors

This skill embodies the principles of \"Clean Code\" by Robert C. Martin (Uncle Bob). Use it to transform \"code that works\" into \"code that is clean.\

repo: sickn33/agentic-awesome-skills

Beliebtheit

GitHub-Sterne
48k
Platz im Ranking
#4151
Lizenz
MIT
Aktualisiert
15.10.2026

Ist dieser Skill nützlich?

0

Anmelden um abzustimmen.

Kommentare

  • …

Weitere Skills aus diesem Repository

Ähnliche Skills