بنقرة واحدة
do-refactor-code
Analyze a file for refactoring opportunities and apply selected improvements.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Analyze a file for refactoring opportunities and apply selected improvements.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Capture session learnings and save to skills, guidelines, or reference docs under ~/.claude/.
Orchestrate parallel claude -p sessions — bootstrap, launch, monitor, and converge. Works with any skill that produces manifest.json, item directories, and a runner script.
Create a request (pull request or merge request) or update an existing one following project conventions.
Resolve merge or rebase conflicts between branches.
Assess open PRs with unaddressed review comments and generate a parallel addressing script — produces manifest.json and let-it-rip.sh for address-request-comments execution.
Assess open work items and generate a parallel execution script — produces manifest.json and let-it-rip.sh for implement/clarify execution.
| name | do-refactor-code |
| description | Analyze a file for refactoring opportunities and apply selected improvements. |
| disable-model-invocation | true |
| argument-hint | [filepath] |
| allowed-tools | ["Read","Glob","Grep","Edit","Write","Bash"] |
Keywords: refactor, helper class extraction, helper method extraction, nested function extraction, test factory, large file decomposition, file split, dead code, naming, deep nesting, early returns
Analyze a file or class for refactoring opportunities including helper class extraction, helper method extraction, nested function extraction, and test factory creation.
/do-refactor-code <filepath> - Analyze a specific file/do-refactor-code <filepath>:<classname> - Analyze a specific class~/.claude/skill-references/code-quality-checklist.md — Shared checklist of structural issues to look for~/.claude/learnings/refactoring-patterns.md — Refactoring patterns with multi-language examplesRead the target file:
$ARGUMENTS to extract filepath and optional class nameAnalyze using the checklist and structural patterns:
Read ~/.claude/skill-references/code-quality-checklist.md and evaluate the file against each item. Also look for:
Helper Class Extraction opportunities:
inventory_check, inventory_update)Helper Method Extraction opportunities:
Nested/Inner Function Extraction opportunities:
Test Factory opportunities (if test file):
Large File Decomposition (500+ lines):
General structural issues:
Present findings — group by category, with line numbers and specific suggestions:
Found X refactoring opportunities:
**Helper class extraction:**
- Methods `check_inventory`, `update_inventory` at lines 45-80 only use `inventory_levels` field
→ Extract to `InventoryManager` class
**Helper method extraction:**
- Lines 112-118 and 145-151 duplicate DataProcessor creation
→ Extract to `_create_processor(datasets)` helper
**Nested function extraction:**
- `format_value` defined inside `process_data` at line 12
→ Extract to module-level `_format_value` helper
**Test factory opportunities:**
- `Order` objects created in 5 tests with mostly identical fields
→ Create `make_order(**overrides)` factory function
**Module to package extraction:**
- `pipeline.py` (1089 lines) contains distinct sections:
- Constants (lines 667-688)
- Data classes (lines 33-359)
- Utility functions (lines 362-623)
- Main class (lines 787-1089)
→ Split into `pipeline/` package with focused modules
Which refactoring would you like to apply? (Enter number or 'all')
Apply selected refactoring(s):
_ prefix~/.claude/learnings/refactoring-patterns.md for language-specific patterns)Run validation: Execute the project's lint and test commands to verify correctness.