Refactor Safely

Plans and executes code refactoring using knowledge graph dependency analysis.

Updated May 3, 2017
One-click install
npx skills add https://github.com/arnonmoscona/dot_files --skill refactor-safely-arnonmoscona
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Refactor Safely
Source: https://github.com/arnonmoscona/dot_files/tree/main/claude/projects/toolguard/.claude/skills/refactor-safely
Command: npx skills add https://github.com/arnonmoscona/dot_files --skill refactor-safely-arnonmoscona

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Refactoring code without understanding dependencies risks breaking critical paths and leaving dead code behind. This Skill uses a knowledge graph to analyze impact before changes are applied, so renames and restructuring happen with full visibility into affected locations. ## Core Features & Use Cases - Refactoring Suggestions: Use refactor_tool in suggest mode to get community-driven refactoring recommendations and dead_code mode to find unreferenced code. - Safe Renames: Preview every affected location with rename mode, then apply changes via apply_refactor_tool using the returned refactor_id. - Impact Verification: Check get_impact_radius and get_affected_flows before major refactors, then run detect_changes afterward to confirm the blast radius. - Use Case: Before renaming a core utility function used across services, preview all call sites, verify no critical flows break, apply the rename, and validate the change impact in under five tool calls. ## Quick Start Ask the assistant to safely rename a function across the codebase and verify that no critical flows are affected.

Frequently Asked Questions about Refactor Safely

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely rename a function across a codebase?

Use refactor_tool with mode="rename" to preview every affected location as an edit list, then apply the change with apply_refactor_tool using the returned refactor_id. Always preview before applying to avoid unintended modifications.

How to find dead code in a project?

Run refactor_tool with mode="dead_code" to identify unreferenced code through the knowledge graph. This surfaces functions and modules no longer reachable from any call path.

How do I check refactoring impact before making changes?

Call get_impact_radius to see how far a change propagates and get_affected_flows to confirm no critical execution paths break. After applying changes, run detect_changes to verify the actual impact.

Why start refactoring tasks with get_minimal_context?

get_minimal_context loads only the graph context relevant to your task, keeping token usage low. Combined with detail_level="minimal", it targets completing reviews or refactors within five tool calls and 800 output tokens.

When should I escalate from minimal to standard detail level?

Escalate to detail_level="standard" only when the minimal output lacks enough information to complete the task. The default workflow assumes minimal is sufficient for most review, debug, and refactor operations.