Agent skill

Graph-Guided Safe Refactoring

by tirth8205 in tirth8205/code-review-graph

Plans a refactor from a code dependency graph, previews renames before applying them and checks that the final impact matches the plan.

MITAuto-check passedDevelopment

Install Graph-Guided Safe Refactoring

skills CLI
$ npx skills add tirth8205/code-review-graph --skill refactor-safely -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install tirth8205/code-review-graph refactor-safely --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/tirth8205/code-review-graph.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/refactor-safely .claude/skills/refactor-safely && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
refactor-safely
GitHub stars
32k
Used in
1 other repo
Token cost
~332 tokens
SKILL.md length
164 words
Files
1
Skills in repo
7
Repo updated
First seen
Licence
MIT

At a glance

Plans a refactor from a code dependency graph, previews renames before applying them and checks that the final impact matches the plan.

  • Works in 6 steps: Call refactor_tool with mode="suggest"… → For a rename, call refactor_tool with… → Call apply_refactor_tool with the… → …
  • Renaming a symbol across a codebase with a reviewable edit list
  • SKILL.md covers Refactor Safely and Token Efficiency Rules
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

The skill works through the tools of a code-graph server. For ideas it calls `refactor_tool` in suggest mode to list refactoring candidates, or in dead-code mode to find unreferenced code, and `find_large_functions_tool` points out functions worth splitting. For a rename it calls `refactor_tool` with the old and new names, checks the returned edit list, and then applies it with `apply_refactor_tool` using the returned refactor ID.

Before a large change it looks at the impact radius and affected flows to see dependents and critical paths, and afterwards it runs `detect_changes_tool` to confirm the real impact matches the plan. The skill also sets a token budget: start with `get_minimal_context_tool`, ask for minimal detail wherever a tool allows, prefer targeted graph queries to broad listings, keep to about five tool calls and 800 tokens of graph output per task, and still read the implementation and its tests before editing, since the graph narrows scope but does not replace the source.

When your agent uses it

  • Renaming a symbol across a codebase with a reviewable edit list
  • Finding dead code or oversized functions worth cleaning up
  • Estimating what a large refactor will touch before starting

Example prompts

  • “Rename parseConfig to loadConfig everywhere, and show me the edit list before applying it.”
  • “Find unreferenced code in the services package.”
  • “Before I split this module, show which callers and flows depend on it.”

Requirements

  • The code-review-graph MCP server with a built graph of the repository

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  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.

What it can do on your machine

Read from SKILL.md and the folder at commit 6b12d11. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Graph-Guided Safe Refactoring loads about 332 tokens when it runs. Until then it costs about 19 tokens; SKILL.md has 164 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~19
When it runs · the whole SKILL.md, loaded when a task matches
~332

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from tirth8205/code-review-graph at commit 6b12d11, republished under its MIT licence (© tirth8205). 164 words, ~332 tokens.

