mehen
mehen is a Rust-powered CLI for detecting heuristic source code metrics at scale: complexity, maintainability, lines of code, documentation health, and more.
It is designed for fast, deterministic analysis over large codebases, helping both human and AI engineers track how complexity evolves over time.
📚 Documentation: https://mehen.ophi.dev
What is Mehen?
In Ophidiarium projects, names matter. Mehen is a mythical ancient Egyptian serpent associated with
guarding Ra. In the same spirit, mehen helps guard your codebase from slowly collapsing under
complexity.
Why teams use mehen
- Polyglot by design — per-file language detection across eleven source languages plus Markdown and SQL. Useful for monorepos.
- Real language parsers — Ruff for Python, Oxc for TS/JS/JSX/TSX, Mago for PHP, Prism for Ruby,
ra_ap_syntaxfor Rust, ANTLR (Kotlin spec grammar for Kotlin, grammars-v4 for Java and C#), pulldown-cmark for Markdown, sqruff for SQL, tree-sitter for Go, C, PowerShell. - Code, documentation, and SQL in one tool — source-code complexity, Markdown documentation
health, and a dedicated relational metric family for
.sqlfiles. - Bring-your-own coverage — ingests LCOV, Cobertura, JaCoCo, Clover, Istanbul, and Go
coverprofile reports, auto-discovers them in their idiomatic (usually gitignored) locations,
and publishes
coverage.*as a rankable, gateable metric family down to per-function values. - Deterministic, no network — pure static analysis. Same input → same output. Safe for air-gapped CI.
- Pull-request native — built-in
mehen diffplus a sticky comment GitHub Action.
Install
# npm
npm install -g mehen
# PyPI / uv
uv tool install mehen
# or: pip install mehen
# cargo binstall
cargo binstall --git https://github.com/ophi-dev/mehen mehen
Full installation guide: https://mehen.ophi.dev/installation.
Quick start
# Analyze a single file
mehen metrics src/main.py --pretty
# Rank the worst offenders in a tree
mehen top-offenders src --metric cognitive
# Diff metrics against main
mehen diff --from main --to HEAD --paths src --output-format markdown
Quickstart: https://mehen.ophi.dev/quickstart.
Configuration
Drop a mehen.toml (or .mehen.toml) anywhere between the directory you run mehen from and
the git repository root — discovery walks upward and stops at the repository boundary — or pin an
explicit file with --config <PATH>:
[thresholds]
cognitive = 15 # higher-is-worse metrics: the limit is a maximum
"loc.lloc" = 500
mi.visual_studio = 40 # higher-is-better metrics (mi.*): the limit is a minimum
[languages.python.thresholds]
cognitive = 10 # overrides the global limit for Python files only
Every command that reports a configured metric enforces it: mehen metrics checks the full
metric set of the analyzed file, while mehen diff (head side) and mehen top-offenders check
the metrics selected for output — across all analyzed files, not just the displayed rows. Any
crossed limit prints a grouped report on stderr and fails the command with exit code 1:
× 2 metric threshold violations (config: /repo/mehen.toml)
│
│ src/app/core.py
│ cognitive = 23 — exceeds max 10 (set by languages.python.thresholds)
│ loc.lloc = 640 — exceeds max 500 (set by thresholds)
help: adjust or remove the limit at the configuration path shown, or bring the file back within it.
Configuration mistakes fail fast with a caret into the TOML source and a suggestion ("unknown
metric cognitve … did you mean cognitive?"): every metric name is validated against the keys
the analyzers actually publish — including the sql.* and markdown.* namespaces — so a typo
can never silently disable a gate. Full reference: https://mehen.ophi.dev/configuration.
GitHub Action
Drop the action into a workflow to publish per-PR metric trends:
permissions:
contents: read
pull-requests: write
issues: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: ophi-dev/mehen@v1
with:
paths: src
Full reference: https://mehen.ophi.dev/guides/github-action.
Documentation
Everything else lives in the docs site:
- Code metrics — cyclomatic, cognitive, Halstead, MI, ABC, LOC family, NOM, NPA, NPM, WMC.
- Markdown metrics — DMI, MRPC, MCC, link debt, filler/lazy risk, English/Japanese prose layer.
- SQL metrics — CTE graphs, join/subquery structure,
object-touch risk, SQL Halstead, and composite scores via
mehen-sql(sqruff-backed). - Coverage metrics — ingest test-coverage reports (six formats, auto-discovered), gate on line/branch/function coverage, rank the least-tested files.
- Commands —
mehen metrics,mehen diff,mehen top-offenders. - Configuration —
mehen.tomlthresholds and per-language overrides. - Developers guide — build, test, contribute, add a language.
Contributing
Issues and pull requests welcome at https://github.com/ophi-dev/mehen/issues.
License
mehen is released under the GNU Affero General Public License v3.0.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 mehen-1.10.0.tar.gz.
File metadata
- Download URL: mehen-1.10.0.tar.gz
- Upload date:
- Size: 1.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9a76fda74db144410f16431b2ae2e0005f5242e5a5a7a49227035538b097204
|
|
| MD5 |
47bc7528eb67fc8f40a66a962bde7cca
|
|
| BLAKE2b-256 |
e2b352d4e6d890173e0ca3c6dc45a9d26f7041c21a647691601a627f528ea310
|
Provenance
The following attestation bundles were made for mehen-1.10.0.tar.gz:
Publisher:
release.yml on ophi-dev/mehen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mehen-1.10.0.tar.gz -
Subject digest:
a9a76fda74db144410f16431b2ae2e0005f5242e5a5a7a49227035538b097204 - Sigstore transparency entry: 2517270454
- Sigstore integration time:
-
Permalink:
ophi-dev/mehen@df9ffd96149f71b734326dd0fed26cd170911834 -
Branch / Tag:
refs/tags/v1.10.0 - Owner: https://github.com/ophi-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@df9ffd96149f71b734326dd0fed26cd170911834 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mehen-1.10.0-py3-none-win_arm64.whl.
File metadata
- Download URL: mehen-1.10.0-py3-none-win_arm64.whl
- Upload date:
- Size: 11.6 MB
- Tags: Python 3, Windows ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c4ee664fa50c78fbe0da13f34c0174c8bec8ebc0c1c9926d72a2524b57681f3
|
|
| MD5 |
7b7d177ddd22263cae725976a8e195d8
|
|
| BLAKE2b-256 |
ca3b1161b548c1d0ea47d3fbdd1a59aec911a298236cb0e4d88b8913f778fbce
|
Provenance
The following attestation bundles were made for mehen-1.10.0-py3-none-win_arm64.whl:
Publisher:
release.yml on ophi-dev/mehen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mehen-1.10.0-py3-none-win_arm64.whl -
Subject digest:
2c4ee664fa50c78fbe0da13f34c0174c8bec8ebc0c1c9926d72a2524b57681f3 - Sigstore transparency entry: 2517270549
- Sigstore integration time:
-
Permalink:
ophi-dev/mehen@df9ffd96149f71b734326dd0fed26cd170911834 -
Branch / Tag:
refs/tags/v1.10.0 - Owner: https://github.com/ophi-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@df9ffd96149f71b734326dd0fed26cd170911834 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mehen-1.10.0-py3-none-win_amd64.whl.
File metadata
- Download URL: mehen-1.10.0-py3-none-win_amd64.whl
- Upload date:
- Size: 12.9 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
274151e8688987fbd6cbac27bdb19a9d4747792d739042db2c98b92cfa62d0db
|
|
| MD5 |
8ab357d28588cd29c680b847df5785f6
|
|
| BLAKE2b-256 |
e9abbe9ffbf5efd8ad7b409c7acd8e72c3e19a199c281c87829046c1dc5eed9e
|
Provenance
The following attestation bundles were made for mehen-1.10.0-py3-none-win_amd64.whl:
Publisher:
release.yml on ophi-dev/mehen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mehen-1.10.0-py3-none-win_amd64.whl -
Subject digest:
274151e8688987fbd6cbac27bdb19a9d4747792d739042db2c98b92cfa62d0db - Sigstore transparency entry: 2517270650
- Sigstore integration time:
-
Permalink:
ophi-dev/mehen@df9ffd96149f71b734326dd0fed26cd170911834 -
Branch / Tag:
refs/tags/v1.10.0 - Owner: https://github.com/ophi-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@df9ffd96149f71b734326dd0fed26cd170911834 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mehen-1.10.0-py3-none-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: mehen-1.10.0-py3-none-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 12.4 MB
- Tags: Python 3, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d00eaa1010904e482fd5642c15a7536f542460f039b064157c8f81c5617ad10
|
|
| MD5 |
9077ed984404919e0103a9a3f1168c06
|
|
| BLAKE2b-256 |
ba02b0235e962e9617a33d3a3f20626ff7103581a6a185ebfd61d260257c8869
|
Provenance
The following attestation bundles were made for mehen-1.10.0-py3-none-manylinux_2_28_x86_64.whl:
Publisher:
release.yml on ophi-dev/mehen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mehen-1.10.0-py3-none-manylinux_2_28_x86_64.whl -
Subject digest:
8d00eaa1010904e482fd5642c15a7536f542460f039b064157c8f81c5617ad10 - Sigstore transparency entry: 2517270584
- Sigstore integration time:
-
Permalink:
ophi-dev/mehen@df9ffd96149f71b734326dd0fed26cd170911834 -
Branch / Tag:
refs/tags/v1.10.0 - Owner: https://github.com/ophi-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@df9ffd96149f71b734326dd0fed26cd170911834 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mehen-1.10.0-py3-none-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: mehen-1.10.0-py3-none-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 11.5 MB
- Tags: Python 3, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
803f8f68774c601c37d38f10567cd7219578cd333f6e8c276a690934ef60fc17
|
|
| MD5 |
6fa24684ba42dea5510e2773dcb1c6d0
|
|
| BLAKE2b-256 |
a9c600736dd853dca8b37afcaa60bb7ebc5d515d91fc1a5bd1c37e0d83a68abb
|
Provenance
The following attestation bundles were made for mehen-1.10.0-py3-none-manylinux_2_28_aarch64.whl:
Publisher:
release.yml on ophi-dev/mehen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mehen-1.10.0-py3-none-manylinux_2_28_aarch64.whl -
Subject digest:
803f8f68774c601c37d38f10567cd7219578cd333f6e8c276a690934ef60fc17 - Sigstore transparency entry: 2517270682
- Sigstore integration time:
-
Permalink:
ophi-dev/mehen@df9ffd96149f71b734326dd0fed26cd170911834 -
Branch / Tag:
refs/tags/v1.10.0 - Owner: https://github.com/ophi-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@df9ffd96149f71b734326dd0fed26cd170911834 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mehen-1.10.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: mehen-1.10.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 11.4 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75978e056a98596008cab54b6a9e86c7f0db023f5d8b7864802b18e7c1ab749b
|
|
| MD5 |
29d2a7f3485dfb2b48a270714633cfbd
|
|
| BLAKE2b-256 |
b09757a7907c32c14fbb67bfb01eb131b7e0b824fb8c3132cd11e371130fc9b7
|
Provenance
The following attestation bundles were made for mehen-1.10.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on ophi-dev/mehen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mehen-1.10.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
75978e056a98596008cab54b6a9e86c7f0db023f5d8b7864802b18e7c1ab749b - Sigstore transparency entry: 2517270611
- Sigstore integration time:
-
Permalink:
ophi-dev/mehen@df9ffd96149f71b734326dd0fed26cd170911834 -
Branch / Tag:
refs/tags/v1.10.0 - Owner: https://github.com/ophi-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@df9ffd96149f71b734326dd0fed26cd170911834 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mehen-1.10.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl.
File metadata
- Download URL: mehen-1.10.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
- Upload date:
- Size: 12.5 MB
- Tags: Python 3, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
569978753b4f73a30cc5153382a010b59887277832b50f4d90168557c25aa8de
|
|
| MD5 |
e4f76dc751c03d313daaaf1bcbd42c68
|
|
| BLAKE2b-256 |
5f12c1506e49440a117e774229736cc62c6fa529d26470e33871ffd745ce84cf
|
Provenance
The following attestation bundles were made for mehen-1.10.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl:
Publisher:
release.yml on ophi-dev/mehen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mehen-1.10.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl -
Subject digest:
569978753b4f73a30cc5153382a010b59887277832b50f4d90168557c25aa8de - Sigstore transparency entry: 2517270498
- Sigstore integration time:
-
Permalink:
ophi-dev/mehen@df9ffd96149f71b734326dd0fed26cd170911834 -
Branch / Tag:
refs/tags/v1.10.0 - Owner: https://github.com/ophi-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@df9ffd96149f71b734326dd0fed26cd170911834 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mehen-1.10.0-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: mehen-1.10.0-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 11.4 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21b56e3bbbed630267e73626602bd87dbafc04910c75fbcb39090883895fda79
|
|
| MD5 |
46d56f50f9915150f688a5d7f010427a
|
|
| BLAKE2b-256 |
4f48d764af117e4df71aa6f32c15ad5ea0b41046228316111d553bd151f1643f
|
Provenance
The following attestation bundles were made for mehen-1.10.0-py3-none-macosx_11_0_arm64.whl:
Publisher:
release.yml on ophi-dev/mehen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mehen-1.10.0-py3-none-macosx_11_0_arm64.whl -
Subject digest:
21b56e3bbbed630267e73626602bd87dbafc04910c75fbcb39090883895fda79 - Sigstore transparency entry: 2517270714
- Sigstore integration time:
-
Permalink:
ophi-dev/mehen@df9ffd96149f71b734326dd0fed26cd170911834 -
Branch / Tag:
refs/tags/v1.10.0 - Owner: https://github.com/ophi-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@df9ffd96149f71b734326dd0fed26cd170911834 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mehen-1.10.0-py3-none-macosx_10_12_x86_64.whl.
File metadata
- Download URL: mehen-1.10.0-py3-none-macosx_10_12_x86_64.whl
- Upload date:
- Size: 12.3 MB
- Tags: Python 3, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d91b7b8b01248f8892bbe72dd7c4d6d8f9d4e55a3c75ef13a7d81f0dac20a55c
|
|
| MD5 |
1c4e62ff4cbf6c4ef540dd0f0efdeba4
|
|
| BLAKE2b-256 |
32610d166eca834174d1edf6592f336b1ada4806eaf845983e124f6021b4f2cc
|
Provenance
The following attestation bundles were made for mehen-1.10.0-py3-none-macosx_10_12_x86_64.whl:
Publisher:
release.yml on ophi-dev/mehen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mehen-1.10.0-py3-none-macosx_10_12_x86_64.whl -
Subject digest:
d91b7b8b01248f8892bbe72dd7c4d6d8f9d4e55a3c75ef13a7d81f0dac20a55c - Sigstore transparency entry: 2517270516
- Sigstore integration time:
-
Permalink:
ophi-dev/mehen@df9ffd96149f71b734326dd0fed26cd170911834 -
Branch / Tag:
refs/tags/v1.10.0 - Owner: https://github.com/ophi-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@df9ffd96149f71b734326dd0fed26cd170911834 -
Trigger Event:
push
-
Statement type: