Intelligent Refactoring

Perform AST-aware refactoring of Python symbols with dry-run validation and test verification.

Updated Mar 3, 2026
One-click install
npx skills add https://github.com/StrategicMilk/Vetinari-Orchestrastor --skill intelligent-refactoring
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Intelligent Refactoring
Source: https://github.com/StrategicMilk/Vetinari-Orchestrastor/tree/main/vetinari/skills/catalog/worker/intelligent-refactoring
Command: npx skills add https://github.com/StrategicMilk/Vetinari-Orchestrastor --skill intelligent-refactoring

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Intelligent Refactoring prevents unsafe, incomplete, or text-based refactors by using AST-aware tools (LSP rename, find-references, call-hierarchy, ast-grep) to find and update every reference, preserve semantics, and produce traceable change reports so refactors do not break callers, tests, or documentation.

Core Features & Use Cases

  • AST-aware reference discovery: Use LSP find-references and call-hierarchy to enumerate all code locations, type annotations, and call sites.
  • Safe transformations with dry-run: Preview AST-based changes and LSP rename previews before applying any destructive edits.
  • Import chain repair & verification: Update imports, re-exports, and detect circular import risks after moves or extracts.
  • Test-driven validation: Run full or targeted test suites to verify behavior preservation and ensure test counts do not regress.
  • Documentation and consistency updates: Update docstrings, markdown docs, and grep for leftover references in strings and configs.
  • Use cases: Renaming symbols across a repo, extracting shared validators, moving modules between packages, simplifying nested logic, and updating function signatures with all callers.

Quick Start

Run Intelligent Refactoring to rename a symbol across the repository, perform a dry run, repair imports, run tests, and produce a refactoring report.

Frequently Asked Questions about Intelligent Refactoring

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

FAQPage Schema
How do I safely rename a function across a Python codebase without missing references?

AST-aware refactoring uses LSP find-references and call-hierarchy to enumerate all call sites and type annotations before applying changes. This prevents the missed references and broken callers that text-based find-and-replace commonly leaves behind.

How does AST-aware code refactoring handle import chains when moving modules?

AST-aware refactoring repairs import chains by updating imports, re-exports, and detecting circular import risks after modules are moved or shared utilities are extracted. This preserves the dependency graph and prevents runtime import failures.

Can I preview Python refactoring changes before applying them to the repository?

Python refactoring supports safe transformations with dry-run validation, allowing you to preview AST-based changes and LSP rename previews before applying destructive edits. This ensures only verified modifications reach the codebase.

How do I verify behavior preservation after extracting shared utilities or simplifying logic?

Test-driven validation runs full or targeted test suites after refactoring to verify behavior preservation and ensure test counts do not regress. This confirms the semantic meaning remains identical before and after the structural changes.

What is the best way to update documentation and docstrings after renaming symbols?

Documentation updates after symbol renaming involve updating docstrings, markdown docs, and grepping for leftover references in strings and configs. This maintains consistency across code, comments, and project documentation.

When should I avoid text-based find-and-replace for code maintenance?

Text-based find-and-replace should be avoided for code maintenance when updating function signatures, moving modules, or renaming classes, because it misses type annotations and call sites. AST-aware tools are required to preserve semantics and produce traceable refactoring reports.