Download SKILL.mdSave it as .claude/skills/refactor-safely/SKILL.md (or your agent's skills folder).
name
refactor-safely
description
Plan and execute safe refactoring using dependency analysis

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.

© tirth8205, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/refactor-safely of tirth8205/code-review-graph.

Open the folder on GitHubat commit 6b12d11

Used in 1 other repository

We found 2 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in tirth8205/code-review-graph, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Graph-Guided Safe Refactoring next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Graph-Guided Safe Refactoring compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Graph-Guided Safe Refactoring this skilltirth8205/code-review-graph32k1 repos~332Automated safety check: PassMIT
Refactortermide/termide171—~2.8kAutomated safety check: PassMIT
Trace-MCP Refactoringnikolai-vysotskyi/trace-mcp185—~672Automated safety check: PassMIT
Codehealth MCPaffaan-m/ECC274k1 repos~1.8kAutomated safety check: PassMIT
ast-grep Structural Searchcode-yeongyu/oh-my-openagent70k—~3.3kAutomated safety check: PassMIT
Systematic Code Refactoringluongnv89/claude-howto42k—~3kAutomated safety check: PassMIT

Similar skills

  • Refactor

    termide/termide

    Full-workspace code quality analysis and refactoring with validation

    171 GitHub stars~2.8k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Trace-MCP Refactoring

    nikolai-vysotskyi/trace-mcp

    Refactors code safely in projects indexed by trace-mcp: assess risk, find candidates, check impact and rename symbols across every file without missing a reference.

    185 GitHub stars~672 tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Codehealth MCP

    affaan-m/ECC

    Real-time structural Code Health via CodeScene MCP — review before edits, verify score deltas after changes, gate commits and PRs.

    274k GitHub starsUsed in 1 repo~1.8k tokens
    DevelopmentAuto-check passed
  • ast-grep Structural Search

    code-yeongyu/oh-my-openagent

    Searches and rewrites code by syntax-tree shape across 25 languages with ast-grep, for codemods, structural queries and YAML lint rules, using a Python wrapper script.

    70k GitHub stars~3.3k tokensUpdated today
    DevelopmentAuto-check passed
  • Systematic Code Refactoring

    luongnv89/claude-howto

    Guides refactoring in phases based on Martin Fowler's method: research, test coverage check, planning and small tested steps, with your approval at each phase.

    42k GitHub stars~3k tokensUpdated 7 days ago
    DevelopmentAuto-check passed
  • Dignified Python Standards

    docling-project/docling

    Applies opinionated production Python conventions chosen by the project's Python version: modern type syntax, pathlib, explicit checks and interface guidance.

    68k GitHub stars~1.5k tokensUpdated yesterday
    DevelopmentAuto-check passed

More from tirth8205/code-review-graph

  • Knowledge Graph PR Review

    tirth8205/code-review-graph

    Reviews a pull request or branch diff with a code knowledge graph and produces a structured review that includes blast-radius analysis.

    32k GitHub stars~452 tokensUpdated yesterday
    Auto-check passed
  • Graph-Based Bug Tracing

    tirth8205/code-review-graph

    Traces a bug through a code knowledge graph, following callers, callees and execution flow before opening source files, within a small token budget.

    32k GitHub starsUsed in 1 repo~287 tokens
    Auto-check passed
  • Explore Codebase with Graph

    tirth8205/code-review-graph

    Navigates a codebase through the code-review-graph MCP tools: architecture overview, symbol search, caller and callee tracing, flows and oversized functions.

    32k GitHub starsUsed in 1 repo~335 tokens
    Auto-check passed
  • Graph-Based Change Review

    tirth8205/code-review-graph

    Reviews a change set using a code knowledge graph for risk scores, blast radius and test gaps, and ends with a merge recommendation.

    32k GitHub starsUsed in 1 repo~331 tokens
    Auto-check passed
  • Code Review Graph Builder

    tirth8205/code-review-graph

    Builds or incrementally updates the code-review knowledge graph for a repository and reports whether the build succeeded, partly or failed.

    32k GitHub stars~295 tokensUpdated yesterday
    Auto-check passed
  • Review Delta

    tirth8205/code-review-graph

    Reviews only the code changed since the last commit, using a code-graph MCP server to find risk-scored changes, test gaps and the blast radius, then writes a short report.

    32k GitHub stars~325 tokensUpdated yesterday
    Auto-check passed

Categories

Questions about Graph-Guided Safe Refactoring

What does Graph-Guided Safe Refactoring do?

Plans a refactor from a code dependency graph, previews renames before applying them and checks that the final impact matches the plan. The skill works through the tools of a code-graph server. For ideas it calls `refactor_tool` in suggest mode to list refactoring candidates, or in dead-code mode to find unreferenced code, and `find_large_functions_tool` points out functions worth splitting.

When should I use Graph-Guided Safe Refactoring?

Graph-Guided Safe Refactoring fits situations like: renaming a symbol across a codebase with a reviewable edit list; finding dead code or oversized functions worth cleaning up; estimating what a large refactor will touch before starting.

How do I install Graph-Guided Safe Refactoring in Claude Code?

Run `npx skills add tirth8205/code-review-graph --skill refactor-safely -a claude-code`. Or copy the skill folder (skills/refactor-safely in tirth8205/code-review-graph) into .claude/skills/refactor-safely in your project. Claude Code loads it when a task matches its description.

How do I install Graph-Guided Safe Refactoring in Codex?

Run `npx skills add tirth8205/code-review-graph --skill refactor-safely -a codex`. Or copy the skill folder (skills/refactor-safely in tirth8205/code-review-graph) into .agents/skills/refactor-safely in your project. Codex loads it when a task matches its description.

Can I use Graph-Guided Safe Refactoring in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add tirth8205/code-review-graph --skill refactor-safely -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/refactor-safely, .gemini/skills/refactor-safely, .github/skills/refactor-safely and .opencode/skills/refactor-safely in your project.

What does Graph-Guided Safe Refactoring need to run?

SKILL.md names no scripts, command-line tools or credentials: Graph-Guided Safe Refactoring is instructions for the agent only. Our summary lists: The code-review-graph MCP server with a built graph of the repository.

Does Graph-Guided Safe Refactoring access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Graph-Guided Safe Refactoring safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Graph-Guided Safe Refactoring use?

Graph-Guided Safe Refactoring is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Graph-Guided Safe Refactoring use?

About 332 tokens (SKILL.md is roughly 1.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Graph-Guided Safe Refactoring?

Skills that share tags, products or a category with Graph-Guided Safe Refactoring: Refactor (termide/termide, 171 stars), Trace-MCP Refactoring (nikolai-vysotskyi/trace-mcp, 185 stars), Codehealth MCP (affaan-m/ECC, 274k stars) and ast-grep Structural Search (code-yeongyu/oh-my-openagent, 70k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Graph-Guided Safe Refactoring?

tirth8205 (a GitHub user) maintains it in tirth8205/code-review-graph, which has 31,943 GitHub stars. The repository holds 7 skills in this directory. The repository was last updated on October 6, 2026.

Source: tirth8205/code-review-graph on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.