Logo vun Comment Refactor

Comment Refactor

Communautéit
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".

Iwwersiicht

Editeuriamneilroberts
Repositoryclaude-skills
Skill-Nummcomment-refactor
Stären
37
Forks
6
Matgeliwwert Fichieren
2
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 2 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    Vum iamneilroberts op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Comment Refactor an TypingMind, fir e mat all LLM ze benotzen, oder füügt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vun GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier hei drënner an a bestätegt.
    https://github.com/iamneilroberts/claude-skills/tree/main/skills/comment-refactor
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill afügen → Vu GitHub-URL, pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an de Skill-Verzeechnes vun deem KI-Agent.

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
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Comment Refactor an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Comment Refactor automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Comment Refactor net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Keys.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

/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.

Matgeliwwert Fichieren

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de 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...

Firwat Comment Refactor op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Comment Refactor besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt amplaz vun engem Abonnement pro Benotzerplaz. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Comment Refactor an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/iamneilroberts/claude-skills/tree/main/skills/comment-refactor an. TypingMind liest d'Datei SKILL.md, bündelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Comment Refactor benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Comment Refactor benotzen?

Esou vill Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Comment Refactor domat benotzen – GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama a méi – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Comment Refactor gratis?

Jo. De Skill gëtt vum iamneilroberts ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbaart Pak vun Instruktiounen, dat engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt en nokënnt a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a keng Lafzäitëmfeld a funktionéiere mat all Modell.

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