Skip to main content

refactron (Python wrapper)

The verification layer for AI code change. Refactron proves that a change, your AI agent's, a codemod's, or your own, preserved behavior. It applies the diff in an isolated shadow tree, runs your real test suite, and returns a three-way verdict: SAFE, UNSAFE, or UNPROVEN. Your working tree is never touched.

This package is a thin Python shim around the npm refactron package. It exists so a Python-first toolchain can put the refactron command on your PATH without adding Node to your project manifest. All the real work happens in the Node CLI.

Requirements

  • Node.js 18+ on your PATH. This wrapper does not remove the Node dependency; it only saves you from wiring the CLI in by hand.
  • Python 3.8+, plus coverage.py in the environment your tests run in if you want coverage-backed verdicts.

Install

pip install refactron==0.3.0
npm install -g refactron

Both lines matter. The pip package gives you the refactron entry point; the npm package is what it runs. Keep the two versions equal: the wrapper prints a warning to stderr when they disagree.

The wrapper does not install the npm package for you. A pip install that silently ran npm install -g would write outside your Python environment and would pull whatever version is latest, which is not necessarily the version you pinned. If the Node CLI is missing, the wrapper tells you the exact command to run and exits non-zero.

Prefer not to install globally? Skip the pip package and use npx refactron <command> directly.

Usage

Identical to the npm package. Every argument is passed straight through.

refactron login                                  # or set REFACTRON_TOKEN in CI
refactron verify-diff . --diff change.diff --test-cmd "python3 -m pytest -q"
refactron preflight ./my-sqlalchemy-app
refactron analyze .
refactron run --apply

verify-diff exits 1 on UNSAFE, 2 on bad input, 7 when unauthenticated, and 0 on both SAFE and UNPROVEN. UNPROVEN is a warning, not a rejection: read the verdict field from --json if you want CI to fail on it.

Coverage attestation is Python-only, via coverage.py. A TypeScript, mixed, or otherwise non-Python diff caps at UNPROVEN; it never returns a false SAFE.

MCP server

The npm package also ships a refactron-mcp binary, a stdio MCP server exposing a verify_change tool your agent calls before it lands a change. It is not routed through this wrapper: point your MCP client at refactron-mcp directly. See the MCP docs.

Environment variables

Variable Effect
REFACTRON_TOKEN Authenticates non-interactive runs (CI).
REFACTRON_SKIP_VERSION_CHECK Set to 1 to silence the wrapper's version-skew warning.

License

Apache-2.0. See LICENSE and NOTICE.

Full docs: https://docs.refactron.dev

Metadata

Release files for refactron 0.4.6

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

Source distribution (sdist)

Source distribution for refactron 0.4.6
File Size Uploaded
refactron-0.4.6.tar.gz 10.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for refactron 0.4.6
File Interpreter ABI Platform
refactron-0.4.6-py3-none-any.whl Python 3 none any Details

Total release size: 21.2 kB

Release files / refactron-0.4.6.tar.gz

Download URL refactron-0.4.6.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
da3ec0eec2aaad23be4e811b2d319845aa44fc4d28bb500af553480e5ba8b4db
BLAKE2b-256 checksum
How to use checksums
9253d2d9ebb91e5117b078fd62f6ce34eef92f07401852781f30aedf8f82fd39
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 8, 2026.

Transparency log

Release files / refactron-0.4.6-py3-none-any.whl

Download URL refactron-0.4.6-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba6a5d77881139456a1f16c919871a9dd06bde0b982b92b5b66f30f621ed4d8a
BLAKE2b-256 checksum
How to use checksums
96404553b3683a8b2c8ce0a8ca3c59c68370842d3cc088a82dc78284a85fdb2f
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 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.6 This release

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

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