LLM Skills
~/catalogue/debugging et maintenance//refactor.prompt

Refonte et nettoyage

/refactor.prompt

Améliorer la structure interne du code sélectionné sans modifier son comportement observable. Tous les tests doivent être réussis avant et après.

affaan-maffaan-m
252.2k
4 juin 2026
MIT
// contenu du skill

agent: agent

description: Clean up dead code, reduce duplication, and simplify structure without changing behavior


Refactor & Cleanup

Improve the internal structure of the selected code without changing its observable behavior. All tests must pass before and after.

Before Starting

  • [ ] Confirm the test suite is passing.
  • [ ] Note the current coverage baseline.
  • [ ] Identify the scope: single function, file, or module?

Refactoring Targets

Dead Code Removal

  • Unused variables, imports, functions, and exports
  • Commented-out code blocks (delete, don't leave as comments)
  • Feature flags that are permanently enabled/disabled
  • Unreachable branches

Duplication Reduction

  • Repeated logic that can be extracted into a shared utility
  • Copy-pasted blocks differing only in a parameter (extract with that parameter)
  • Inline constants that appear in multiple places (extract to named constants)

Structure Improvements

  • Functions over 50 lines → break into smaller, named steps
  • Files over 800 lines → extract cohesive sub-modules
  • Nesting deeper than 4 levels → extract early-return guards or helper functions
  • Mixed concerns in one function → split into focused single-responsibility functions

Naming

  • Rename variables/functions whose names don't match their behavior
  • Replace magic numbers and strings with named constants
  • Align naming with the domain language used elsewhere in the codebase

Constraints

  • No behavior changes — refactoring is purely structural.
  • One concern at a time — do not mix refactoring with feature work or bug fixes.
  • Keep tests green — run the suite after each meaningful change.
  • Don't add abstractions preemptively — extract only what has already proven to be duplicated (rule of three).

Output

After refactoring, summarize:

  • What was removed (dead code, duplication)
  • What was extracted (new utilities, constants)
  • What was renamed and why
  • Coverage before / after (should not decrease)
// source originale publique
affaan-m/ECC
/.github/prompts/refactor.prompt.md
Licence : MIT
Projet indépendant, non affilié à Anthropic. Ce skill reste la propriété de son auteur original.
// installer ce skill
Collez cette commande dans votre terminal à la racine de votre projet :
mkdir -p .claude/commands && curl -o ".claude/commands/refactor.prompt.md" "https://raw.githubusercontent.com/affaan-m/ECC/main/.github/prompts/refactor.prompt.md"
Ensuite dans Claude Code, tapez /refactor.prompt pour l'activer.
open_in_newVoir la source originale
// sauvegarder
Sauvegarde disponible après connexion.
loginSe connecter pour sauvegarder
// informations
Créateuraffaan-m
Étoiles 252.2k
LicenceMIT
Mis à jour4 juin 2026
Format.md
AccèsGratuit
// similaires

Skills Debugging et maintenance

Voir toutarrow_forward