Skip to main content

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_syntax for 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 .sql files.
  • 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 diff plus 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.toml thresholds 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.

Metadata

Release files for mehen 1.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mehen 1.10.0
File Size Uploaded Provenance
mehen-1.10.0.tar.gz 1.7 MB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for mehen 1.10.0
File
mehen-1.10.0-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details
mehen-1.10.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
mehen-1.10.0-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details
mehen-1.10.0-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details
mehen-1.10.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details
mehen-1.10.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl Python 3 none Linux glibc 2.5+ x86-64 Details
mehen-1.10.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
mehen-1.10.0-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details

Total release size: 97.5 MB

Release files / mehen-1.10.0.tar.gz

Download URL mehen-1.10.0.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
a9a76fda74db144410f16431b2ae2e0005f5242e5a5a7a49227035538b097204
BLAKE2b-256 checksum
How to use checksums
e2b352d4e6d890173e0ca3c6dc45a9d26f7041c21a647691601a627f528ea310
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 Aug 19, 2026.

Transparency log

Release files / mehen-1.10.0-py3-none-win_arm64.whl

Download URL mehen-1.10.0-py3-none-win_arm64.whl
Size 11.6 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
2c4ee664fa50c78fbe0da13f34c0174c8bec8ebc0c1c9926d72a2524b57681f3
BLAKE2b-256 checksum
How to use checksums
ca3b1161b548c1d0ea47d3fbdd1a59aec911a298236cb0e4d88b8913f778fbce
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 Aug 19, 2026.

Transparency log

Release files / mehen-1.10.0-py3-none-win_amd64.whl

Download URL mehen-1.10.0-py3-none-win_amd64.whl
Size 12.9 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
274151e8688987fbd6cbac27bdb19a9d4747792d739042db2c98b92cfa62d0db
BLAKE2b-256 checksum
How to use checksums
e9abbe9ffbf5efd8ad7b409c7acd8e72c3e19a199c281c87829046c1dc5eed9e
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 Aug 19, 2026.

Transparency log

Release files / mehen-1.10.0-py3-none-manylinux_2_28_x86_64.whl

Download URL mehen-1.10.0-py3-none-manylinux_2_28_x86_64.whl
Size 12.4 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
8d00eaa1010904e482fd5642c15a7536f542460f039b064157c8f81c5617ad10
BLAKE2b-256 checksum
How to use checksums
ba02b0235e962e9617a33d3a3f20626ff7103581a6a185ebfd61d260257c8869
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 Aug 19, 2026.

Transparency log

Release files / mehen-1.10.0-py3-none-manylinux_2_28_aarch64.whl

Download URL mehen-1.10.0-py3-none-manylinux_2_28_aarch64.whl
Size 11.5 MB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
803f8f68774c601c37d38f10567cd7219578cd333f6e8c276a690934ef60fc17
BLAKE2b-256 checksum
How to use checksums
a9c600736dd853dca8b37afcaa60bb7ebc5d515d91fc1a5bd1c37e0d83a68abb
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 Aug 19, 2026.

Transparency log

Release files / mehen-1.10.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL mehen-1.10.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 11.4 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
75978e056a98596008cab54b6a9e86c7f0db023f5d8b7864802b18e7c1ab749b
BLAKE2b-256 checksum
How to use checksums
b09757a7907c32c14fbb67bfb01eb131b7e0b824fb8c3132cd11e371130fc9b7
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 Aug 19, 2026.

Transparency log

Release files / mehen-1.10.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl

Download URL mehen-1.10.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Size 12.5 MB
Tags Linux glibc 2.5+ x86-64 Python 3
SHA-256 checksum
How to use checksums
569978753b4f73a30cc5153382a010b59887277832b50f4d90168557c25aa8de
BLAKE2b-256 checksum
How to use checksums
5f12c1506e49440a117e774229736cc62c6fa529d26470e33871ffd745ce84cf
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 Aug 19, 2026.

Transparency log

Release files / mehen-1.10.0-py3-none-macosx_11_0_arm64.whl

Download URL mehen-1.10.0-py3-none-macosx_11_0_arm64.whl
Size 11.4 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
21b56e3bbbed630267e73626602bd87dbafc04910c75fbcb39090883895fda79
BLAKE2b-256 checksum
How to use checksums
4f48d764af117e4df71aa6f32c15ad5ea0b41046228316111d553bd151f1643f
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 Aug 19, 2026.

Transparency log

Release files / mehen-1.10.0-py3-none-macosx_10_12_x86_64.whl

Download URL mehen-1.10.0-py3-none-macosx_10_12_x86_64.whl
Size 12.3 MB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
d91b7b8b01248f8892bbe72dd7c4d6d8f9d4e55a3c75ef13a7d81f0dac20a55c
BLAKE2b-256 checksum
How to use checksums
32610d166eca834174d1edf6592f336b1ada4806eaf845983e124f6021b4f2cc
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 Aug 19, 2026.

Transparency log

Security for mehen 1.10.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.

Full provenance

All 9 files in this release have been uploaded with provenance metadata.

Select from 9 files

Attestation for mehen-1.10.0.tar.gz

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 Aug 19, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page