Logo von Comment Refactor

Comment Refactor

Community
iamneilroberts
comment-refactor

Refactor the comments in AI-generated (or long-lived) code — strip the accumulation of fix-history narration, obsolete explanations, and code-restating noise while preserving load-bearing WHY/TODO/warning comments. Works over a path, glob, or the whole repo; skips dead/abandoned/unused and vendored/generated files; and stamps each cleaned file with a content-hash marker so re-runs skip files that haven't changed. Incorporates the /remove-comments and /deslop (humanizer) heuristics plus a used-code filter and incremental idempotency. Triggers on `/comment-refactor [path|glob]`, "refactor the comments", "clean up comment cruft", "strip obsolete comments".

Übersicht

Herausgeberiamneilroberts
Repositoryclaude-skills
Skill-Namecomment-refactor
Sterne
37
Forks
6
Mitgelieferte Dateien
2
LizenzMIT
Links
  • Anweisungen in Markdown

    Eine SKILL.md-Datei, die das Modell bei Bedarf lädt. So werden nur dann Token verbraucht, wenn eine Anfrage tatsächlich dazu passt.

  • Funktioniert mit jedem LLM

    KI-Skills bestehen aus reinem Markdown, nicht aus anbieterspezifischem Code. Daher funktionieren sie mit GPT, Claude, Gemini, Grok oder einem lokalen Modell.

  • 2 mitgelieferte Dateien

    Skripte, Vorlagen und Referenzmaterial, die das Modell bei der Arbeit lesen kann. Die Dateien sind schreibgeschützt und werden niemals ausgeführt.

  • Open Source

    Von iamneilroberts auf GitHub veröffentlicht. Prüfen Sie den Quellinhalt vor der Installation.

Installation

Installieren Sie den KI-Skill Comment Refactor in TypingMind, um ihn mit jedem LLM zu nutzen, oder fügen Sie ihn einem anderen Agenten hinzu, der SKILL.md lesen kann.

1

In TypingMind installieren

TypingMind installiert einen Skill direkt aus seinem GitHub-Ordner — liest SKILL.md, bündelt die Ressourcendateien und speichert das Ergebnis lokal.

  1. Öffnen Sie die App und gehen Sie zu Plugins → Skills.
  2. Wählen Sie „Von GitHub installieren“.
  3. Fügen Sie die unten angegebene URL des Skill-Ordners ein und bestätigen Sie.
    https://github.com/iamneilroberts/claude-skills/tree/main/skills/comment-refactor
  4. Aktivieren Sie den Skill in jedem Chat, in dem er verfügbar sein soll.
Plugins → Skills → Skill anlegen → Über GitHub-URL. Fügen Sie dann die Ordner-URL ein und klicken Sie auf „Weiter“.
2

In einem anderen Agenten installieren

Jeder Agent, der das Agent-Skills-Format lesen kann, kann diesen Skill nutzen — kopieren Sie den Ordner in das Skill-Verzeichnis des jeweiligen Agenten.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/iamneilroberts/claude-skills.git /tmp/claude-skills
mkdir -p .claude/skills
cp -r /tmp/claude-skills/skills/comment-refactor .claude/skills/comment-refactor
Starten Sie Claude Code nach dem Kopieren neu, damit der neue Skill erkannt wird.

In TypingMind verwenden

Aktivieren Sie Comment Refactor in einem beliebigen Chat in TypingMind. Den Rest übernimmt das Modell. Name und Beschreibung des Skills stehen im System-Prompt. Sobald eine Anfrage passt, lädt das Modell selbstständig die vollständigen Anweisungen — Sie müssen den Skill nie manuell aufrufen, und er verbraucht erst Token, wenn er tatsächlich genutzt wird.

Das Modell lädt Comment Refactor automatisch, sobald eine passende Anfrage gestellt wird.

Funktioniert mit jedem KI-Modell

KI-Skills bestehen aus reinen Markdown-Anweisungen statt aus anbieterspezifischem Code. Daher ist Comment Refactor nicht an das Modell gebunden, für das der Skill geschrieben wurde. Installieren Sie ihn einmal in TypingMind und nutzen Sie ihn mit GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder einem selbst betriebenen lokalen Modell — alles mit Ihren eigenen API-Keys.

  • Wird nur bei Bedarf geladen

    Der System-Prompt enthält nur den Namen und die Beschreibung. Die Anweisungen werden bei der ersten passenden Anfrage geladen. Ein ungenutzter Skill verursacht daher keine Kosten.

  • Modell im laufenden Chat wechseln

    Da der Skill aus Anweisungen statt aus Code besteht, funktioniert er auch nach einem Modellwechsel — das nächste Modell liest dieselbe SKILL.md-Datei.

Skill-Anweisungen

Dies ist der Inhalt von SKILL.md, den das Modell lädt. Lesen Sie ihn vor der Installation — ein Skill besteht aus Anweisungen, denen Ihr Modell folgt.

/comment-refactor — clean comment cruft, incrementally, across a codebase

Comments in AI-assisted code accumulate: fix-history narration (// changed to X because the old way broke), stale explanations that no longer match the code, and line-by-line restating of what the code plainly does. This skill removes that layer while keeping the comments that carry real information, across many files, and only re-touches files that changed since their last pass.

It composes three things:

  1. the /remove-comments keep/remove judgment (the engine),
  2. the /deslop → humanizer pass applied to comment prose (AI-tell removal inside the comments that survive), and
  3. two mods you asked for: a used-code filter (skip dead/abandoned/unused + vendored/generated files) and an incremental content-hash marker (skip files already up to date).

Bundled helpers

  • marker.py — the idempotency control marker. check <file> (exit 0 = up-to-date/skip, 10 = process), stamp <file> (write/refresh the marker), hash <file>. The marker is @comment-refactor:v1:<sha256(body-without-marker)[:16]> in the file's own comment syntax, placed at the top (after a shebang). Excluding the marker line from the hash makes re-stamping stable; any real edit changes the hash and forces a reprocess.
  • scan.sh [path|glob …] — prints the mechanical worklist (PROCESS <file> / SKIP-UPTODATE <file>), applying the extension allowlist, the vendored/generated exclusions, and the marker check. Default scope is the git-tracked tree.

Procedure

1. Resolve scope

From the argument: a file → that file; a directory/glob → its matching files; empty → the whole repo. Run the scan to get the worklist:

bash
bash "$SKILL_DIR/scan.sh" <path-or-glob>     # omit arg for the whole repo

SKILL_DIR is this skill's directory. Everything marked SKIP-UPTODATE is already clean since its last pass — ignore it. Work only the PROCESS list.

2. Filter to code that's actually used (the used-code mod)

The scan already drops node_modules/dist/build/vendor/.min./*.d.ts/generated dirs. Now drop dead/abandoned/unused source too, so effort goes to live code:

  • If the repowise MCP server is available, call get_dead_code and remove any PROCESS file it flags as dead/unreachable. If codebase-memory is available instead, use search_graph / reachability to the same end.
  • If neither is available, fall back to obvious signals only — files with no inbound imports, files under legacy//deprecated//archive/, and anything the repo's own docs mark obsolete — and say in the summary that the dead-code filter was heuristic, not tool-verified.

Never delete or edit a file you're skipping; just leave it out of the worklist.

3. Refactor each PROCESS file

Read the file. Apply the keep/remove judgment (comment syntax is language-specific — //, #, --, /* */, <!-- -->, docstrings).

