Work with Refactor Plan
Use the refactor plan workflow when you want to scan a codebase for technical debt and produce a prioritized refactoring roadmap with effort estimates and risk levels.
Prerequisites
- Access to the project source code
- The relevant source files:
src/attune/workflows/refactor_plan.pysrc/attune/workflows/refactor_plan_report.py
Run a refactor plan
-
Instantiate
RefactorPlanWorkflow. Import the class fromworkflows.refactor_planand create an instance. The constructor accepts keyword arguments that are forwarded to the underlying subagents (debt-scanner,impact-analyzer, andplan-generator).from workflows.refactor_plan import RefactorPlanWorkflow workflow = RefactorPlanWorkflow() -
Call
execute()with the target path. Pass the path you want to analyze as a keyword argument. The workflow coordinates all three subagents and returns aWorkflowResult.result = workflow.execute(path="src/auth/") -
Format the output. Pass the result and your original input data to
format_refactor_plan_report()to produce a human-readable report.from workflows.refactor_plan_report import format_refactor_plan_report report = format_refactor_plan_report(result, input_data={"path": "src/auth/"}) print(report) -
Or run the CLI entry point directly. Call
main()fromworkflows.refactor_plan_reportto run the full workflow from the command line without writing any Python.
Modify report formatting
-
Open
src/attune/workflows/refactor_plan_report.py. Theformat_refactor_plan_report(result: dict, input_data: dict) -> strfunction is the single place responsible for converting raw workflow output into the final report string. -
Identify the section to change. The report is structured around three sections driven by the workflow output: Summary, Refactoring, and Suggestions. Find the block that renders the section you need to adjust.
-
Edit the formatting logic and verify the signature.
format_refactor_plan_reporttakesresult(thedictreturned byexecute()) andinput_data(the original inputs). Make sure your changes consume only fields present in those arguments. -
Confirm the output looks correct. Call
format_refactor_plan_reportdirectly in a Python shell with a representativeresultdict and inspect the returned string.
Verify success
Run the test suite targeting this feature:
pytest -k "refactor-plan"
All tests pass and format_refactor_plan_report returns a non-empty string that includes a Summary, Refactoring, and Suggestions section for a valid result input.