Metrolith
Evidence, not scores.
Metrolith is a local-first, multi-language static-analysis CLI. It produces versioned code metrics and offline reports so you can investigate a source tree, inspect complex functions, and compare changes between revisions. Optional duplication and history analyses provide additional evidence; you choose which analyses and rules to run.
Inspect what was measured, what was excluded, and where results are partial or unavailable before deciding what to change.
Languages: Python, Java, JavaScript/TypeScript and Go. Parsing and measurement coverage are language-specific.
Try online · Explore a recorded demo · Install from PyPI · Read the guide
Three questions to start with
- What is in this source tree? Inspect languages, files, code size, classes/structs and methods/functions alongside inclusion reasons and explicit measurement coverage.
- Where should I look more closely? Read callable complexity, then request lexical or structural duplication evidence separately. Their populations can overlap; their group counts are not a combined defect total.
- What changed between revisions? Use revision Diff or existing-Run comparisons, and Changed Code for explicit base/head revisions. Evaluate a Policy of rules you select; measurements do not infer architecture quality.
For how these pieces fit together, see Architecture.
Quickstart from PyPI
Install in a fresh virtual environment, check the environment, then run a tiny bundled example. CPython 3.13 is required (>=3.13,<3.14); 3.13.9 is the verified patch on Windows and Ubuntu. Git must be on PATH, including for local directory snapshots. Your analyzed directory need not be a Git repository.
Start in an empty working directory outside your project's source. Use an unused metrolith-user environment directory. Installation can download dependencies; the bundled local example is network-free afterward.
PowerShell — python must resolve to CPython 3.13:
python --version
git --version
python -m venv "metrolith-user"
& "./metrolith-user/Scripts/python.exe" -m pip install "metrolith==4.0.0"
$env:PATH = "$((Resolve-Path './metrolith-user/Scripts').Path);$env:PATH"
metrolith doctor --format text
metrolith example run --local
Ubuntu / POSIX shell:
python3.13 --version
git --version
python3.13 -m venv "metrolith-user"
"./metrolith-user/bin/python" -m pip install "metrolith==4.0.0"
. "./metrolith-user/bin/activate"
metrolith doctor --format text
metrolith example run --local
Stop if a prerequisite check or installation fails. PowerShell changes PATH only for this session; no execution-policy change is needed.
With published Metrolith 4.0.0, the bundled example measures 22 code lines, 2 source files, 0 classes/structs and 4 methods/functions, with complete core metrics. Zero classes is a measured result. The Run path printed by example run --local belongs to this example; open its summary.md to inspect these values.
Next, in the same configured shell, change to your project's source directory and run:
metrolith analyze . --workspace "../metrolith-results"
Choose an output workspace outside the analyzed source. This command prints a new Run directory for your project under WORKSPACE/metrolith-output/runs/. metrolith analyze . also works; its default workspace is METROLITH_HOME or the current directory. Analysis reads source and writes outputs/cache state in the workspace. See source modes and locations.
Read your first Run
Open summary.md in the Run directory for the source you want to inspect. Each invocation prints its own path; use your project's path when reading your project.
Replace RUN below with the printed directory, keeping quotes:
metrolith report "RUN"
metrolith explain "RUN"
metrolith validate "RUN"
report writes the derived offline view at RUN/report.html; open it in a browser. explain describes recorded scope and availability. validate checks required artifacts and cross-file consistency; it does not rerun analysis or prove source authenticity. Keep the Run's JSON/CSV evidence and fact sheets with the report.
Completion does not mean every measurement is complete. Read partial, unavailable, not requested, and not applicable separately from measured zero. Optional analyses are not all executed by analyze.
Evidence and boundaries
Directory snapshots, working snapshots and exact Git revisions record different source identities. A working snapshot is not proof of committed bytes. A Policy contains your rules; a Ratchet compares selected measurements with a retained baseline and chosen tolerances. Neither supplies universal quality thresholds. Local PASS does not establish protected organizational approval.
pip install metrolith installs the CLI and offline reporting. The hosted Story/Explorer is a separate companion to the CLI's offline HTML report. Local source processing and the website's server-side repository processing have different privacy and feasibility boundaries; see the website guide.
Choose your next path
- Using Metrolith: Documentation map, Usage and full command reference, Examples.
- Understanding evidence: Architecture, recorded walkthrough, reproducibility.
- Contributing: Development preserves the hash-locked source setup. Build & smoke checks Ubuntu packaging and a tiny installed example; it is not full engine qualification.
- Maintaining releases: Publication record and procedure. Deliberate full qualification uses
tools/release_verify.pyandrequirements/release-verification.lock.
The deprecated archlens/arch-bench commands and frozen ArchLens format identifiers remain compatibility contracts.
License, citation and contact
Apache-2.0 · Software citation · Issues
Maintainer: Ali Sajedifar — its.alisajedifar@gmail.com.
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 metrolith-4.0.1.tar.gz.
File metadata
- Download URL: metrolith-4.0.1.tar.gz
- Upload date:
- Size: 9.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
002468f5663b019251e09ce8cdfb68242efd46520519c06f2ca1c73b2939ff7f
|
|
| MD5 |
fcbd4291244f70997d757a2a6c270a44
|
|
| BLAKE2b-256 |
fd3a029e9db4ec03b5a4e6167f3b23ce2345fd9ac852ec6f12a1b17a8506613d
|
Provenance
The following attestation bundles were made for metrolith-4.0.1.tar.gz:
Publisher:
publish-pypi.yml on AliSajedifar/metrolith
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metrolith-4.0.1.tar.gz -
Subject digest:
002468f5663b019251e09ce8cdfb68242efd46520519c06f2ca1c73b2939ff7f - Sigstore transparency entry: 2842263127
- Sigstore integration time:
-
Permalink:
AliSajedifar/metrolith@bb04e053ad35d6940779eaf1fd37a23b436c4ed5 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/AliSajedifar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@bb04e053ad35d6940779eaf1fd37a23b436c4ed5 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file metrolith-4.0.1-py3-none-any.whl.
File metadata
- Download URL: metrolith-4.0.1-py3-none-any.whl
- Upload date:
- Size: 1.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4e62135b24aa1c3a932776844e960a76e66b10133f16af3570980f8fe29172d
|
|
| MD5 |
e9bcf74ea7da07d795369293bbb07610
|
|
| BLAKE2b-256 |
d1487a8c0b329fb5fb4c6eccbf6b9823aba152b1866100eecdcb70b2967117b9
|
Provenance
The following attestation bundles were made for metrolith-4.0.1-py3-none-any.whl:
Publisher:
publish-pypi.yml on AliSajedifar/metrolith
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metrolith-4.0.1-py3-none-any.whl -
Subject digest:
f4e62135b24aa1c3a932776844e960a76e66b10133f16af3570980f8fe29172d - Sigstore transparency entry: 2842263235
- Sigstore integration time:
-
Permalink:
AliSajedifar/metrolith@bb04e053ad35d6940779eaf1fd37a23b436c4ed5 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/AliSajedifar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@bb04e053ad35d6940779eaf1fd37a23b436c4ed5 -
Trigger Event:
workflow_dispatch
-
Statement type: