Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

refactor-safely — Claude Code skill: what it does, how to install

Plans a refactor from a dependency graph, lists edits before a rename and checks the impact radius before large changes.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add tirth8205/code-review-graph --skill refactor-safely -a claude-code
Open on GitHub

What refactor-safely does

The skill drives a set of dependency-graph tools. refactor_tool with mode="suggest" surfaces refactoring candidates, mode="dead_code" finds unreferenced code, and mode="rename" prepares a rename with an edit list that gets reviewed before apply_refactor_tool applies it. Before a large refactor it calls get_impact_radius_tool and get_affected_flows_tool to show dependents and critical paths, and find_large_functions_tool points to functions worth splitting. After the change, detect_changes_tool checks that the actual impact matches the plan.

A token-efficiency section sets the order: get_minimal_context_tool runs before any other graph tool, detail_level="minimal" is used wherever a tool accepts it, and a targeted query_graph_tool call beats a broad listing. The budget is about five tool calls and 800 tokens of graph output per task. The instructions are explicit that the graph only narrows scope, so reading the implementation and its tests before changing code stays on the checklist.

What it helps with

  • find unreferenced code in a codebase
  • plan a function or variable rename with an edit list reviewed before applying it
  • check the impact radius before a large refactor
  • find large functions worth splitting
  • confirm a change matches the planned impact

Example prompts for the agent

  • Find dead code in the auth module and suggest what to remove
  • Show the impact radius before renaming getUserData
  • Rename getUserData to fetchUserProfile and show the edit list before applying it

How to install refactor-safely

1Skills CLI (Vercel)

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

2Manually: put the files in place

~/.claude/skills/refactor-safely/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/refactor-safely/

From the same set7

The whole set →

Similar

qa garrytan Automate bug hunting in browser, API, CLI, jobs, workers, and webhooks. Searches code, runs commands, checks logs, and asks clarifying questions. Claude Code CX Codex Cursor +1 457installs workers-profiling cloudflare Skill for analyzing CPU and memory usage in deployed Cloudflare Workers and Durable Objects. Finds expensive functions and proposes code optimizations. Claude Code CX Codex Cursor +1 12,100installs code-reviewer https://github.com/Jeffallan Analyzes code diffs and files to spot bugs, security vulnerabilities (SQL injection, XSS), code smells, N+1 queries, and returns a prioritized review report. Use for pull request reviews and code audits. Claude Code CX Codex Cursor +1 6,500installs claude-code Hermes Agent + Teknium Delegates coding tasks to the Claude Code CLI through terminal commands. Useful for running automated refactoring, bug fixes, and tests in one-shot or interactive sessions. Claude Code CX Codex Cursor +1 433installs review-agent-setup Tom Farley This skill gates AI review actions behind manual human approval before pull requests or CI pipelines change. Every attempt generates an Ed25519-signed receipt for offline auditing. Claude Code CX Codex Cursor 5,200installs codebase-inspection Hermes Agent Counts code lines, files, languages, and code-to-comment ratios with pygount. Use it to inspect a repository’s size and composition. Claude Code CX Codex Cursor +1 420installs improve-codebase-architecture Matt Pocock This skill scans a codebase for architectural friction, then builds a visual HTML report with refactoring candidates. Use it before a deeper architecture review. Claude Code 1,163,035installs tdd Matt Pocock Guides the red-green TDD loop: ensures tests are written first, keep them at public interfaces, and avoid coupling to implementation details. Claude Code 1,141,062installs

Questions about refactor-safely

How to install refactor-safely in Claude Code?

Run npx skills add tirth8205/code-review-graph --skill refactor-safely -a claude-code. The skill then lands in ~/.claude/skills/refactor-safely/SKILL.md.

What does refactor-safely do?

It plans a refactor from a dependency graph: finds candidates and dead code, prepares renames with a preview of edits, and shows affected modules before changes get applied.

Do you still need to read the code by hand with this skill?

Yes, the instructions require reading the implementation and its tests before changing code, since the graph narrows scope but does not replace the source.

Source text

SKILL.md · MIT
---
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 · tirth8205/code-review-graph

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor