instruction-drift
An offline, deterministic, stdlib-only Python CLI that checks concrete instruction claims against repository files. A finding means check this claim. It does not establish that an instruction is wrong. No daemon, LLM, network, or keys.
Requires Python 3.9+. Install a locally built wheel with pip install /path/to/instruction_drift-0.1.0-py3-none-any.whl.
instruction-drift audit .
instruction-drift audit examples/sample-repo --json
instruction-drift audit . --files AGENTS.md CONTRIBUTING.md --ignore 'docs/*'
instruction-drift audit . --fail-on medium
instruction-drift --version
instruction-drift --help
The repository defaults to the current directory. Default instruction files,
in order, are root AGENTS.md, CLAUDE.md, MUSE.md, and CONTRIBUTING.md. Missing
default files are skipped; an empty repository passes with a note. --files
replaces that list with paths relative to the repository. Missing explicitly
requested files, unreadable files, and invalid UTF-8 produce parse errors.
--files and --ignore accept multiple arguments and can be repeated.
Checks are heuristic:
- referenced-file (HIGH): missing path tokens containing
/and ending in .py, .js, .ts, .md, .json, .yaml, .yml, .toml, .sh, .go, .rs, or .txt; also directory references rooted under src/, tests/, docs/, examples/, scripts/, or bin/. Trailing/requires a directory. Paths resolve relative to the repository root. URLs, tokens containing*, and paths resolving outside the repository are skipped. - script-in-command (HIGH): missing path tokens in backticked commands;
missing
make targettargets when a root Makefile exists. Simple literal target definitions are recognized; Makefile variables and comments are not definitions. A command path is reported once rather than also as a reference. - prohibition-contradiction (MEDIUM): “do not use”, “never use”, “must not use”, or “avoid using” followed by an identifier also found in a Python import/from import or JS/TS require/from import. Verify manually: exceptions and test fixtures may be intentional. Instruction files are excluded from source search. Hidden directories, .git, node_modules, dist, pycache, .venv, and venv are skipped, as are symlinked directories.
The report includes files read, file:line locations, kinds, claims, severities,
details, totals by kind and severity, ignored count, parse-error count, and a
PASS/WARN/FAIL verdict. --json exposes the same information as valid JSON.
Claims matching --ignore glob patterns are excluded and counted before
checking their validity. Findings are deduplicated by file, line, kind, and
claim. At most 500 findings are retained in instruction-file and line order;
additional findings set the truncation flag. Totals describe retained findings. Failure thresholds still apply to findings
beyond the display cap.
Exit codes:
| Code | Meaning |
|---|---|
| 0 | PASS: no findings and no parse errors |
| 1 | WARN: findings exist, but none reach the failure threshold |
| 2 | FAIL: a finding reaches the threshold, or any parse error occurs |
The default threshold is HIGH; --fail-on medium also fails MEDIUM findings.
For example, the synthetic sample repo cites a renamed script and moved test
directory, and prohibits an identifier imported in src/app.py. Auditing it
returns two HIGH findings, one MEDIUM finding, and exit code 2. Its illustrative
import does not require an installed dependency because commands are never run.
Limitations
This is pattern matching, not semantic judgement. Paraphrased claims are not checked. A MEDIUM contradiction needs human review. Commands are not executed; only path tokens and simple Makefile target names are checked. Dynamic imports, complex shell syntax, generated paths, multiline imports, Makefile includes and computed targets, and language-specific resolution are not interpreted. Lexical import patterns may match comments or strings and may miss real imports. Source files that cannot be decoded or read are skipped; this can hide import matches. Instruction-file read failures always produce parse errors. A truncated report is incomplete. Filesystem changes during a scan can affect its results.
Differentiation
- startup-trust-guard audits TRUST: can an attacker plant or rewrite the instruction file? instruction-drift audits TRUTH: is what it says still true about the on-disk repository?
- rules-doctor audits rule-file health and structure. This tool cross-checks instruction claims against the on-disk repo.
- edit-guard blocks edits made on stale reads. This tool finds stale instructions that can cause those edits.
- context-mode / heavy runtimes: this is an offline stdlib CLI with no daemon, no LLM, and no network.
Development
PYTHONPATH=src python3 -m unittest discover -s tests -v
python3 -m build
Building requires setuptools, wheel, and the build frontend already installed for offline use. Runtime and tests use only the Python standard library.
Metadata
Release files for instruction-drift 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| instruction_drift-0.1.0.tar.gz | 12.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| instruction_drift-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.6 kB
Release files / instruction_drift-0.1.0.tar.gz
| Download URL | instruction_drift-0.1.0.tar.gz |
|---|---|
| Size | 12.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e9121aa99fff56b3772aafec50b430aa8797799289b3f1d134ae185a05bb13f8
|
|
BLAKE2b-256 checksum How to use checksums |
8f12131e3eeeb80a6073f7c23ab699a9fe8cabe1bbdf2de42079b824eb731325
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / instruction_drift-0.1.0-py3-none-any.whl
| Download URL | instruction_drift-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e3d73554c821b1def3677542b03bc1062eb0b3caca0fbab8ca821c7e14f31278
|
|
BLAKE2b-256 checksum How to use checksums |
ea1c574bc6c6d5fcf3877f3fcd43f77113e04fd83b4521ac0966e8c3f425e20f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for instruction-drift 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.