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@0.3.0
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@0.3.0 <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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file refactron-0.3.1.tar.gz.
File metadata
- Download URL: refactron-0.3.1.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db7d2ddae02d24bb162c8a1c9e30239b51f38a24c7c48458c186feeb552a6db4
|
|
| MD5 |
596dfb48fc5790e56c188a050469db43
|
|
| BLAKE2b-256 |
3adac2eea898d196ff27aef931039491d7bd35e2a8c7166f31d8b5b2317c15a7
|
Provenance
The following attestation bundles were made for refactron-0.3.1.tar.gz:
Publisher:
release.yml on Refactron-ai/Refactron_Lib_TS
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
refactron-0.3.1.tar.gz -
Subject digest:
db7d2ddae02d24bb162c8a1c9e30239b51f38a24c7c48458c186feeb552a6db4 - Sigstore transparency entry: 2359715431
- Sigstore integration time:
-
Permalink:
Refactron-ai/Refactron_Lib_TS@93b2de01089433e427b73315e8bdac47683d40a4 -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/Refactron-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@93b2de01089433e427b73315e8bdac47683d40a4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file refactron-0.3.1-py3-none-any.whl.
File metadata
- Download URL: refactron-0.3.1-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0e03735843ae198008b85b45067a7aff9bf55c0afa630775c7ed3645d80bfad
|
|
| MD5 |
42f68f059270a5bf1865534fd259edc1
|
|
| BLAKE2b-256 |
d81c12d7d25b6ab816c464681cf4a83067df369fffcb940eac97a32180a98620
|
Provenance
The following attestation bundles were made for refactron-0.3.1-py3-none-any.whl:
Publisher:
release.yml on Refactron-ai/Refactron_Lib_TS
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
refactron-0.3.1-py3-none-any.whl -
Subject digest:
b0e03735843ae198008b85b45067a7aff9bf55c0afa630775c7ed3645d80bfad - Sigstore transparency entry: 2359715486
- Sigstore integration time:
-
Permalink:
Refactron-ai/Refactron_Lib_TS@93b2de01089433e427b73315e8bdac47683d40a4 -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/Refactron-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@93b2de01089433e427b73315e8bdac47683d40a4 -
Trigger Event:
push
-
Statement type: