
Refactor Safely
- 807 installs
- 28.5k repo stars
- Updated August 2, 2026
- tirth8205/code-review-graph
Refactor Safely is a Claude Code skill that plans and applies codebase refactors using the code-review-graph knowledge graph so developers can preview rename blast radius and verify impact before committing changes.
About
Refactor Safely is a skill in tirth8205/code-review-graph that wires agents to dependency-analysis graph tools for low-surprise refactors. The workflow starts with get_minimal_context, then runs refactor_tool in suggest, dead_code, or rename modes to surface community suggestions, unreferenced code, and full edit lists before any write. apply_refactor_tool commits renames by refactor_id, and detect_changes_tool validates post-change impact alongside get_impact_radius_tool and get_affected_flows_tool. Token-efficiency rules target completing review or refactor tasks in five or fewer tool calls and under 800 output tokens using detail_level minimal. Reach for Refactor Safely when renaming across packages, pruning dead paths, or decomposing large functions where grep alone misses cross-file callers. Refactor Safely pairs with get_impact_radius_tool before major structural changes and find_large_functions to locate decomposition targets. Safety checks insist on preview-before-apply for every rename so agents never commit blind cross-package edits that break critical flows surfaced by get_affected_flows_tool.
- 5-step refactoring workflow using suggest, dead_code, rename, and apply modes
- Always begins with get_minimal_context to reduce token usage
- Safety checks include get_impact_radius, get_affected_flows, and find_large_functions
- Preview all changes before applying with rename mode edit lists
- Target: complete any refactor in ≤5 tool calls and ≤800 output tokens
Refactor Safely by the numbers
- 807 all-time installs (skills.sh)
- Ranked #175 of 1,352 Code Review & Quality skills by installs in the Skillselion catalog
- Security screen: LOW risk (skills.sh audit)
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/tirth8205/code-review-graph --skill refactor-safelyAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 807 |
|---|---|
| repo stars | ★ 28.5k |
| Security audit | 3 / 3 scanners passed |
| Last updated | August 2, 2026 |
| Repository | tirth8205/code-review-graph ↗ |
How do you refactor code safely with dependency graphs?
Plan and execute code refactors with zero surprise breakage by leveraging a project knowledge graph.
Who is it for?
Backend or full-stack developers refactoring a mapped repository who already use the code-review-graph MCP server.
Skip if: Developers without the code-review-graph MCP installed or teams needing only stylistic lint fixes with no structural dependency analysis.
When should I use this skill?
User asks to rename symbols, remove dead code, decompose large functions, or refactor with graph-backed impact preview.
What you get
Rename edit lists, dead-code reports, applied refactors, and detect_changes_tool impact verification.
- rename edit preview list
- applied refactor commits
- post-refactor impact report
By the numbers
- Targets ≤5 tool calls and ≤800 output tokens per refactor task
- Supports refactor_tool modes: suggest, dead_code, and rename
Files
Refactor Safely
Use the knowledge graph to plan and execute refactoring with confidence.
Steps
1. Use refactor_tool with mode="suggest" for community-driven refactoring suggestions. 2. Use refactor_tool with mode="dead_code" to find unreferenced code. 3. For renames, use refactor_tool with mode="rename" to preview all affected locations. 4. Use apply_refactor_tool with the refactor_id to apply renames. 5. After changes, run detect_changes_tool to verify the refactoring impact.
Safety Checks
- Always preview before applying (rename mode gives you an edit list).
- Check
get_impact_radius_toolbefore major refactors. - Use
get_affected_flows_toolto ensure no critical paths are broken. - Run
find_large_functionsto identify decomposition targets.
Token Efficiency Rules
- ALWAYS start with
get_minimal_context(task="<your task>")before any other graph tool. - Use
detail_level="minimal"on all calls. Only escalate to "standard" when minimal is insufficient. - Target: complete any review/debug/refactor task in ≤5 tool calls and ≤800 total output tokens.
Related skills
How it compares
Pick Refactor Safely over plain grep refactors when cross-file dependency chains and rename blast radius matter.
FAQ
What tools does Refactor Safely use?
Refactor Safely orchestrates code-review-graph MCP tools: refactor_tool (suggest, dead_code, rename), apply_refactor_tool, detect_changes_tool, get_impact_radius_tool, and get_affected_flows_tool. Always start with get_minimal_context at detail_level minimal.
Must renames be previewed before applying?
Refactor Safely requires preview-before-apply: refactor_tool mode rename returns a full edit list, then apply_refactor_tool uses the refactor_id. Skipping preview risks breaking callers the graph would have surfaced.