Skip to main content

AXM Logo

axm-edit — Validated batch file editing for AXM agents and Python callers

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


batch_edit replaces, creates, deletes and rewrites files in one request. It validates before writing and snapshots the target paths for automatic rollback on apply failure. Apply and recovery are best-effort filesystem operations, not an OS transaction or a lock against concurrent writers.

Features

  • Whole-line replacement, file creation, deletion and checksum-guarded rewrite.
  • Batch validation before writing and targeted snapshots for recovery.
  • Read-only batch checks and file inspection, search and listing tools.
  • Python API and registered tools for the unified AXM CLI and MCP server.

Installation

uv add axm-edit
uv run axm batch_edit --help

Python 3.12+ is required. The dependency axm supplies the generic CLI; there is no separate axm-edit executable. Install axm-mcp in the same environment to expose the registered axm.tools to an MCP client.

Quick Start

This self-contained Python example changes only a temporary directory. The root API does not run the tool's preflight or post-edit Ruff pass. Save it as example.py and run uv run python example.py after installation.

from pathlib import Path
from tempfile import TemporaryDirectory

from axm_edit import CreateOp, Edit, ReplaceOp, batch_apply, rollback

with TemporaryDirectory() as directory:
    root = Path(directory)
    (root / "settings.txt").write_text("mode = draft\n", encoding="utf-8")
    result = batch_apply(root, [
        ReplaceOp(file="settings.txt", edits=[
            Edit(old="mode = draft", new="mode = ready"),
        ]),
        CreateOp(file="notes.txt", content="Ready for review.\n"),
    ])
    assert result.success, result.error
    assert result.summary == {"modified": 1, "created": 1, "deleted": 0}
    assert result.checkpoint is not None
    restored = rollback(root, result.checkpoint)
    assert restored.ok, restored.unrestored
    assert (root / "settings.txt").read_text() == "mode = draft\n"
    assert not (root / "notes.txt").exists()

The assertions verify that one file was changed and another created, then that rollback restored their prior state. Success produces no output.

Usage

Choose an interface

Need Tool
Apply whole-line edits and file operations batch_edit
Undo using a retained structured snapshot batch_rollback
Read, search or list project files read_file, search_files, list_dir
Write a file or replace substrings write_file, edit_file
Inspect SHA-256, UTF-8 and escape sequences file_bytes
Run an executable in a selected directory run_command

read_file, write_file and edit_file take path (project root) and file (target within it). file_bytes instead takes a file path without project-root confinement. run_command constrains its initial working directory, not the executable's filesystem or network access.

The tool batch_edit runs Ruff fix/format by default on touched Python files; use lint=False / CLI --no-lint to apply only the supplied edits. A successful tool result does not certify lint cleanliness. The checkpoint is present in structured data after apply starts, but is omitted from the compact text returned by the MCP axm_call façade.

Documentation

Development

From the axm-forge workspace root:

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

See CONTRIBUTING.md for the workspace workflow. 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-edit 0.3.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-edit 0.3.1
File Size Uploaded
axm_edit-0.3.1.tar.gz 152.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for axm-edit 0.3.1
File Interpreter ABI Platform
axm_edit-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 239.0 kB

Release files / axm_edit-0.3.1.tar.gz

Download URL axm_edit-0.3.1.tar.gz
Size 152.5 kB
Tags Source
SHA-256 checksum
How to use checksums
dec0633ada5d36a95283038ad12bd2f7075ff545529450f9185b0274d8a5eb85
BLAKE2b-256 checksum
How to use checksums
70dc18d54d7e6349443017d527889189d717b29c10ed8098c0a8bd185bc3e5a2
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 Sep 17, 2026.

Transparency log

Release files / axm_edit-0.3.1-py3-none-any.whl

Download URL axm_edit-0.3.1-py3-none-any.whl
Size 86.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a7ed88a14827e6dddab8df1686f4578036dc03ca951eac14688b183b0540a73c
BLAKE2b-256 checksum
How to use checksums
04847dd2abaa6bec7347c3b7fa69004d9f646555047f4af1192aadd8f156dd80
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 Sep 17, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.0

2 release files

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.1

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