Graph-It Refactor
Safe two-phase refactoring for changes whose blast radius is larger than one local implementation detail.
Map semantic impact with Graph-It-Live before editing code with the host IDE's native tools.
Valid Phase 1 Opening
When the target file and exported symbol are known, the first Graph-It-Live actions are this exact gate:
1. graphitlive_generate_codemap({ filePath: "/abs/path/to/source.ext", format: "toon" })
2. graphitlive_get_impact_analysis({ filePath: "/abs/path/to/source.ext", symbolName: "ExportedSymbol", format: "toon" })
3. graphitlive_get_symbol_callers({ filePath: "/abs/path/to/source.ext", symbolName: "ExportedSymbol", format: "toon" })
4. graphitlive_crawl_dependency_graph({ filePath: "/abs/path/to/source.ext", format: "toon" })
5. Summarize source files, impacted callers/importers/exports, cycles, and analysis gaps before editing.
If the target file is unknown, first use read-only search or IDE navigation to resolve it. Then run the same gate.
Canonical Graph-It-Live Tools
Use these exact MCP tool names. Do not invent aliases such as find_symbol, find_references, impact_analysis, dependency_impact, validate_references, or refresh_index.
Do not rewrite these names with prefixes or separators such as mcp__graph_it_live__..., graph-it-live..., graph-it-live...., or graph_it_live....
Any refactor plan that names a Graph-It-Live analysis tool outside the four names below is invalid and must be rewritten before continuing.
graphitlive_generate_codemap
graphitlive_get_impact_analysis
graphitlive_get_symbol_callers
graphitlive_crawl_dependency_graph
When to Use
- A refactor touches multiple files or modules.
- An exported function, class, method, type, interface, or package entry point changes name, location, signature, or visibility.
- Code is being moved between files, folders, packages, or layers.
- Dead code removal or dependency reorganization could affect callers, imports, or package exports.
- A complex regression may be caused by call graph, dependency, or module-boundary changes.
Phase 1: Semantic Mapping and Impact Analysis
This phase is read-only. Do not call write-capable tools, formatters, codemods, package managers that mutate files, or shell commands that alter the worktree.
Read-only search commands may be used to locate target files, but they never replace Graph-It-Live evidence.
Pre-Edit Evidence Gate
Before any edit, action plans and tool calls must name all required Graph-It-Live tools and include format: "toon" wherever the tool schema supports it:
| Evidence |
Required tool call |
| Target structure |
graphitlive_generate_codemap with the target file and format: "toon" |
| Exported-symbol blast radius |
graphitlive_get_impact_analysis with target file, symbol name, and format: "toon" |
| Caller confirmation |
graphitlive_get_symbol_callers with target file, symbol name, and format: "toon" |
| Dependency cycles and transitive module effects |
graphitlive_crawl_dependency_graph with the touched entry file or module and format: "toon" |
If any required Graph-It-Live tool is unavailable, blocked, or returns partial evidence, stop before editing and report the gap. Do not replace the missing tool with text search.
Do not add extra Graph-It-Live discovery tools to this gate. Use read-only rg or IDE navigation only to resolve file paths needed by the four canonical tools.
Minimal planned-call shape:
graphitlive_generate_codemap({ filePath: "/abs/path/to/source.ext", format: "toon" })
graphitlive_get_impact_analysis({ filePath: "/abs/path/to/source.ext", symbolName: "ExportedSymbol", format: "toon" })
graphitlive_get_symbol_callers({ filePath: "/abs/path/to/source.ext", symbolName: "ExportedSymbol", format: "toon" })
graphitlive_crawl_dependency_graph({ filePath: "/abs/path/to/source.ext", format: "toon" })
- Generate a codemap for each target file with
graphitlive_generate_codemap.
The planned or executed call must explicitly include format: "toon" whenever the tool supports it.
- For every exported symbol that may change, run
graphitlive_get_impact_analysis.
The planned or executed call must explicitly include format: "toon" whenever the tool supports it.
Then run graphitlive_get_symbol_callers for the same exported symbol unless the tool is unavailable and that blocker is reported.
Caller search with rg, IDE references, or tests is supporting evidence only; it does not satisfy this step.
- Always run
graphitlive_crawl_dependency_graph for the touched area to identify dependency cycles and transitive module effects.
The planned or executed call must explicitly include format: "toon" whenever the tool supports it.
- Before editing, present a concise action plan with:
- source files to modify,
- every caller, importer, dependent symbol, and package export that must be updated,
- cycles, partial-analysis gaps, dynamic-dispatch risks, or public API compatibility risks.
Omitting this plan means Phase 1 is incomplete.
Phase 2: Targeted Editing and Propagation
Start only after Phase 1 is complete and the action plan exists.
- Apply the primary refactor using native editing primitives such as
apply_patch, edit_file, or the IDE's structured edit tools.
- Update each impacted caller, importer, dependent file, and export surface recorded in Phase 1.
- Keep the scope sealed: only modify files identified by the semantic impact analysis, plus tests or generated metadata needed to validate the change.
- Re-run the relevant Graph-It-Live checks after editing when imports, exports, symbols, or module boundaries changed.
- Run the smallest meaningful formatter, typecheck, and test commands for the impacted area.
Strict Rules
| Rule |
Requirement |
| TOON output |
Spell out format: "toon" in every Graph-It-Live plan or call that supports it. |
| No blind editing |
Do not edit before graphitlive_get_impact_analysis has run for each changed exported symbol. |
| Caller completeness |
Treat missing caller/importer evidence as a blocker, not as permission to guess. |
| Sealed scope |
Do not broaden the refactor beyond files and symbols identified during Phase 1. |
| Cycle awareness |
Run dependency graph crawling before every move, deletion, signature change, or module reorganization. |
Common Mistakes
- Running
rg only and assuming text matches are a complete impact analysis.
- Treating impact analysis as optional because the change "looks obvious".
- Inventing Graph-It-Live tool names instead of using the canonical MCP tool names listed above.
- Forgetting
format: "toon" on Graph-It-Live calls and wasting context on larger outputs.
- Writing an action list that says "run Graph-It-Live" without naming the specific tools and TOON format.
- Making dependency crawling conditional on whether earlier results look suspicious.
- Claiming a narrow diff removes the need for impact or cycle analysis.
- Moving a public symbol without checking package exports, barrel files, and compatibility re-exports.
- Editing first, then using Graph-It-Live to justify the diff afterward.
Red Flags
- "This is urgent, just rename it."
- "The references are obvious."
- "Tests are already red, so impact analysis can wait."
- "No need for a full architecture pass."
- "I'll fix imports after the move."
- "The host uses fully qualified MCP names, so I'll rename the tools."
These all mean: stop, complete Phase 1, then edit.
1---2name: graph-it-refactor3description: Use when refactoring multiple files, changing exported signatures or interfaces, moving symbols, deleting dead code, reorganizing dependencies, or fixing complex regressions.4---56# Graph-It Refactor78Safe two-phase refactoring for changes whose blast radius is larger than one local implementation detail.9Map semantic impact with Graph-It-Live before editing code with the host IDE's native tools.1011## Valid Phase 1 Opening1213When the target file and exported symbol are known, the first Graph-It-Live actions are this exact gate:1415```text161. graphitlive_generate_codemap({ filePath: "/abs/path/to/source.ext", format: "toon" })172. graphitlive_get_impact_analysis({ filePath: "/abs/path/to/source.ext", symbolName: "ExportedSymbol", format: "toon" })183. graphitlive_get_symbol_callers({ filePath: "/abs/path/to/source.ext", symbolName: "ExportedSymbol", format: "toon" })194. graphitlive_crawl_dependency_graph({ filePath: "/abs/path/to/source.ext", format: "toon" })205. Summarize source files, impacted callers/importers/exports, cycles, and analysis gaps before editing.21```2223If the target file is unknown, first use read-only search or IDE navigation to resolve it. Then run the same gate.2425## Canonical Graph-It-Live Tools2627Use these exact MCP tool names. Do not invent aliases such as `find_symbol`, `find_references`, `impact_analysis`, `dependency_impact`, `validate_references`, or `refresh_index`.28Do not rewrite these names with prefixes or separators such as `mcp__graph_it_live__...`, `graph-it-live...`, `graph-it-live....`, or `graph_it_live...`.29Any refactor plan that names a Graph-It-Live analysis tool outside the four names below is invalid and must be rewritten before continuing.3031- `graphitlive_generate_codemap`32- `graphitlive_get_impact_analysis`33- `graphitlive_get_symbol_callers`34- `graphitlive_crawl_dependency_graph`3536## When to Use3738- A refactor touches multiple files or modules.39- An exported function, class, method, type, interface, or package entry point changes name, location, signature, or visibility.40- Code is being moved between files, folders, packages, or layers.41- Dead code removal or dependency reorganization could affect callers, imports, or package exports.42- A complex regression may be caused by call graph, dependency, or module-boundary changes.4344## Phase 1: Semantic Mapping and Impact Analysis4546This phase is read-only. Do not call write-capable tools, formatters, codemods, package managers that mutate files, or shell commands that alter the worktree.47Read-only search commands may be used to locate target files, but they never replace Graph-It-Live evidence.4849### Pre-Edit Evidence Gate5051Before any edit, action plans and tool calls must name all required Graph-It-Live tools and include `format: "toon"` wherever the tool schema supports it:5253| Evidence | Required tool call |54| --- | --- |55| Target structure | `graphitlive_generate_codemap` with the target file and `format: "toon"` |56| Exported-symbol blast radius | `graphitlive_get_impact_analysis` with target file, symbol name, and `format: "toon"` |57| Caller confirmation | `graphitlive_get_symbol_callers` with target file, symbol name, and `format: "toon"` |58| Dependency cycles and transitive module effects | `graphitlive_crawl_dependency_graph` with the touched entry file or module and `format: "toon"` |5960If any required Graph-It-Live tool is unavailable, blocked, or returns partial evidence, stop before editing and report the gap. Do not replace the missing tool with text search.61Do not add extra Graph-It-Live discovery tools to this gate. Use read-only `rg` or IDE navigation only to resolve file paths needed by the four canonical tools.6263Minimal planned-call shape:6465```text66graphitlive_generate_codemap({ filePath: "/abs/path/to/source.ext", format: "toon" })67graphitlive_get_impact_analysis({ filePath: "/abs/path/to/source.ext", symbolName: "ExportedSymbol", format: "toon" })68graphitlive_get_symbol_callers({ filePath: "/abs/path/to/source.ext", symbolName: "ExportedSymbol", format: "toon" })69graphitlive_crawl_dependency_graph({ filePath: "/abs/path/to/source.ext", format: "toon" })70```71721. Generate a codemap for each target file with `graphitlive_generate_codemap`.73 The planned or executed call must explicitly include `format: "toon"` whenever the tool supports it.742. For every exported symbol that may change, run `graphitlive_get_impact_analysis`.75 The planned or executed call must explicitly include `format: "toon"` whenever the tool supports it.76 Then run `graphitlive_get_symbol_callers` for the same exported symbol unless the tool is unavailable and that blocker is reported.77 Caller search with `rg`, IDE references, or tests is supporting evidence only; it does not satisfy this step.783. Always run `graphitlive_crawl_dependency_graph` for the touched area to identify dependency cycles and transitive module effects.79 The planned or executed call must explicitly include `format: "toon"` whenever the tool supports it.804. Before editing, present a concise action plan with:81 - source files to modify,82 - every caller, importer, dependent symbol, and package export that must be updated,83 - cycles, partial-analysis gaps, dynamic-dispatch risks, or public API compatibility risks.84 Omitting this plan means Phase 1 is incomplete.8586## Phase 2: Targeted Editing and Propagation8788Start only after Phase 1 is complete and the action plan exists.89901. Apply the primary refactor using native editing primitives such as `apply_patch`, `edit_file`, or the IDE's structured edit tools.912. Update each impacted caller, importer, dependent file, and export surface recorded in Phase 1.923. Keep the scope sealed: only modify files identified by the semantic impact analysis, plus tests or generated metadata needed to validate the change.934. Re-run the relevant Graph-It-Live checks after editing when imports, exports, symbols, or module boundaries changed.945. Run the smallest meaningful formatter, typecheck, and test commands for the impacted area.9596## Strict Rules9798| Rule | Requirement |99| --- | --- |100| TOON output | Spell out `format: "toon"` in every Graph-It-Live plan or call that supports it. |101| No blind editing | Do not edit before `graphitlive_get_impact_analysis` has run for each changed exported symbol. |102| Caller completeness | Treat missing caller/importer evidence as a blocker, not as permission to guess. |103| Sealed scope | Do not broaden the refactor beyond files and symbols identified during Phase 1. |104| Cycle awareness | Run dependency graph crawling before every move, deletion, signature change, or module reorganization. |105106## Common Mistakes107108- Running `rg` only and assuming text matches are a complete impact analysis.109- Treating impact analysis as optional because the change "looks obvious".110- Inventing Graph-It-Live tool names instead of using the canonical MCP tool names listed above.111- Forgetting `format: "toon"` on Graph-It-Live calls and wasting context on larger outputs.112- Writing an action list that says "run Graph-It-Live" without naming the specific tools and TOON format.113- Making dependency crawling conditional on whether earlier results look suspicious.114- Claiming a narrow diff removes the need for impact or cycle analysis.115- Moving a public symbol without checking package exports, barrel files, and compatibility re-exports.116- Editing first, then using Graph-It-Live to justify the diff afterward.117118## Red Flags119120- "This is urgent, just rename it."121- "The references are obvious."122- "Tests are already red, so impact analysis can wait."123- "No need for a full architecture pass."124- "I'll fix imports after the move."125- "The host uses fully qualified MCP names, so I'll rename the tools."126127These all mean: stop, complete Phase 1, then edit.