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.pyin 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.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| refactron-0.4.4.tar.gz | 10.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| refactron-0.4.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.2 kB
Release files / refactron-0.4.4.tar.gz
| Download URL | refactron-0.4.4.tar.gz |
|---|---|
| Size | 10.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c1f4bebf754a56742fa1e43e0feffa307415e68a7b46837543f0b89798148001
|
|
BLAKE2b-256 checksum How to use checksums |
711693a65640f093fb5b0ad9cc1c8d23926235d686939aa01064d8d84f6b4453
|
| 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 1, 2026.
Transparency logRelease files / refactron-0.4.4-py3-none-any.whl
| Download URL | refactron-0.4.4-py3-none-any.whl |
|---|---|
| Size | 11.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
682c55c78c5eb8b329f643c2e27323962f462562f1911f910f8a1d056318531a
|
|
BLAKE2b-256 checksum How to use checksums |
f8b31177f4c2c6da6992cb6c9f0fabc2c45743a6d17d8eafe5cb56eec3208033
|
| 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 1, 2026.
Transparency log