Overview
Refactron provides intelligent refactoring suggestions with safety previews, risk scoring, and automated fixes. All refactorings include backup and rollback capabilities.Basic Refactoring
Preview Changes
Always preview refactoring suggestions before applying:Apply Refactoring
Apply all suggested refactorings:Available Refactorers
Extract Method
Extract Method
Extracts a logically distinct block of statements from a long function into a new named function, reducing function length and improving readability
Extract Constant
Extract Constant
Replaces magic numbers with named constants
Add Docstring
Add Docstring
Adds missing docstrings to functions and classes
Simplify Conditionals
Simplify Conditionals
Refactors complex conditional expressions
Reduce Parameters
Reduce Parameters
Reduces function parameters using dataclasses or dicts
Risk Levels
Refactoring suggestions include risk scores:Safe (0.0)
Formatting, imports only
Low (0.1-0.2)
Documentation, constants
Moderate (0.3-0.5)
Logic changes
High (0.6-1.0)
Complex transformations
Filter by Risk Level
Specific Refactorings
Apply only specific types of refactoring:Python API
Auto-Fix
Theautofix command applies safe, automated fixes:
Backup and Rollback
Every refactoring creates automatic backups:List Rollback Sessions
Rollback Specific Session
Python API Rollback
Refactoring Workflow
Configuration
Configure refactoring behavior in.refactron.yaml:
.refactron.yaml
Pattern Learning Integration
Refactron learns from your refactoring decisions:Learn more about pattern learning in the Pattern Learning Guide
Best Practices
Always Preview First
Always Preview First
Use
--preview to see changes before applying themUse Version Control
Use Version Control
Commit your code before refactoring for easy rollback
Test After Refactoring
Test After Refactoring
Run your test suite after applying refactorings
Start with Low Risk
Start with Low Risk
Begin with safe refactorings, then gradually increase risk tolerance
Refactor Incrementally
Refactor Incrementally
Refactor small portions at a time rather than entire codebase
Next Steps
AI Features
Explore AI-powered refactoring
Pattern Learning
Learn how Refactron improves over time
