refactor
यह क्या करती है
यह टूल आपके कोड को व्यवस्थित और बेहतर बनाने में मदद करता है। यह समझता है कि आप क्या बदलना चाहते हैं, देखता है कि कोड के हिस्से आपस में कैसे जुड़े हैं, और गलती से बचते हुए बदलाव की योजना सुरक्षित तरीके से बनाता है।
कब इस्तेमाल करें
- ✓जब आप किसी जटिल कोड को सरल बनाना चाहते हों।
- ✓जब आपको कोड के किसी हिस्से को नए मॉड्यूल में निकालना हो।
- ✓जब आप किसी पुराने प्रोजेक्ट को आधुनिक बनाना या उसका ढांचा दोबारा ठीक करना चाहते हों।
Skill का लिंक
https://github.com/code-yeongyu/oh-my-openagent/blob/dev/packages/shared-skills/skills/refactor/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“लॉगिन फ़ंक्शन को नए ऑथेंटिकेशन पैटर्न का उपयोग करने के लिए रीफ़ैक्टर करो।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
AI पहले आपके अनुरोध को समझता है और फिर सारे कोड का विश्लेषण करता है कि हिस्से आपस में कैसे जुड़े हैं। फिर वह एक विस्तृत योजना बनाता है और चरण-दर-चरण बदलाव करता है, हर बार जांचते हुए कि सब कुछ अब भी चल रहा है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे 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:
- Understands your intent - Analyzes what you actually want to achieve
- Maps the codebase - Builds a definitive codemap before touching anything
- Assesses risk - Evaluates test coverage and determines verification strategy
- Plans meticulously - Creates a detailed plan with Plan agent
- Executes precisely - Step-by-step refactoring with LSP and AST-grep
- 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:
- [Option A] - [implications]
- [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.
…
अक्सर पूछे जाने वाले सवाल
'रीफ़ैक्टर' का क्या मतलब है?
रीफ़ैक्टरिंग का मतलब है मौजूदा कोड को बिना उसका काम बदले दोबारा व्यवस्थित करना, ताकि वह साफ़, कुशल या समझने में आसान बने।
AI यह कैसे पक्का करता है कि कुछ टूटे नहीं?
यह मौजूदा टेस्ट कवरेज का विश्लेषण करता है और हर छोटे बदलाव के बाद टेस्ट चलाता है, ताकि कोई चीज़ खराब न हो (इसे रिग्रेशन कहते हैं)।
क्या मैं पूरी फ़ाइल को रीफ़ैक्टर करने को कह सकता हूँ या सिर्फ़ एक हिस्से को?
हाँ, आप बता सकते हैं कि रीफ़ैक्टरिंग एक फ़ाइल में हो, किसी मॉड्यूल (फ़ोल्डर) में हो, या पूरे प्रोजेक्ट में।
जानकारी
लेखक का मूल विवरण
Guides a refactor, cleanup, or restructure with the right decomposition. Use when the user asks to refactor, simplify, extract, or modernize code.
लोकप्रियता
- GitHub स्टार
- 70k
- रैंकिंग में स्थान
- #3137
- लाइसेंस
- NOASSERTION
- अपडेट की गई
- 15/10/2026
कमेंट
- …
इस repository की और skills
comment-checker
70kयह आपके एजेंट को automatic comment checkers के feedback को समझने और उस पर जवाब देने में मदद करता है। automated code या content reviews के नतीजों को प्रोसेस करने में उपयोगी है।
lcx-contribute-bug-fix
70kयह आपके एजेंट को LazyCodex से जुड़े projects में bug fixes देने में मदद करता है। code की गुणवत्ता बनाए रखने के लिए यह issues या pull requests बनाता है।
lcx-doctor
70kयह आपके एजेंट को LazyCodex और Codex CLI installations की स्थिति जांचने देता है। updates या बदलावों के बाद system अजीब व्यवहार करे, तब यह उपयोगी है।
lcx-report-bug
70kयह आपके एजेंट को LazyCodex projects के bugs विस्तार से रिपोर्ट करने में मदद करता है। यह ऐसे issues बनाता है जिनमें developers के लिए समस्या ठीक करने की काम की जानकारी होती है।
मिलती-जुलती skills
diffs
394kयह आपके एजेंट को बदलावों का असली diff बनाने देती है, जिसे व्यूअर लिंक या इमेज फ़ाइल के रूप में साझा किया जा सकता है, हाथ से लिखे सारांश के बजाय।
coding-agent
394kयह आपके एजेंट को बड़े कोडिंग काम Codex, Claude Code या OpenCode को बैकग्राउंड वर्कर के रूप में सौंपने, फिर उसकी प्रगति जांचने में मदद करती है।
gh-issues
394kयह आपके एजेंट को GitHub issues खोजने, उनमें से काम करने लायक चुनने, और सुधार के साथ pull requests खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।