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.4.0

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.4.0
File Size Uploaded
axm_edit-0.4.0.tar.gz 165.7 kB Details

Built distribution (wheel)

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

Total release size: 258.9 kB

Release files / axm_edit-0.4.0.tar.gz

Download URL axm_edit-0.4.0.tar.gz
Size 165.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bbdc095fc2ca4ff5b4303599fa2b68e8b3be06efff7245aea7c0fcebc87086a4
BLAKE2b-256 checksum
How to use checksums
ad56ee1ae795721737d3e410edb1fa5ec8cb8ac6ac2cfb0f4b8656e1294d9481
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_edit-0.4.0-py3-none-any.whl

Download URL axm_edit-0.4.0-py3-none-any.whl
Size 93.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fcb2868361db05ed33f3b6f4ec7d84a77021bfad094db8bd281cbf40b65f5224
BLAKE2b-256 checksum
How to use checksums
0b5dd8eb05ddaf9c75fbda2d725551be128e1273bf3ecc639a9cc3c8f5c3169e
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.0 This release

2 release files

0.3.1

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