Aller au contenu
Skillpedia
Programmation générale70k · #3137

refactor

Ce qu’il fait

Cet outil vous aide à organiser et à améliorer votre code. Il comprend ce que vous souhaitez modifier, analyse les liens entre les différentes parties du code et planifie les changements de façon sûre pour éviter les erreurs.

Quand l’utiliser

  • ✓Lorsque vous voulez simplifier un morceau de code complexe.
  • ✓Lorsque vous devez extraire une partie du code dans un nouveau module.
  • ✓Lorsque vous souhaitez moderniser ou restructurer un ancien projet.

Lien du skill

https://github.com/code-yeongyu/oh-my-openagent/blob/dev/packages/shared-skills/skills/refactor/SKILL.md

Copiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.

Comment l’utiliser

Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.

Message prêt à coller

Utilise ce skill pour m’aider : https://github.com/code-yeongyu/oh-my-openagent/blob/dev/packages/shared-skills/skills/refactor/SKILL.md Lis le fichier SKILL.md de ce lien et suis ses instructions pour ma tâche.
Envie que votre IA trouve seule des skills comme celui-ci ?Installez le MCP gratuit de Skillpedia : une ligne, et elle cherche parmi 15 000+ skills avant chaque tâche.Installer en 1 minute →

Exemple de demande à votre IA

“Refactorisez la fonction de connexion pour utiliser le nouveau modèle d'authentification.”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

L'IA commence par comprendre votre demande et analyse l'ensemble de votre code pour voir comment ses parties sont liées. Ensuite, elle établit un plan détaillé et applique les modifications étape par étape, en vérifiant que tout fonctionne toujours.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis GitHub.

export const REFACTOR_TEMPLATE = `# Intelligent Refactor Command

Usage

``` /refactor <refactoring-target> [--scope=<file|module|project>] [--strategy=<safe|aggressive>]

Arguments: refactoring-target: What to refactor. Can be: - File path: src/auth/handler.ts - Symbol name: "AuthService class" - Pattern: "all functions using deprecated API" - Description: "extract validation logic into separate module"

Options: --scope: Refactoring scope (default: module) - file: Single file only - module: Module/directory scope - project: Entire codebase

--strategy: Risk tolerance (default: safe) - safe: Conservative, maximum test coverage required - aggressive: Allow broader changes with adequate coverage ```

What This Command Does

Performs intelligent, deterministic refactoring with full codebase awareness. Unlike blind search-and-replace, this command:

  1. Understands your intent - Analyzes what you actually want to achieve
  2. Maps the codebase - Builds a definitive codemap before touching anything
  3. Assesses risk - Evaluates test coverage and determines verification strategy
  4. Plans meticulously - Creates a detailed plan with Plan agent
  5. Executes precisely - Step-by-step refactoring with LSP and AST-grep
  6. Verifies constantly - Runs tests after each change to ensure zero regression

PHASE 0: INTENT GATE (MANDATORY FIRST STEP)

BEFORE ANY ACTION, classify and validate the request.

Step 0.1: Parse Request Type

Signal Classification Action
Specific file/symbol Explicit Proceed to codebase analysis
"Refactor X to Y" Clear transformation Proceed to codebase analysis
"Improve", "Clean up" Open-ended MUST ask: "What specific improvement?"
Ambiguous scope Uncertain MUST ask: "Which modules/files?"
Missing context Incomplete MUST ask: "What's the desired outcome?"

Step 0.2: Validate Understanding

Before proceeding, confirm:

  • Target is clearly identified
  • Desired outcome is understood
  • Scope is defined (file/module/project)
  • Success criteria can be articulated

If ANY of above is unclear, ASK CLARIFYING QUESTION:

``` I want to make sure I understand the refactoring goal correctly.

What I understood: [interpretation] What I'm unsure about: [specific ambiguity]

Options I see:

  1. [Option A] - [implications]
  2. [Option B] - [implications]

My recommendation: [suggestion with reasoning]

Should I proceed with [recommendation], or would you prefer differently? ```

Step 0.3: Create Initial Todos

IMMEDIATELY after understanding the request, create todos:

``` TodoWrite([ {"id": "phase-1", "content": "PHASE 1: Codebase Analysis - launch parallel explore agents", "status": "pending", "priority": "high"}, {"id": "phase-2", "content": "PHASE 2: Build Codemap - map dependencies and impact zones", "status": "pending", "priority": "high"}, {"id": "phase-3", "content": "PHASE 3: Test Assessment - analyze test coverage and verification strategy", "status": "pending", "priority": "high"}, {"id": "phase-4", "content": "PHASE 4: Plan Generation - invoke Plan agent for detailed refactoring plan", "status": "pending", "priority": "high"}, {"id": "phase-5", "content": "PHASE 5: Execute Refactoring - step-by-step with continuous verification", "status": "pending", "priority": "high"}, {"id": "phase-6", "content": "PHASE 6: Final Verification - full test suite and regression check", "status": "pending", "priority": "high"} ]) ```


PHASE 1: CODEBASE ANALYSIS (PARALLEL EXPLORATION)

Mark phase-1 as in_progress.

1.1: Launch Parallel Explore Agents (BACKGROUND)

Fire ALL of these simultaneously using `call_omo_agent`:

``` // Agent 1: Find the refactoring target call_omo_agent( subagent_type="explore", run_in_background=true, prompt="Find all occurrences and definitions of [TARGET]. Report: file paths, line numbers, usage patterns." )

// Agent 2: Find related code call_omo_agent( subagent_type="explore", run_in_background=true, prompt="Find all code that imports, uses, or depends on [TARGET]. Report: dependency chains, import graphs." )

// Agent 3: Find similar patterns call_omo_agent( subagent_type="explore", run_in_background=true, prompt="Find similar code patterns to [TARGET] in the codebase.

…

Questions fréquentes

Que signifie « refactoriser » ?

La refactorisation consiste à réorganiser du code existant sans changer son comportement, simplement pour le rendre plus propre, plus efficace ou plus facile à comprendre.

Comment l'IA s'assure-t-elle de ne rien casser ?

Elle analyse la couverture des tests existants et exécute les tests après chaque petite modification pour s'assurer qu'aucune régression n'est apparue.

Puis-je demander de refactoriser un fichier entier ou seulement une partie ?

Oui, vous pouvez préciser si la refactorisation doit porter sur un seul fichier, un module (dossier) ou l'ensemble du projet.

Détails

Description originale de l’auteur

Guides a refactor, cleanup, or restructure with the right decomposition. Use when the user asks to refactor, simplify, extract, or modernize code.

repo: code-yeongyu/oh-my-openagent

Popularité

Étoiles GitHub
70k
Position au classement
#3137
Licence
NOASSERTION
Mis à jour
15/10/2026

Ce skill vous est-il utile ?

0

Connectez-vous pour voter.

Commentaires

  • …

Autres skills de ce dépôt

Skills similaires