REMOVE:

  • Comments that restate the code (// increment i, # return the result, // constructor).
  • Fix-history / changelog narration in comments: // changed to…, // was previously…, // fixed bug where…, // updated 2024-… to handle…, stacked layers of // also handle… added over time. The comment should describe the code as it is now, not its edit history — that's what git is for.
  • Obsolete explanations that no longer match the current code (verify against the actual code, not the comment's claim).
  • AI narration of control flow (// Now we loop over the items and…, // First, we check if…).
  • Commented-out code (// const old = …) unless a nearby comment explains why it's intentionally parked.

PRESERVE (do not touch):

  • WHY a non-obvious choice was made; business-logic rationale; the repo's own "load-bearing" comments.
  • TODO / FIXME / HACK / XXX, MARK:/section markers, and warnings about non-obvious or dangerous behavior.
  • License/copyright headers, @ts-* / eslint-* / noqa / type-directive pragmas, and generator markers — including this skill's own @comment-refactor:v1: marker.

CONSOLIDATE: where several stacked comments describe one thing (typically fix-history), collapse to a single present-tense line, or delete if the code is now self-evident.

Then de-slop the surviving comment prose. If the humanizer skill is available, invoke it (Skill tool, skill=humanizer) on the comment text — it's the source of truth (/deslop is its alias). If it isn't installed, apply its core rules inline: no em-dash overuse, no rule-of-three, no AI vocabulary ("leverage", "seamless", "robust"), no filler/hedging. Either way, keep the technical content and stay neutral — never rewrite comments in anyone's "voice".

Keep changes surgical — comments only. Do not touch code, formatting, or imports.

4. Stamp the marker

After editing a file, refresh its marker so future runs skip it until it changes again:

bash
python3 "$SKILL_DIR/marker.py" stamp <file>

Stamp only files you actually refactored (or confirmed already clean this pass) — the marker asserts "these comments were reviewed at this content hash."

5. Confirm + report

  • Default to a dry-run first on a multi-file scope: show the worklist and a sample of the removals per file, and get a go-ahead before applying — a bulk comment sweep is easy to over-cut. A single-file / small scope can apply directly with the diff shown.
  • Report: files processed, files skipped up-to-date, files skipped as dead/vendored, and a one-line note if the dead-code filter was heuristic.

Notes

  • The marker makes the skill cheap to re-run: a second pass over an unchanged repo does almost no work (all SKIP-UPTODATE). Run it after a big AI-assisted coding burst.
  • Bump the marker version (v1→v2) only if the keep/remove rules change enough that every file deserves a fresh pass — that invalidates all existing markers by design.
  • Language coverage is the marker helper's extension map; an unsupported extension is reported and left unstamped rather than guessed.

Mitgelieferte Dateien

Das Modell liest diese Dateien bei Bedarf, während der Skill geladen ist. Sie werden als lesbare Dateien bereitgestellt und niemals ausgeführt.

Häufig gestellte Fragen

Was macht der KI-Skill Comment Refactor?

Refactor the comments in AI-generated (or long-lived) code — strip the accumulation of fix-history narration, obsolete explanations, and code-restating noise while preserving load-bearing WHY/TODO/warning comments. Works over a path, glob, or the whole repo; skips dead/abandoned/unused and vendored/generated files; and stamps each cleaned file with a content-hash marker so re-runs skip files that haven't changed. Incorporates the /remove-comments and /deslop (humanizer) heuristics plus a used-code filter and incremental idempotency. Triggers on `/comment-refactor [path|glob]`, "refactor the...

Warum Comment Refactor in TypingMind nutzen?

Weil Sie den Skill einmal installieren und mit jedem Modell verwenden können. Comment Refactor besteht aus reinem Markdown statt aus anbieterspezifischem Code. So funktioniert derselbe Skill mit GPT-5, Claude, Gemini, Grok oder einem lokalen Modell – und Sie können das Modell mitten im Chat wechseln, ohne dass der Skill seine Funktion verliert. TypingMind verwendet Ihre eigenen API-Schlüssel. Sie bezahlen die Anbieter daher direkt statt über ein Abonnement pro Nutzerplatz, und Ihre Skills und Chats bleiben in Ihrem eigenen Speicher.

Wie installiere ich Comment Refactor in TypingMind?

Öffnen Sie in TypingMind Plugins → Skills → Von GitHub installieren und fügen Sie https://github.com/iamneilroberts/claude-skills/tree/main/skills/comment-refactor ein. TypingMind liest die Datei SKILL.md, bündelt die zugehörigen Dateien und installiert alles als Skill, den Sie für jeden Chat einzeln aktivieren können.

Welche KI-Modelle können Comment Refactor nutzen?

Jedes Modell, das Sie in TypingMind verbinden. KI-Skills bestehen aus reinen Markdown-Anweisungen statt aus anbieterspezifischem Code. Daher können GPT, Claude, Gemini, Grok und lokale Modelle diesen Skill laden, wenn eine Anfrage dazu passt.

Wie viele KI-Modelle kann ich mit Comment Refactor verwenden?

So viele Sie möchten. Solange ein Modell Skills unterstützt, können Sie Comment Refactor damit verwenden – GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama und weitere – alles in TypingMind mit Ihren eigenen API-Schlüsseln.

Ist der KI-Skill Comment Refactor kostenlos?

Ja. Der Skill wird von iamneilroberts auf GitHub unter der Lizenz MIT veröffentlicht. Sie bezahlen nur Ihren eigenen KI-Anbieter für die verwendeten Token.

Was sind KI-Skills?

Ein KI-Skill ist ein wiederverwendbares Anweisungspaket, das einem KI-Modell vermittelt, wie es eine bestimmte Aufgabe erledigt. Es folgt dem offenen Format Agent Skills: eine Datei namens SKILL.md mit einem Namen und einer Beschreibung sowie allen Skripten, Vorlagen oder Referenzdateien, die das Modell möglicherweise benötigt. Das Modell liest die Anweisungen nur, wenn Ihre Anfrage zum Skill passt. Ein installierter Skill verursacht daher erst Kosten, wenn er verwendet wird.

Wie unterscheiden sich KI-Skills von Plugins oder MCP-Servern?

Ein Plugin oder MCP-Server stellt einem Modell neue aufrufbare Tools bereit – Code, der auf einem System ausgeführt wird und ein Ergebnis zurückgibt. Ein KI-Skill vermittelt dem Modell stattdessen Wissen und Vorgehensweisen: wie es eine Aufgabe angeht, welche Schritte es befolgt und wie eine gute Ausgabe aussieht. Skills bestehen aus reinem Markdown und benötigen daher weder Server noch API-Schlüssel oder Laufzeitumgebung. Sie funktionieren mit jedem Modell.

Alle

Jetzt eigenen KI-Arbeitsbereich einrichten

Abonnieren Sie unseren Newsletter und erfahren Sie mehr über neue Funktionen und kommende Gewinnspiele 👇