Serena Safe Refactoring
Cross-Codebase Rename
code
rename_symbol(old_name="calcTax", new_name="calculate_tax")
- •Updates ALL references automatically
- •Works across files
- •Handles imports/exports
Replace Function Body
code
replace_symbol_body(symbol_name="process_payment", new_body="...")
- •Preserves function signature
- •Safer than text replacement
- •Maintains formatting
Pre-Refactoring Checklist
- •
Check impact:
codefind_referencing_symbols("function_to_change")Review all affected locations before changing.
- •
Verify tests exist:
codefind_symbol("test_function_to_change") - •
Run tests after:
bashpytest tests/test_module.py -v
Common Patterns
Rename Function
code
find_referencing_symbols("old_name") # Check impact
rename_symbol(old_name="old_name", new_name="new_name")
# Run tests
Replace Implementation
code
find_symbol("function_name", include_body=true) # See current
replace_symbol_body("function_name", new_body="...")
# Run tests
Safety Notes
- •Always check references before renaming
- •Run tests after each refactoring step
- •Document patterns in Serena memory for future reference