Trace Refactoring Workflow
Safely rename and restructure code across files without breaking cross-file references.
Installation
- Make sure Claude is on your device and in your terminal.
Skills load from
~/.claude/skills/when Claude Code starts up — so you need it on your machine first. If you don't have it yet, install it once with the command below, then runclaudein any terminal to verify.One-time setupnpm i -g @anthropic-ai/claude-codeAlready have it? Skip ahead.
- Paste into Claude Code or into your terminal.
This copies the whole skill folder into
~/.claude/skills/trace-mcp-refactoring-nikolai-vysotskyi/— the SKILL.md plus any scripts, reference docs, or templates the skill ships with. Works for every skill.What this command does
- Makes a new, empty temporary folder.
- Downloads the skill's folder,
skills/trace-mcp-refactoring, fromgithub.com/nikolai-vysotskyi/trace-mcp(branchmaster), the GitHub repository it's listed from. You get the version that is there now, not a copy we keep. - Copies that folder to
~/.claude/skills/trace-mcp-refactoring-nikolai-vysotskyi/. - Deletes the temporary folder.
Installing runs none of the skill's files; it only downloads and copies them. When you later use the skill, Claude follows its SKILL.md and may run scripts that come with it. Read them first.
Faster alternative (instruction-only skills)
Skips the clone and grabs only the SKILL.md file. Don't use this if the skill ships Python scripts, reference markdowns, or asset templates — they won't be downloaded and the skill will fail when it tries to load them.
Quick install (SKILL.md only)Sign up to copy - Restart Claude Code.
Quit and reopen Claude Code (or any other agent that loads from
~/.claude/skills/). New skills are picked up on startup. - Just ask Claude.
Skills auto-activate when your request matches the skill's description — no slash command needed. Trigger phrases live in the skill's own frontmatter; you can read them in the “What this skill does” section above.
Prefer to read the source first? Open on GitHub.
When Claude uses it
Safe refactoring workflow using trace-mcp — assess risk, find candidates, check impact, and rename symbols across all files without missing import sites or cross-file references.
What this skill does
trace-mcp — Refactoring Workflow
Use this skill whenever you are about to rename, restructure, extract, or otherwise refactor code in a project indexed by trace-mcp. The goal is to never break cross-file references and never guess at what is affected.
When to Use
- Renaming a class, function, method, variable, or file
- Extracting a function or method
- Restructuring a module or splitting a file
- Changing a function signature
- Any change that touches more than one call site
Refactoring Workflow
1. Assess before touching anything
assess_change_risk({ file_path: "src/foo.ts" })
# or
assess_change_risk({ symbol_id: "<id>" })
This returns the risk level of the target change based on churn, complexity, fan-in/fan-out, and test coverage. Use it to decide whether to proceed, add tests first, or split the change.
2. Find what actually needs refactoring
get_refactor_candidates()
Do not guess. This surfaces high-complexity, high-churn, and anti-pattern-laden symbols that are the real refactor targets.
3. Know what will break
get_change_impact({ symbol_id: "<id>" })
Returns the reverse-dependency graph: every file, symbol, and test that depends on the target. Review this list before editing.
4. Quantify complexity
get_complexity_report({ file_path: "src/foo.ts" })
Gives you a baseline so you can verify the refactor actually reduced complexity.
Renaming a Symbol — MANDATORY Flow
Never rename with Edit and replace_all. It silently misses import sites, re-exports, type references, and cross-file usages.
# 1. Collision detection first
check_rename({ symbol_id: "<id>", target_name: "newName" })
# 2. Apply rename across ALL files (definition + every reference)
apply_rename({ symbol_id: "<id>", new_name: "newName" })
apply_rename updates the definition, imports, re-exports, call sites, JSX usages, and tests in one atomic operation.
Extracting a Function
extract_function({
file_path: "src/foo.ts",
start_line: 42,
end_line: 67,
new_name: "computeTotals"
})
Let trace-mcp handle the variable capture analysis — manual extraction routinely misses closure variables.
After the Refactor
register_editon each edited file to reindexget_complexity_reportagain to confirm the reductionget_tests_forthe changed symbols — run themcheck_quality_gateswithscope: "changed"to verify no regressions
Related skills
Generative Code Art
anthropics
Create algorithmic art with p5.js using randomness and interactive parameters.
Poster & Visual Design
anthropics
Create original posters and visual art in PNG and PDF formats.
Claude API Helper
anthropics
Build, debug, and optimize Claude API applications with caching and model migration support.
MCP Server Builder
anthropics
Build protocol servers that connect language models to external APIs and services.