Logo di Surgical Refactoring

Surgical Refactoring

Community
adamentwistle
surgical-refactoring

Refactor/rename/migration discipline — enumerate every call site before the first edit, separate mechanical from judgment edits, keep the build green, verify by absence and presence. Use when asked to rename, extract, move, split, inline, or deduplicate code; for signature/type reshapes; for codebase-wide pattern swaps (replace a helper, swap a library call); for any change touching 3+ call sites. Not for feature work or bug fixes that merely touch many files.

Panoramica

Pubblicato daadamentwistle
Repositoryfable-skills
Nome della skillsurgical-refactoring
Stelle
98
Fork
11
File inclusi
Solo istruzioni
LicenzaMIT
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • Tutto nelle istruzioni

    Tutto ciò che serve al modello è nelle istruzioni: nessun file aggiuntivo da sincronizzare.

  • Open source

    Pubblicata da adamentwistle su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Surgical Refactoring in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/adamentwistle/fable-skills/tree/main/surgical-refactoring
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Aggiungi skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella della skill nella directory delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/adamentwistle/fable-skills.git /tmp/fable-skills
mkdir -p .claude/skills
cp -r /tmp/fable-skills/surgical-refactoring .claude/skills/surgical-refactoring
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Surgical Refactoring in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Surgical Refactoring non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Surgical Refactoring non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Surgical Refactoring

Weak refactoring edits the hits the first grep happened to show, fixes a bug it noticed on the way, and calls it done when the build passes. Strong refactoring writes the full touch-point list before editing, changes behavior by exactly zero in the mechanical pass, and proves completion with a grep that returns nothing.

0. Baseline before the first edit

Run the project's gate suite (build/typecheck, lint, tests) once before touching anything and note what already fails. Without this you cannot tell a failure you caused from one you inherited.

1. Enumerate every touch point BEFORE the first edit

Grep for the symbol/pattern in every casing and form (fooBar, foo_bar, FooBar, foo-bar, string literals, dynamic/reflective access, re-exports, tests, docs, config). Record the exact command and the hit count. That list is the definition of done — not a green build, because dead branches, string-keyed lookups, and mock/stub twins compile fine while broken.

Sweeps people skip: test fixtures, mocks that mirror real implementations, serialized/persisted keys, API contract strings, comments/docs, CI and build config, anything reached by string dispatch.

2. Separate mechanical from judgment edits

(a) Mechanical: rename, move, signature reshuffle — zero behavior change. (b) Judgment: logic changes, improvements. Do them in separate passes, ideally separate commits, and run the gate suite between them: a green gate after the mechanical pass alone is the proof that pass was behavior-neutral. A diff mixing both is unreviewable, and behavior bugs hide inside "just a rename".

If asked only to refactor, behavior must be bit-identical. Bugs found mid-refactor are noted and reported, not fixed — fixing them silently changes behavior the user did not ask to change.

3. Sequence to keep the build green

Introduce the new shape first (new function/type alongside the old), migrate call sites in groups, delete the old shape last. When old and new cannot coexist, do the full sweep in one atomic pass. Never end a session with half the call sites migrated.

4. Verify by absence AND presence

  • Absence: rerun the step-1 grep → zero hits, or a one-line justification per remaining hit.
  • Presence: the full gate suite after the last edit.
  • Behavior: exercise the refactored path at runtime — a pure rename that passes tests can still break string-keyed dispatch or serialized data.

5. Scope is a contract

Improvements outside the requested scope go in the report as suggestions, not in the diff. The only exception is a change strictly required to complete the refactor (a caller that must adapt).

Stop and re-plan when

The sweep reveals far more sites than expected (5×), a public API or shared-interface boundary, or persisted-data implications (stored keys, wire formats, migrations). Surface it before continuing; it changes the cost and risk the user approved.

Report

Include: the grep command with before/after hit counts, justification for any remaining hit, gate results (baseline vs final), what you exercised at runtime, and the bugs and out-of-scope improvements you noticed but did not touch.

Domande frequenti

Cosa fa la skill IA Surgical Refactoring?

Refactor/rename/migration discipline — enumerate every call site before the first edit, separate mechanical from judgment edits, keep the build green, verify by absence and presence. Use when asked to rename, extract, move, split, inline, or deduplicate code; for signature/type reshapes; for codebase-wide pattern swaps (replace a helper, swap a library call); for any change touching 3+ call sites. Not for feature work or bug fixes that merely touch many files.

Perché usare Surgical Refactoring su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Surgical Refactoring è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che la skill smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Surgical Refactoring in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/adamentwistle/fable-skills/tree/main/surgical-refactoring. TypingMind legge il file SKILL.md e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Surgical Refactoring?

Qualsiasi modello che colleghi a TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Surgical Refactoring?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Surgical Refactoring: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Surgical Refactoring è gratuita?

Sì. È pubblicata su GitHub da adamentwistle con licenza MIT. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, template o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Elenco completo

Crea subito il tuo spazio di lavoro AI

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