clean-code Skill
✓ VerifiziertErzwingt Coding-Standards wie das Single-Responsibility-Prinzip, klare Benennung und Komplexitätsmanagement beim Generieren oder Modifizieren von Implementierungscode.
- GitHub Stars
- 211
- Dateien
- 2
- Letzter Commit
- 24. Okt. 2026
- Lizenz
- MIT
- Erlaubte Tools
- —
Was macht der clean-code Skill?
clean-code ist ein Agent Skill. Erzwingt Coding-Standards wie das Single-Responsibility-Prinzip, klare Benennung und Komplexitätsmanagement beim Generieren oder Modifizieren von Implementierungscode.
Zusammenfassung erzeugt aus der SKILL.md des Skills.
Über den clean-code skill
Die Hauptfunktion dieses Skills besteht darin, eine hohe Implementierungsqualität während des Coding-Prozesses aufrechtzuerhalten. Er wurde für Entwickler entwickelt, die sicherstellen müssen, dass jede einzelne Code-Einheit strengen Standards für klare Benennung, Single Responsibility und Komplexitätsmanagement entspricht. Der Skill wird automatisch von spezialisierten Agenten wie code-forge, refactor-safely und bug-fix geladen, wenn ein Nutzer Verbesserungen der Codequalität oder spezifische Coding-Guidelines anfordert.
Anstatt sich auf die breite Architektur oder Sicherheit zu konzentrieren, steuert dieses Tool das Handwerk beim Schreiben spezifischer Funktionen und Variablen. Es nutzt ein Konfigurationssystem, das .lattice/config.yaml ausliest, um benutzerdefinierte Standards oder sprachspezifische Idiome für Error Handling und Typsysteme anzuwenden. Der Skill verwendet eine Self-Validation-Checkliste, um Funktionsgröße, zyklomatische Komplexität und Parameteranzahl zu überwachen, damit der Code selbstdokumentierend und leicht testbar bleibt. Zudem führt er einen aktiven Scan auf Anti-Patterns wie tiefe Verschachtelungen, kryptische Benennungen und verschluckte Errors durch, um zu verhindern, dass Technical Debt in die Codebase gelangt.
Was ein agent damit machen kann
- 1Single Responsibility in Funktionen erzwingenFordere den Agenten auf, eine große Funktion, die mehrere Aufgaben übernimmt, in kleinere, fokussierte Einheiten zu refactoren.
- 2Zyklomatische Komplexität reduzierenBitte den Agenten, die komplexe Conditional Logic innerhalb eines spezifischen Code-Blocks zu vereinfachen.
- 3Benennung von Variablen und Funktionen verbessernInstruiere die KI, Variablen und Funktionen so umzubenennen, dass ihre Absicht ohne zusätzliche Kommentare klar ist.
Geschrieben basierend auf dem SKILL.md des skills. Jeder use case wurde gegen ein zitat daraus geprüft.
So installierst du den clean-code Skill
Jeder Befehl kopiert den Skill-Ordner in das Skills-Verzeichnis des Clients. Starte den Client neu oder beginne eine neue Session, um ihn zu laden.Den clean-code Skill in Plugin installieren
/plugin marketplace add techygarg/lattice /plugin install lattice@lattice
Den clean-code Skill in Claude Code installieren
~/.claude/skills/clean-code/SKILL.md
$ npx degit techygarg/lattice/skills/clean-code ~/.claude/skills/clean-codeDen clean-code Skill in Claude Code (project) installieren
.claude/skills/clean-code/SKILL.md
$ npx degit techygarg/lattice/skills/clean-code .claude/skills/clean-codeDen clean-code Skill in Codex installieren
~/.agents/skills/clean-code/SKILL.md
$ npx degit techygarg/lattice/skills/clean-code ~/.agents/skills/clean-codeDen clean-code Skill in Gemini CLI installieren
~/.gemini/skills/clean-code/SKILL.md
$ npx degit techygarg/lattice/skills/clean-code ~/.gemini/skills/clean-codeDen clean-code Skill in Claude.ai installieren
npx degit techygarg/lattice/skills/clean-code clean-code && zip -r clean-code.zip clean-code # claude.ai → Customize → Skills → + → Create skill → Upload a skill → clean-code.zip
Automatisierte Checks
Geluften am 14. Nov. 2026Vollständiger Bericht →Hat unsere automatischen Prüfungen bestanden. Das ist kein Sicherheitsaudit: Lesen Sie die Skripte, bevor ein Agent sie ausführt. Wie die Checks funktionieren
- Source Repository verknüpft und erreichbartechygarg/lattice/skills/clean-code is public and reachablegithub.com/techygarg/lattice/tree/HEAD/skills/clean-code ↗Bestanden
- Open Source Lizenz (OSI)MITspdx.org/licenses/MIT.html ↗Bestanden
- Commit oder Release im letzten JahrLast commit 2026-10-24github.com/techygarg/lattice/commits ↗Bestanden
- Keine Download-und-Ausführen-Muster oder Zugangsdatendiebstahl in SkriptenNo scripts in the skill folderBestanden
- Keine versteckten Anweisungen in SKILL.mdNo override phrases, safeguard switches, credential requests or hidden charactersgithub.com/techygarg/lattice/blob/HEAD/skills/clean-code/SKI ↗Bestanden
- Vorab erlaubte Tools sind eingeschränktNo pre-approved tools; the agent asks before using onegithub.com/techygarg/lattice/blob/HEAD/skills/clean-code/SKI ↗Bestanden
SKILL.md
Auf GitHub ansehenClean Code
Config Resolution
Projects can customize this skill's standards. Resolution order:
- Read
.lattice/config.yamlin the repo root. - If found, check
paths.clean_codefor a custom document path. - If a custom document exists at that path, read it and check its YAML frontmatter for
mode:mode: override: the custom document has full precedence. Use it instead of the embedded defaults. It must be comprehensive -- treat it as the sole reference.mode: overlay(or no mode field): read the embedded./references/defaults.mdfirst, then apply the custom document's sections on top. A custom section replaces the matching default section (matched by exact heading); new sections append after the defaults.
- If a custom path is configured but no document exists at it → tell the user which configured path is missing, then fall back to
./references/defaults.md. - If there is no config file or no
paths.clean_codekey, read./references/defaults.md. - Language adaptation: if
paths.language_idiomsis set in the config and the document exists, read it and adapt the defaults using these sections:- "Error Handling" → adapt §8 (Error Handling) patterns to the language's idioms. Language idioms take precedence over the pseudocode defaults.
- "Type System & Object Model" → adapt §1 (Single Responsibility) cohesion guidance to the language's constructs (e.g., struct vs class).
- "Naming Conventions" → adapt §4 (Meaningful Naming) patterns to the language's conventions.
- "Parameter & Function Design" → adapt §2 (Small, Focused Functions) and §5 (Parameter Design) to the language's capabilities.
- "Dependency Management" → adapt §9 (Test-Friendly Code) dependency-injection patterns to the language's idioms.
Self-Validation Checklist
STOP after generating each component. Verify ALL checks. Fix every failed check before presenting. Judgment calls → present options (see Ambiguity Signals).
- SINGLE RESPONSIBILITY: Can you describe each function without "and"? If not → extract a separate function.
- SIZE: Is each function under the size threshold from the loaded doc (~20 lines default)? If not → extract a sub-operation into its own named function.
- COMPLEXITY: Is cyclomatic complexity under the threshold from the loaded doc (~10 default)? If not → flatten with a guard clause or extract a branch.
- ABSTRACTION LEVEL: Does each function operate at one level of abstraction? If high-level logic mixes with low-level detail → extract the detail.
- NAMING: Does each function/variable name reveal intent without needing surrounding context? If not → rename to be self-documenting.
- PARAMETERS: Is the parameter count under the threshold from the loaded doc (4 default)? If not → group parameters into an object.
- PRIMITIVE OBSESSION: Would a string/number/boolean be clearer as a named type? If so → introduce a parameter object or typed wrapper.
- ERROR HANDLING: Does every fail-able operation have explicit handling with an actionable message? Is it handled at the right level?
Project-specific checks: if the loaded doc (from Config Resolution) contains a Validation Checklist section (§10 from the clean-code-refiner template), apply those checks as additional project-specific validation after the checklist above.
All checks pass → state "Passes clean-code. [next step]."
Active Anti-Pattern Scan
After the checklist, scan for each of these. Any box you can check → fix before presenting.
- God Function: a function exceeds ~30 lines doing multiple things; describing it requires "and" → extract focused functions.
- Deep Nesting: three or more levels of indentation → flatten with early returns / guard clauses.
- Cryptic Naming: variables like
d,tmp2,processData→ rename to reveal intent. - Long Parameter Lists: five or more parameters → group into an object or split the function.
- Premature Abstraction: a utility extracted from only two similar blocks → inline it until the Rule of Three (third instance with the same reason to change).
- Swallowed Errors: empty catch blocks, generic "something went wrong" messages, silent null returns → handle explicitly.
- Comments as Deodorant: a comment explains convoluted code instead of the code being fixed → rename to self-document; keep only "why" comments, remove "what" comments.
- Hidden Side Effects: a function named
getXalso writes a cache or sends notifications → rename or separate the concern. - Dead Code: commented-out blocks, unused imports, unreachable branches → delete them (version control preserves history).
- Untestable Logic: side effects tangled with business logic; unit testing requires mocking I/O → push side effects to the boundary, extract pure functions, inject dependencies.
Ambiguity Signals
Multiple valid outcomes exist. Present the options rather than silently choosing. If framework:collaborative-judgment is loaded, use its presentation format. See ./references/defaults.md for resolution guidance on each signal below.
- Single Responsibility: two tightly-coupled sequential operations may be one responsibility (a pipeline), not two. The "and" test catches true violations AND false positives.
- Function Size: near-threshold size (20–30 lines) with one clear purpose -- extraction may create five unclear smaller functions. Present the tradeoff.
- DRY vs Premature Abstraction: two identical blocks may serve different purposes and diverge independently. Until a third instance with the same reason to change appears, this is genuinely ambiguous.
- Error Handling Strategy: exception vs Result type vs error codes depends on language idiom and team convention, not on universal rules.
Dateien in diesem Skill
2clean-code Skill-Fragen
Wie installiere ich den clean-code Skill in Claude Code?
Führe npx degit techygarg/lattice/skills/clean-code ~/.claude/skills/clean-code aus. Claude Code lädt Skills aus ~/.claude/skills (alle Projekte) oder .claude/skills (ein Projekt) und nutzt einen Skill, wenn seine Beschreibung zur Aufgabe passt.
Welche Clients können den clean-code Skill nutzen?
Jeder Client, der das Agent Skills-Format liest: Claude Code, Codex, Gemini CLI und claude.ai (als ZIP hochladen). Skripte im Skill laufen nur dort, wo der Client Codeausführung erlaubt.
Was sind die Standard-Schwellenwerte für Funktionsgröße und Komplexität?
Standardmäßig sollten Funktionen unter etwa 20 Zeilen liegen und eine zyklomatische Komplexität von unter etwa 10 aufweisen.
Wie kann ein Projekt die Clean-Code-Standards anpassen?
Projekte können die Standards anpassen, indem sie einen benutzerdefinierten Dokumentenpfad in .lattice/config.yaml definieren. Dabei kann entweder der 'override'-Modus für volle Priorität oder der 'overlay'-Modus zur Ergänzung der Standardwerte genutzt werden.