| name | ide-refactor |
| description | Safe refactoring with snapshot rollback. Creates a checkpoint, performs the refactoring using LSP rename and code actions, runs tests, and rolls back automatically if anything breaks. |
| disable-model-invocation | true |
| effort | high |
| argument-hint | [description of refactoring] |
IDE Safe Refactor Workflow
Prerequisites
- Check if the
getToolCapabilities MCP tool is available to you.
-
Not available (no MCP tool by that name): stop and tell the user:
"This skill requires the Claude IDE Bridge with a connected VS Code extension. It uses LSP tools (rename symbol, code actions, references, snapshots) that have no CLI equivalent.
To use this skill:
- Start the bridge:
npm run start-all (in claude-ide-bridge/)
- Ensure the Claude IDE Bridge extension is installed in your IDE
- Use the
claude --ide session (not remote-control)"
-
Available: call it. If extensionConnected is false: show the same message. If true: proceed.
Perform refactoring with a safety net. Uses snapshots for instant rollback if tests fail after the change.
Workflow
Phase 1: Checkpoint
- Use
createSnapshot with name "pre-refactor" to capture current workspace state
- Confirm: "Snapshot created. Starting refactoring: $ARGUMENTS"
Phase 2: Plan the refactoring
- Analyze what needs to change based on the description:
$ARGUMENTS
- Use
searchWorkspace and getDocumentSymbols to identify all affected symbols
- Use
findReferences to map the impact across the codebase
- Use
getCallHierarchy to understand dependency chains
- List all files that will be affected and confirm the plan
Phase 3: Execute the refactoring
For symbol renames:
8. Use renameSymbol — this handles all references across the workspace via LSP
For structural changes:
9. Use getCodeActions to check if VS Code has automated refactorings available
10. Use applyCodeAction for supported refactorings (extract method, extract variable, etc.)
11. Use editText for manual structural changes
Phase 4: Clean up
- Use
organizeImports on every modified file
- Use
formatDocument on every modified file
- Use
getDiagnostics to check for new errors introduced by the refactoring
Phase 5: Verify
- Use
runTests to run the full test suite
- If all tests pass:
- Report success with a summary of changes
- The snapshot remains available for manual rollback if needed later
- If tests fail:
- Use
diffSnapshot with "pre-refactor" to show exactly what changed
- Ask: "Tests failed. Would you like me to roll back?"
- If yes: use
restoreSnapshot with "pre-refactor" to instantly revert
- If no: report which tests failed and why, so you can fix manually
Phase 6: Summary
- Report:
- What was refactored
- How many files changed
- Symbol renames performed
- Code actions applied
- Test results
- Whether the snapshot was used for rollback
Guidelines
- Always create a snapshot before any changes
- Prefer
renameSymbol over manual find-and-replace — it handles all language-aware references
- Check for string references that LSP rename won't catch (config files, comments, documentation)
- If the refactoring is too large, suggest breaking it into smaller steps