Skip to content
Skillpedia
General coding33k · #9141

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.md

Copy 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

Use this skill to help me: https://github.com/tirth8205/code-review-graph/blob/staging/skills/refactor-safely/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

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

  1. Call refactor_tool with mode="suggest" for refactoring candidates, or mode="dead_code" for unreferenced code.
  2. For a rename, call refactor_tool with mode="rename", old_name and new_name. Check the returned edit list before applying.
  3. Call apply_refactor_tool with the returned refactor_id to apply the rename.
  4. Before a large refactor, call get_impact_radius_tool and get_affected_flows_tool to see the dependents and critical paths involved.
  5. Call find_large_functions_tool to find functions worth splitting.
  6. After the change, call detect_changes_tool to 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_tool call 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

repo: tirth8205/code-review-graph

Popularity

GitHub stars
33k
Ranking position
#9141
License
MIT
Updated
10/29/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills