refactor-safely
What it does
This skill guides the AI agent in refactoring code safely with the code-review-graph tool. It is for developers who want to rename or restructure code without breaking other parts.
When to use it
- ✓When you want to rename a function or class across a codebase.
- ✓When you need to find dead code that nothing references.
- ✓When you are planning to split up large functions and want to see their dependents.
Skill link
https://github.com/tirth8205/code-review-graph/blob/staging/skills/refactor-safely/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Can you rename the function calculateTotal to computeOrderTotal everywhere, and first show me what it will change?”
5 new skills a week. 1 minute to read.
How it works
The agent asks the graph for a rename preview with its list of edits, shows you the list, and applies the change only after confirmation.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Refactor Safely
Plan a refactor from the dependency graph and apply renames from a preview.
Steps
- Call
refactor_toolwithmode="suggest"for refactoring candidates, ormode="dead_code"for unreferenced code. - For a rename, call
refactor_toolwithmode="rename",old_nameandnew_name. Check the returned edit list before applying. - Call
apply_refactor_toolwith the returnedrefactor_idto apply the rename. - Before a large refactor, call
get_impact_radius_toolandget_affected_flows_toolto see the dependents and critical paths involved. - Call
find_large_functions_toolto find functions worth splitting. - After the change, call
detect_changes_toolto confirm the impact matches the plan.
Token Efficiency Rules
- Call
get_minimal_context_tool(task="<your task>")before any other graph tool. - Pass
detail_level="minimal"wherever a tool accepts it. Use "standard" only when minimal is not enough. - Prefer a targeted
query_graph_toolcall over a broad listing call. - Budget: about five tool calls and 800 tokens of graph output per task.
- Read the implementation and its tests before changing code. The graph narrows scope; it does not replace the source.
FAQ
Does it apply changes without a preview?
No. The skill says to check the returned edit list before applying a rename.
Can it find unused code?
Yes. A dead code mode lists code that is not referenced.
What checks come after?
The skill recommends running a change detection step to confirm the impact matches the plan.
Details
Original description by the author
Plan and execute safe refactoring using dependency analysis
Popularity
- GitHub stars
- 33k
- Ranking position
- #9141
- License
- MIT
- Updated
- 10/29/2026
Comments
- …
More skills from this repository
build-graph
33kLets your agent build or update a code knowledge graph of your repository, so later code reviews and searches are faster.
debug-issue
33kHelps your agent trace a bug through a code knowledge graph, following the call chain before reading the source code.
explore-codebase
33kHelps your agent find its way around an unfamiliar codebase by searching the code knowledge graph for modules and relationships.
review-changes
33kHelps your agent review a set of code changes with risk scores, test gaps and the blast radius, grouped by risk level.
Similar skills
diffs
394kLets your agent produce a real, shareable diff of edits as a viewer link or image file, instead of a hand-written summary.
coding-agent
394kHelps your agent hand a larger coding job to Codex, Claude Code, or OpenCode as a background worker, then check on its progress.
gh-issues
394kHelps your agent find GitHub issues, pick the ones to work on, and open pull requests with fixes, including follow-up on review comments.