axm-anvil
Deterministic CST-based refactoring toolkit for Python — move, rename, split, merge symbols atomically across files.
Installation
Quick Start
Move a class and a private helper into another module, previewing first:
Bash
axm-anvil move src/mylib/models.py src/mylib/services.py \
UserService,_validate_input --dry-run
Features
- 🔨 Deterministic moves — Classes, functions, and constants moved with transitive dependency resolution (imports, constants, helpers), formatting preserved exactly via libcst
- ✏️ Rename in flight —
--rename '{"Old": "New"}'rewrites the definition, every reference,__all__, and string forward-references - 📍 Placement control —
--insert-aftersplices moved blocks after a named symbol;--no-include-helpersskips copying local helpers - 🧭 Edge-case aware —
__all__sync, conditional-import preservation, relative→absolute import conversion on cross-package moves, and warnings for side-effect decorators, string forward-refs, and pytest fixture-scope breaks - 🛡️ Atomic & safe — All edits computed in memory, validated, then written all-or-nothing; new import cycles are detected via
--check