Code Refactoring Assistant
This skill is a comprehensive tool for safe code refactoring. It analyzes codebase changes by impact scope, creates prioritized checklists, facilitates user review, executes approved refactors, performs quality assurance, and generates before/after reports with metrics.
Distinguished from priority optimizers: Focuses on impact scope (files/modules/deps/tests) rather than business priority, with richer interactive review (yes/no/back/feedback).
Capabilities
- Impact Analysis: Assess refactoring scope (low: <5 files/local; medium: 5-20 files/module; high: >20 files/cross-module/deps)
- Checklist Generation: Structured lists grouped by impact, with risks and benefits
- Interactive Review: yes/no/back/other feedback per item
- Refactor Execution: Apply changes to files with git diffs
- QA Validation: Check style, tests, coverage, performance
- Reporting: Before/after comparisons, metrics delta, visualizations
Input Requirements
JSON format:
codebase: {files: [{path, lines, deps}], tests: [...], goals: ["improve modularity", "reduce complexity"]}
metrics: Optional baseline (coverage %, perf ms)
- Data from Claude tools (Glob/Grep/Bash git status)
Quality: Accurate file lists, recent git state.
Output Formats
checklist.json: Items with id/impact/desc/risks
review_decisions.json: User choices per item
changes.diff: Executed diffs
qa_report.json: Pass/fail metrics
final_report.md: Full comparison (tables, charts)
How to Use
@[code-refactoring-assistant] Analyze current repo for low-impact refactors to improve modularity, then review checklist.
Scripts
refactoring_assistant.py: Orchestrates 6 core classes (ImpactAnalyzer, RefactoringPlanner, ReviewInterface, RefactoringExecutor, QAValidator, RefactoringReporter)
Best Practices
- Start with low-impact items
- Backup repo (git stash/branch) before execution
- Provide test paths for accurate QA
- Review high-impact manually
- Iterate: Refactor → QA → Report → Re-analyze
Limitations
- Relies on Claude tools for real file access (no direct FS write)
- Simulated execution in samples; real uses git/Bash tools
- Complex deploys need human oversight
- Python sandbox limits (no external libs beyond std)
1---2name: code-refactoring-assistant3description: Analyzes codebases by impact scope (low/medium/high), generates refactoring checklists, supports interactive review, executes refactors with QA, and produces detailed optimization reports.4---5
6# Code Refactoring Assistant
7
8This skill is a comprehensive tool for safe code refactoring. It analyzes codebase changes by impact scope, creates prioritized checklists, facilitates user review, executes approved refactors, performs quality assurance, and generates before/after reports with metrics.
9
10Distinguished from priority optimizers: Focuses on *impact scope* (files/modules/deps/tests) rather than business priority, with richer interactive review (yes/no/back/feedback).
11
12## Capabilities
13
14- **Impact Analysis**: Assess refactoring scope (low: <5 files/local; medium: 5-20 files/module; high: >20 files/cross-module/deps)
15- **Checklist Generation**: Structured lists grouped by impact, with risks and benefits
16- **Interactive Review**: yes/no/back/other feedback per item
17- **Refactor Execution**: Apply changes to files with git diffs
18- **QA Validation**: Check style, tests, coverage, performance
19- **Reporting**: Before/after comparisons, metrics delta, visualizations
20
21## Input Requirements
22
23JSON format:
24- `codebase`: {`files`: [{`path`, `lines`, `deps`}], `tests`: [...], `goals`: ["improve modularity", "reduce complexity"]}
25- `metrics`: Optional baseline (coverage %, perf ms)
26- Data from Claude tools (Glob/Grep/Bash git status)
27
28Quality: Accurate file lists, recent git state.
29
30## Output Formats
31
32- `checklist.json`: Items with id/impact/desc/risks
33- `review_decisions.json`: User choices per item
34- `changes.diff`: Executed diffs
35- `qa_report.json`: Pass/fail metrics
36- `final_report.md`: Full comparison (tables, charts)
37
38## How to Use
39
40@[code-refactoring-assistant] Analyze current repo for low-impact refactors to improve modularity, then review checklist.
41
42## Scripts
43
44- `refactoring_assistant.py`: Orchestrates 6 core classes (ImpactAnalyzer, RefactoringPlanner, ReviewInterface, RefactoringExecutor, QAValidator, RefactoringReporter)
45
46## Best Practices
47
481. Start with low-impact items
492. Backup repo (git stash/branch) before execution
503. Provide test paths for accurate QA
514. Review high-impact manually
525. Iterate: Refactor → QA → Report → Re-analyze
53
54## Limitations
55
56- Relies on Claude tools for real file access (no direct FS write)
57- Simulated execution in samples; real uses git/Bash tools
58- Complex deploys need human oversight
59- Python sandbox limits (no external libs beyond std)