Logotipo de Comment Refactor

Comment Refactor

Comunidad
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".

Descripción general

Editoriamneilroberts
Repositorioclaude-skills
Nombre de la habilidadcomment-refactor
Estrellas
37
Forks
6
Archivos incluidos
2
LicenciaMIT
Enlaces
  • Instrucciones en Markdown

    Un archivo SKILL.md que el modelo carga cuando lo necesita, de modo que solo consume tokens cuando una petición es realmente relevante.

  • Funciona con cualquier LLM

    Las habilidades de IA están en Markdown, no en código específico de un proveedor, por lo que funcionan con GPT, Claude, Gemini, Grok o un modelo local.

  • 2 archivos incluidos

    Scripts, plantillas y referencias que el modelo puede leer mientras trabaja. Los archivos son de solo lectura y nunca se ejecutan.

  • Código abierto

    Publicada por iamneilroberts en GitHub. Revisa el contenido original antes de instalarla.

Instalación

Instala la habilidad de IA Comment Refactor en TypingMind para usarla con cualquier LLM, o añádela a otro agente que lea SKILL.md.

1

Instalar en TypingMind

TypingMind instala una habilidad directamente desde su carpeta de GitHub: lee SKILL.md, empaqueta los archivos de recursos y guarda el resultado localmente.

  1. Abre la aplicación y ve a Plugins → Habilidades.
  2. Elige «Instalar desde GitHub».
  3. Pega la URL de la carpeta de la habilidad que se muestra a continuación y confirma.
    https://github.com/iamneilroberts/claude-skills/tree/main/skills/comment-refactor
  4. Activa la habilidad en cada chat en el que quieras tenerla disponible.
Plugins → Habilidades → Añadir habilidad → Desde URL de GitHub; después, pega la URL de la carpeta y pulsa Continuar.
2

Instalar en otro agente

Cualquier agente que lea el formato Agent Skills puede usar esta habilidad: copia la carpeta en el directorio de habilidades de ese agente.

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
Reinicia Claude Code después de copiarla para que detecte la nueva habilidad.

Úsala en TypingMind

Activa Comment Refactor en cualquier chat de TypingMind y el modelo se encargará del resto. Su nombre y descripción se incluyen en el prompt del sistema y, en cuanto una petición es relevante, el modelo carga las instrucciones completas por sí solo. No tienes que invocarla manualmente y no consume tokens hasta que se utiliza.

El modelo carga Comment Refactor automáticamente en cuanto una petición es relevante para esa habilidad.

Funciona con cualquier modelo de IA

Las habilidades de IA son instrucciones en Markdown, no código específico de un proveedor, por lo que Comment Refactor no está vinculada al modelo para el que se creó. Instálala una sola vez en TypingMind y úsala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modelo local que ejecutes tú, todo con tus propias claves API.

  • Se carga solo cuando se necesita

    El prompt del sistema solo incluye el nombre y la descripción. Las instrucciones se cargan con la primera petición relevante, por lo que una habilidad que no se usa no supone ningún coste.

  • Cambia de modelo durante el chat

    Como la habilidad contiene instrucciones y no código, cambiar de modelo no impide que funcione: el nuevo modelo lee el mismo archivo SKILL.md.

Instrucciones de la habilidad

Este es el contenido de SKILL.md que carga el modelo. Léelo antes de instalar la habilidad: contiene instrucciones que tu modelo seguirá.

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

Archivos incluidos

El modelo los lee según los necesita mientras la habilidad está cargada. Se ofrecen como archivos de lectura y nunca se ejecutan.

Preguntas frecuentes

¿Qué hace la habilidad de IA 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...

¿Por qué usar Comment Refactor en TypingMind?

Porque la instalas una vez y la usas con cualquier modelo. Comment Refactor está escrita en Markdown, no en código específico de un proveedor, por lo que la misma habilidad funciona con GPT-5, Claude, Gemini, Grok o un modelo local, y puedes cambiar de modelo en mitad del chat sin que deje de funcionar. TypingMind utiliza tus propias claves API, de modo que pagas directamente a los proveedores en lugar de pagar una suscripción por puesto, y tus habilidades y chats permanecen en tu propio almacenamiento.

¿Cómo instalo Comment Refactor en TypingMind?

Abre Plugins → Habilidades → Instalar desde GitHub en TypingMind y pega https://github.com/iamneilroberts/claude-skills/tree/main/skills/comment-refactor. TypingMind lee su archivo SKILL.md, empaqueta sus archivos y la instala como una habilidad que puedes activar en cada chat.

¿Qué modelos de IA pueden usar Comment Refactor?

Cualquier modelo que conectes en TypingMind. Las habilidades de IA son instrucciones en Markdown, no código específico de un proveedor, por lo que GPT, Claude, Gemini, Grok y los modelos locales pueden cargar esta habilidad cuando una solicitud se corresponda con ella.

¿Con cuántos modelos de IA puedo usar Comment Refactor?

Con tantos como quieras. Siempre que un modelo admita habilidades, puedes usar Comment Refactor con él: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama y muchos más, todos en TypingMind con tus propias claves API.

¿Es gratuita la habilidad de IA Comment Refactor?

Sí. iamneilroberts la ha publicado en GitHub bajo la licencia MIT. Solo pagas a tu proveedor de IA por los tokens que utilizas.

¿Qué son las habilidades de IA?

Una habilidad de IA es un conjunto de instrucciones reutilizables que enseña a un modelo de IA a realizar una tarea concreta. Sigue el formato abierto Agent Skills: un archivo SKILL.md con un nombre y una descripción, además de los scripts, plantillas o archivos de referencia que pueda necesitar el modelo. El modelo solo lee las instrucciones cuando tu solicitud se corresponde con la habilidad, por lo que una habilidad instalada no supone ningún coste hasta que se utiliza.

¿En qué se diferencian las habilidades de IA de los plugins o los servidores MCP?

Un plugin o un servidor MCP proporciona al modelo nuevas herramientas que puede invocar: código que se ejecuta en algún lugar y devuelve un resultado. En cambio, una habilidad de IA aporta conocimientos y procedimientos al modelo: cómo abordar una tarea, qué pasos seguir y qué se considera un buen resultado. Las habilidades son instrucciones en Markdown, por lo que no necesitan servidor, clave API ni entorno de ejecución, y funcionan con cualquier modelo.

Ver todos

Crea ya tu propio espacio de trabajo IA

Suscríbete a nuestro boletín para recibir avisos sobre nuevas funciones y próximos sorteos 👇