What problem does it solve?
Large-scale, multi-file refactorings are inherently risky, requiring extensive manual testing and careful dependency management. A single missed change can break the entire application. This skill automates dependency analysis, plans safe refactoring orders, and provides automatic rollback, transforming risky refactorings into safe, predictable operations.
Core Features & Use Cases
- Dependency Analysis: Builds a complete dependency graph (imports, function calls) across all affected files, detecting circular dependencies.
- Safe Refactoring Order: Calculates a topological sort to determine a safe execution order for changes, breaking into groups if circular dependencies exist.
- Automated Testing & Rollback: Runs the full test suite after each incremental change (e.g., per file) and automatically reverts all changes if any test fails, ensuring code integrity.
- Impact Report: Provides a clear report on what changed, potential risks, and a risk assessment.
- Use Case: A
code_developer needs to rename a function used in 20 files. Instead of manually changing each file and running tests, they use this skill. It analyzes dependencies, renames the function across all files in a safe order, runs tests after each change, and automatically rolls back if a test fails, reducing manual testing from hours to minutes.
Quick Start
# Analyze dependencies for a set of files
python scripts/dependency_analyzer.py \
--files "coffee_maker/auth/*.py" \
--output deps.json
# Plan a refactoring order based on dependencies
python scripts/refactor_planner.py \
--deps deps.json \
--refactoring-type rename \
--output plan.json