Skip to main content

AXM Logo

axm-anvil — CST-based refactoring for top-level Python symbols

CI axm-audit axm-init Coverage PyPI Python 3.12+ Docs


Move definitions, rename them in place, or extract them into another module. Anvil uses libcst for transformations, axm-ast for analysis and axm-edit for batched writes. It changes files; it does not prove semantic equivalence.

Features

  • Move top-level definitions into an existing module, rename them in place, or extract them into a new module.
  • Preview a move with cycle enforcement before applying it.
  • Rewrite supported callers and synchronize existing literal __all__ entries.
  • Handle overload groups, conditional imports, local helpers, in-flight renaming and placement.

Installation

Python 3.12+ is required.

uv add axm-anvil
uv run axm-anvil --help

Quick Start

From the project environment where you installed Anvil, create disposable files and preview moving a class:

anvil_demo=$(mktemp -d)
mkdir "$anvil_demo/demo"
printf '' > "$anvil_demo/demo/__init__.py"
printf 'class User:\n    pass\n' > "$anvil_demo/demo/models.py"
printf '' > "$anvil_demo/demo/services.py"
uv run axm-anvil move demo/models.py demo/services.py User \
    --path "$anvil_demo" --check --strict

The command prints a move plan without applying it. The original User stays in models.py. The disposable-file tutorial continues through an applied move and checks that a caller still works.

Usage

Operation Generic CLI / MCP Dedicated CLI
Move into an existing module anvil_move axm-anvil move
Rename in place anvil_rename —
Extract, creating a missing target anvil_extract —

Preview project changes

For existing project files (illustrative paths), preview with cycle enforcement:

uv run axm-anvil move src/mylib/models.py src/mylib/services.py UserService \
    --path . --check --strict

The Python tools return ToolResult; core functions return dataclass plans or raise exceptions. Check success and warnings before interpreting results.

Before applying

Use a clean worktree, review the complete diff, then run project tests and import checks. Batched writes have best-effort rollback, not OS-level multi-file transactions. Move/extract run optional Ruff cleanup after the batch; formatting can change and warnings can accompany success. Extract previews temporarily create a missing target scaffold. There is no Anvil undo token.

Moves support overload groups, existing literal __all__ synchronization, conditional imports, supported module-attribute callers, in-flight renaming and placement. Shared-helper extraction, split, merge, promote and seal are not implemented operations.

Documentation

Development

From the axm-forge workspace root:

uv sync --all-packages --all-groups
uv run --package axm-anvil --directory packages/axm-anvil pytest
uv run --package axm-anvil --directory packages/axm-anvil --group docs mkdocs build --strict

The MkDocs homepage is docs/index.md; this README is a separate entry point.

License

Licensed under Apache-2.0. See LICENSE.

Metadata

Release files for axm-anvil 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for axm-anvil 0.4.1
File Size Uploaded
axm_anvil-0.4.1.tar.gz 124.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for axm-anvil 0.4.1
File Interpreter ABI Platform
axm_anvil-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 198.8 kB

Release files / axm_anvil-0.4.1.tar.gz

Download URL axm_anvil-0.4.1.tar.gz
Size 124.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6e0797ee4ca834203b2cf1dbeb128a1a186a19e5e1da9d87363e8db1ac754888
BLAKE2b-256 checksum
How to use checksums
092b48bef93ed8151181759386bf19258208c09bb0038cc77a85378356765906
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / axm_anvil-0.4.1-py3-none-any.whl

Download URL axm_anvil-0.4.1-py3-none-any.whl
Size 74.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9188e6bfbe878965aa9bd247c9bcce04f617e96843d92229a9f059cbedc74101
BLAKE2b-256 checksum
How to use checksums
ddbd77887c94eda133a7f44bd00cf67a1950de0a818c38f87c75c0f2f1df1319
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page